Class: FhirPackagesManager::IgnoreList

Inherits:
Object
  • Object
show all
Defined in:
lib/fhir_packages_manager/ignore_list.rb

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

Instance Method Summary collapse

Constructor Details

#initialize(entries = []) ⇒ IgnoreList

Returns a new instance of IgnoreList.

Parameters:

  • entries (Array<String, Hash>) (defaults to: [])

    bare package names (ignore every version) and/or {"name" => ..., "version" => ...} hashes (ignore only that version)

Raises:

  • (ArgumentError)

    if an entry is neither a String nor a Hash



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).

Parameters:

  • path (String)

    path to a YAML or JSON file containing a flat array of entries

Returns:



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.

Parameters:

  • name (String)

    the package name

  • version (String, nil) (defaults to: nil)

    the version being requested, if any

Returns:

  • (Boolean)

    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