Class: FhirPackagesManager::IgnoreList
- Inherits:
-
Object
- Object
- FhirPackagesManager::IgnoreList
- Defined in:
- lib/fhir_packages_manager/ignore_list.rb,
sig/fhir_packages_manager/ignore_list.rbs
Overview
A list of packages (optionally pinned to a version) to skip when fetching.
Loaded from a YAML or JSON file containing a flat array, e.g.:
- hl7.fhir.r4.core # ignore every version of this package
- name: hl7.fhir.us.core
version: 3.1.0 # ignore only this one version
Class Method Summary collapse
-
.load(path) ⇒ IgnoreList
Loads an ignore list from a YAML or JSON file (JSON iff the extension is .json).
Instance Method Summary collapse
-
#ignored?(name, version = nil) ⇒ Boolean
True if this name/version is on the ignore list.
-
#initialize(entries = []) ⇒ IgnoreList
constructor
A new instance of IgnoreList.
- #matches?(entry, name, version) ⇒ Boolean
- #normalize(entry) ⇒ Hash[Symbol, String?]
- #normalize_hash(entry) ⇒ Hash[Symbol, String?]
Constructor Details
#initialize(entries = []) ⇒ IgnoreList
Returns a new instance of IgnoreList.
32 33 34 |
# File 'lib/fhir_packages_manager/ignore_list.rb', line 32 def initialize(entries = []) @entries = entries.map { |entry| normalize(entry) } end |
Class Method Details
.load(path) ⇒ IgnoreList
Loads an ignore list from a YAML or JSON file (JSON iff the extension is .json).
19 20 21 22 23 24 25 26 27 |
# File 'lib/fhir_packages_manager/ignore_list.rb', line 19 def self.load(path) data = case File.extname(path).downcase when '.json' JSON.parse(File.read(path)) else YAML.load_file(path) end new(data || []) end |
Instance Method Details
#ignored?(name, version = nil) ⇒ Boolean
Returns true if this name/version is on the ignore list.
39 40 41 |
# File 'lib/fhir_packages_manager/ignore_list.rb', line 39 def ignored?(name, version = nil) @entries.any? { |entry| matches?(entry, name, version) } end |
#matches?(entry, name, version) ⇒ Boolean
45 46 47 48 49 50 |
# File 'lib/fhir_packages_manager/ignore_list.rb', line 45 def matches?(entry, name, version) return false unless entry[:name] == name ignored_version = entry[:version] ignored_version.nil? || ignored_version == version end |
#normalize(entry) ⇒ Hash[Symbol, String?]
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fhir_packages_manager/ignore_list.rb', line 52 def normalize(entry) case entry when String { name: entry, version: nil } when Hash normalize_hash(entry) else raise ArgumentError, "Invalid ignore list entry: #{entry.inspect}" end end |
#normalize_hash(entry) ⇒ Hash[Symbol, String?]
63 64 65 66 |
# File 'lib/fhir_packages_manager/ignore_list.rb', line 63 def normalize_hash(entry) version = entry['version'] || entry[:version] { name: entry['name'] || entry[:name], version: version&.to_s } end |