Class: Tdc::YamlReaders::YamlReaderBase

Inherits:
Object
  • Object
show all
Defined in:
lib/tdc/yaml_readers/yaml_reader_base.rb

Overview

YAML source.

Direct Known Subclasses

YamlReader, YamlReaderWithExpansion

Instance Method Summary collapse

Constructor Details

#initialize(catalog_root_directory, path_elements) ⇒ YamlReaderBase

Returns a new instance of YamlReaderBase.



9
10
11
12
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 9

def initialize(catalog_root_directory, path_elements)
  @catalog_root_directory = catalog_root_directory
  @path_elements = path_elements
end

Instance Method Details

#applies?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 14

def applies?
  File.exist?(definitions_file)
end

#data_definitionsObject



18
19
20
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 18

def data_definitions
  definitions_source
end

#definitions_sourceObject



22
23
24
25
26
27
28
29
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 22

def definitions_source
  source_string.empty? ? [] : YAML.safe_load(source_string, permitted_classes: [Date])
rescue => e
  raise Tdc::FatalError, "    Unable to load YAML from \#{definitions_file}\n    Cause: \#{e.message}\"\n  MSG\nend\n"