Class: NcsNavigator::Warehouse::Transformers::VdrXml

Inherits:
Object
  • Object
show all
Defined in:
lib/ncs_navigator/warehouse/transformers/vdr_xml.rb,
lib/ncs_navigator/warehouse/transformers/vdr_xml/reader.rb

Defined Under Namespace

Classes: Reader

Class Method Summary collapse

Class Method Details

.from_file(config, filename, options = {}) ⇒ #transform

Returns a transformer that loads the MDES data in the specified VDR XML file.

Returns:

  • (#transform)

    a transformer that loads the MDES data in the specified VDR XML file.



11
12
13
# File 'lib/ncs_navigator/warehouse/transformers/vdr_xml.rb', line 11

def from_file(config, filename, options={}) # <- TODO better solution
  EnumTransformer.new(config, Reader.new(config, filename), options)
end

.from_most_recent_file(config, list, options = {}) ⇒ #transform

Returns a transformer for the most recently modified VDR XML file from the given list of files.

Parameters:

  • config (Configuration)

    the configuration for the warehouse.

  • list (String, Array<String>)

    the files to consider. This may be either a glob or an explicit list of files.

  • options (Hash<Symbol, Object>) (defaults to: {})

    options for the resulting transformer.

Returns:

  • (#transform)

    a transformer for the most recently modified VDR XML file from the given list of files.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ncs_navigator/warehouse/transformers/vdr_xml.rb', line 25

def from_most_recent_file(config, list, options={})
  files =
    if String === list
      Dir[list].tap { |a| fail "Glob #{list} does not match any files." if a.empty? }
    else
      list.tap { |a| fail "The file list is empty." if a.empty? }
    end

  from_file(
    config,
    files.collect { |fn| [fn, File.stat(fn).mtime] }.
      sort_by { |fn, mtime| mtime }.reverse.first.first,
    options)
end