Class: Indoctrinatr::Tools::ConfigurationExtractor

Inherits:
Object
  • Object
show all
Includes:
TemplatePackHelpers
Defined in:
lib/indoctrinatr/tools/configuration_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TemplatePackHelpers

#assets_path, #check_for_folder, #config_file_path, #latex_log_file_destination, #pack_documentation_dir_path, #pack_documentation_examples_dir_path, #pack_technical_documentation_file_path, #path_name, #pdf_with_default_values_file_path, #pdf_with_fieldname_values_file_path, #tex_file_path, #tex_with_default_values_file_path, #tex_with_fieldname_values_file_path

Constructor Details

#initialize(template_pack_name) ⇒ ConfigurationExtractor

Returns a new instance of ConfigurationExtractor.



10
11
12
# File 'lib/indoctrinatr/tools/configuration_extractor.rb', line 10

def initialize template_pack_name
  @template_pack_name = template_pack_name
end

Instance Attribute Details

#template_pack_nameObject (readonly)

Returns the value of attribute template_pack_name.



8
9
10
# File 'lib/indoctrinatr/tools/configuration_extractor.rb', line 8

def template_pack_name
  @template_pack_name
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/indoctrinatr/tools/configuration_extractor.rb', line 14

def call
  config_file = YAML.load_file config_file_path
  configuration = TemplatePackConfiguration.new
  configuration.template_asset_path = assets_path.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', []
  configuration
end