Sha256: 9283045540e99fee9e28507df365f36e8fb5d2d181db57f1abee100b8cf14c1d
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
require "metanorma/acme/processor" require "metanorma/acme/version" require 'forwardable' require 'yaml' module Metanorma module Acme ORGANIZATION_NAME_SHORT = "Acme" ORGANIZATION_NAME_LONG = "Acme Corp." DOCUMENT_NAMESPACE = "https://metanorma.org/ns/acme" YAML_CONFIG_FILE = 'metanorma.yml' class Configuration CONFIG_ATTRS = %i[ organization_name_short organization_name_long document_namespace docid_template i18nyaml logo_path header htmlcoverpage htmlintropage htmlstylesheet published_stages stage_abbreviations scripts scripts_pdf standardstylesheet validate_rng_file wordcoverpage wordintropage wordstylesheet xml_root_tag ].freeze attr_accessor(*CONFIG_ATTRS) def initialize(*args) super # Try to set config values from yaml file in current directory set_default_values_from_yaml_file(YAML_CONFIG_FILE) if File.file?(YAML_CONFIG_FILE) self.organization_name_short ||= ORGANIZATION_NAME_SHORT self.organization_name_long ||= ORGANIZATION_NAME_LONG self.document_namespace ||= DOCUMENT_NAMESPACE end def set_default_values_from_yaml_file(config_file) default_config_options = YAML.load(File.read(config_file)) CONFIG_ATTRS.each do |attr_name| instance_variable_set("@#{attr_name}", default_config_options[attr_name.to_s]) end end end class << self extend Forwardable attr_accessor :configuration Configuration::CONFIG_ATTRS.each do |attr_name| def_delegator :@configuration, attr_name end def configure self.configuration ||= Configuration.new yield(configuration) end end configure {} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
metanorma-acme-1.4.3 | lib/metanorma/acme.rb |
metanorma-acme-1.4.2 | lib/metanorma/acme.rb |