class Tdc::YamlReaders::YamlReaderBase
YAML source.
Public Class Methods
new(catalog_root_directory, path_elements)
click to toggle source
# 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
Public Instance Methods
applies?()
click to toggle source
# File lib/tdc/yaml_readers/yaml_reader_base.rb, line 12 def applies? File.exist?(definitions_file) end
data_definitions()
click to toggle source
# File lib/tdc/yaml_readers/yaml_reader_base.rb, line 16 def data_definitions definitions_source end
definitions_source()
click to toggle source
# File lib/tdc/yaml_readers/yaml_reader_base.rb, line 20 def definitions_source source_string.empty? ? [] : YAML.load(source_string) # rubocop:disable Security/YAMLLoad rescue => e raise Tdc::FatalError, <<~MSG Unable to load YAML from #{definitions_file} Cause: #{e.message}" MSG end
file_extension()
click to toggle source
# File lib/tdc/yaml_readers/yaml_reader_base.rb, line 30 def file_extension raise MissingOverrideError, "Implement the 'file_extension' method" end
source_string()
click to toggle source
# File lib/tdc/yaml_readers/yaml_reader_base.rb, line 34 def source_string raise MissingOverrideError, "Implement the 'source_string' method" end
Private Instance Methods
definitions_file()
click to toggle source
# File lib/tdc/yaml_readers/yaml_reader_base.rb, line 41 def definitions_file @_definitions_file ||= begin fully_qualified_path_elements = [@catalog_root_directory].concat(@path_elements.map(&:to_s)) fully_qualified_path_elements.last.concat(file_extension) File.join(*fully_qualified_path_elements) end end