Class: Indoctrinatr::Tools::ConfigurationExtractor
- Inherits:
-
Object
- Object
- Indoctrinatr::Tools::ConfigurationExtractor
- Defined in:
- lib/indoctrinatr/tools/configuration_extractor.rb
Instance Attribute Summary collapse
-
#template_pack_name ⇒ Object
readonly
Returns the value of attribute template_pack_name.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(template_pack_name) ⇒ ConfigurationExtractor
constructor
A new instance of ConfigurationExtractor.
Constructor Details
#initialize(template_pack_name) ⇒ ConfigurationExtractor
Returns a new instance of ConfigurationExtractor.
8 9 10 |
# File 'lib/indoctrinatr/tools/configuration_extractor.rb', line 8 def initialize(template_pack_name) @template_pack_name = template_pack_name end |
Instance Attribute Details
#template_pack_name ⇒ Object (readonly)
Returns the value of attribute template_pack_name.
6 7 8 |
# File 'lib/indoctrinatr/tools/configuration_extractor.rb', line 6 def template_pack_name @template_pack_name end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/indoctrinatr/tools/configuration_extractor.rb', line 12 def call config_file = YAML.load_file((Pathname.new(Dir.pwd).join template_pack_name).join('configuration.yaml')) TemplatePackConfiguration.new.tap do |configuration| configuration.template_asset_path = ((Pathname.new(Dir.pwd).join template_pack_name).join 'assets').to_s configuration.default_file_name = "#{template_pack_name}_with_default_values.pdf" configuration.output_file_name = config_file.fetch('output_file_name', "#{template_pack_name}_with_default_values.pdf") configuration.template_name = config_file.fetch 'template_name' configuration.textual_description = config_file.fetch('textual_description'), '' configuration.attributes_as_hashes_in_array = config_file.fetch 'fields', [] end end |