Class: Tdc::YamlReaders::YamlReaderBase
- Inherits:
-
Object
- Object
- Tdc::YamlReaders::YamlReaderBase
show all
- Defined in:
- lib/tdc/yaml_readers/yaml_reader_base.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(catalog_root_directory, path_elements) ⇒ YamlReaderBase
Returns a new instance of YamlReaderBase.
7
8
9
10
|
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 7
def initialize(catalog_root_directory, path_elements)
@catalog_root_directory = catalog_root_directory
@path_elements = path_elements
end
|
Instance Method Details
#applies? ⇒ Boolean
12
13
14
|
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 12
def applies?
File.exist?(definitions_file)
end
|
#data_definitions ⇒ Object
16
17
18
|
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 16
def data_definitions
definitions_source
end
|
#definitions_source ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/tdc/yaml_readers/yaml_reader_base.rb', line 20
def definitions_source
source_string.empty? ? [] : YAML.safe_load(source_string, permitted_classes: [Date])
rescue => e
raise Tdc::FatalError, <<~MSG
Unable to load YAML from #{definitions_file}
Cause: #{e.message}"
MSG
end
|