Sha256: 27ee8bc61c2111ef4bb3b7e53afebf329c27fcb71ce6e1cd5bd992778069b774
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module Tdc module YamlReaders # # YAML source. # class YamlReaderBase def initialize(catalog_root_directory, path_elements) @catalog_root_directory = catalog_root_directory @path_elements = path_elements end def applies? File.exist?(definitions_file) end def data_definitions definitions_source end 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 concerning :HookMethods do def file_extension raise MissingOverrideError, "Implement the 'file_extension' method" end def source_string raise MissingOverrideError, "Implement the 'source_string' method" end end private 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tdc-1.0 | lib/tdc/yaml_readers/yaml_reader_base.rb |
tdc-0.6.2 | lib/tdc/yaml_readers/yaml_reader_base.rb |
tdc-0.6.1 | lib/tdc/yaml_readers/yaml_reader_base.rb |