Class: Metanorma::Generic::Configuration
- Inherits:
-
Object
- Object
- Metanorma::Generic::Configuration
- Defined in:
- lib/metanorma/generic.rb
Constant Summary collapse
- CONFIG_ATTRS =
%i[ organization_name_short organization_name_long bibliography_titles document_namespace docid_template doctypes default_doctype i18nyaml logo_path logo_paths header htmlcoverpage htmlintropage htmlstylesheet html_bodyfont html_headerfont html_monospacefont metadata_extensions metanorma_name normref_titles published_stages default_stage stage_abbreviations scripts scripts_pdf standardstylesheet symbols_titles termsdefs_titles validate_rng_file webfont wordcoverpage wordintropage wordstylesheet word_bodyfont word_headerfont word_monospacefont xml_root_tag ].freeze
Class Attribute Summary collapse
-
._file ⇒ Object
Returns the value of attribute _file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Configuration
constructor
A new instance of Configuration.
- #set_default_values_from_yaml_file(config_file) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Configuration
Returns a new instance of Configuration.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/metanorma/generic.rb', line 64 def initialize(*args) super # Try to set config values from yaml file in current directory @yaml = File.join(File.dirname(self.class::_file || __FILE__), "..", "..", YAML_CONFIG_FILE) set_default_values_from_yaml_file(@yaml) if File.file?(@yaml) self.organization_name_short ||= ORGANIZATION_NAME_SHORT self.organization_name_long ||= ORGANIZATION_NAME_LONG self.document_namespace ||= DOCUMENT_NAMESPACE self.termsdefs_titles ||= ["Terms and definitions", "Terms, definitions, symbols and abbreviated terms", "Terms, definitions, symbols and abbreviations", "Terms, definitions and symbols", "Terms, definitions and abbreviations", "Terms, definitions and abbreviated terms"] self.symbols_titles ||= ["Symbols and abbreviated terms", "Symbols", "Abbreviated terms", "Abbreviations"] self.normref_titles ||= ["Normative references"] self.bibliography_titles ||= ["Bibliography"] end |
Class Attribute Details
._file ⇒ Object
Returns the value of attribute _file.
57 58 59 |
# File 'lib/metanorma/generic.rb', line 57 def _file @_file end |
Class Method Details
.inherited(k) ⇒ Object
60 61 62 |
# File 'lib/metanorma/generic.rb', line 60 def self.inherited( k ) k._file = caller_locations.first.absolute_path end |
Instance Method Details
#set_default_values_from_yaml_file(config_file) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/metanorma/generic.rb', line 83 def set_default_values_from_yaml_file(config_file) = YAML.load(File.read(config_file)) CONFIG_ATTRS.each do |attr_name| instance_variable_set("@#{attr_name}", [attr_name.to_s]) end end |