Class: Renogen::ExtractionStratagies::YamlFile::Reader
- Inherits:
-
Object
- Object
- Renogen::ExtractionStratagies::YamlFile::Reader
- Defined in:
- lib/renogen/extraction_stratagies/yaml_file/reader.rb
Overview
Reads the relevant yaml files
Instance Attribute Summary collapse
-
#directory_path ⇒ Object
Returns the value of attribute directory_path.
-
#legacy_version ⇒ Object
Returns the value of attribute legacy_version.
Instance Method Summary collapse
-
#each_yaml_file {|Hash| ... } ⇒ Object
Iterates thorugh each change file and yields the contents.
-
#initialize(directory_path, options = {}) ⇒ Reader
constructor
A new instance of Reader.
Constructor Details
#initialize(directory_path, options = {}) ⇒ Reader
Returns a new instance of Reader.
12 13 14 15 16 |
# File 'lib/renogen/extraction_stratagies/yaml_file/reader.rb', line 12 def initialize(directory_path, = {}) @legacy_version = ['legacy_version'] @directory_path = directory_path @directory_path ||= './change_log/' end |
Instance Attribute Details
#directory_path ⇒ Object
Returns the value of attribute directory_path.
10 11 12 |
# File 'lib/renogen/extraction_stratagies/yaml_file/reader.rb', line 10 def directory_path @directory_path end |
#legacy_version ⇒ Object
Returns the value of attribute legacy_version.
10 11 12 |
# File 'lib/renogen/extraction_stratagies/yaml_file/reader.rb', line 10 def legacy_version @legacy_version end |
Instance Method Details
#each_yaml_file {|Hash| ... } ⇒ Object
Iterates thorugh each change file and yields the contents.
an exception is thrown if the contents are blank or invalid
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/renogen/extraction_stratagies/yaml_file/reader.rb', line 23 def each_yaml_file path = '' change_directories.each_with_index do |file_path, i| path = file_path content = ::YAML.load_file(file_path) raise Exceptions::YamlFileBlank, file_path unless content yield content, i end rescue Psych::SyntaxError raise Exceptions::YamlFileInvalid, path end |