lib/hyla/configuration.rb in hyla-1.0.7.pre.7 vs lib/hyla/configuration.rb in hyla-1.0.7.pre.8

- old
+ new

@@ -1,11 +1,11 @@ module Hyla class Configuration < Hash attr_reader :HEADER, :INDEX_SUFFIX, :HEADER_INDEX, :INCLUDE_PREFIX, :INCLUDE_SUFFIX, :LEVEL_1, :LEVEL_2, :SKIP_CHARACTERS, :ADOC_EXT, :PREFIX_ARTEFACT, :YAML_CONFIG_FILE_NAME, :DEFAULTS, - :templates, :cover_template, :samples, :resources, :styles, :fonts, :backends, :assets + :templates, :configs, :cover_template, :samples, :resources, :styles, :fonts, :backends, :assets DEFAULTS = { 'source' => Dir.pwd, 'destination' => File.join(Dir.pwd, 'generated_content'), 'watch_dir' => '.', @@ -47,22 +47,10 @@ INDEX_FILE = 'AllSlides.txt' SNIPPET_TAG = 'snippet' - - # OLD HEADER_TXT used with hyla < 1.0.7 - # HEADER_TXT = ":data-uri:\n" + - # ":icons: font\n" + - # ":last-update-label!:\n" + - # ":source-highlighter: coderay\n" - # - # HEADER_TXT = "ifndef::local[]\n" + - # ":imagesdir: ../image/\n" + - # "endif::[]\n" - - HEADER_TXT = "// Asciidoctor attributes\n" LEVEL_1 = '= ' LEVEL_2 = '== ' @@ -90,10 +78,17 @@ def self.covers File.expand_path(COVERS, File.dirname(__FILE__)) end # + # Config Location + # + def self.configs + File.expand_path(CONFIGS, File.dirname(__FILE__)) + end + + # # Templates Location # def self.templates File.expand_path(TEMPLATES, File.dirname(__FILE__)) end @@ -159,15 +154,15 @@ extracted_email_attributes = self.extract_attributes(override[:email_attributes]) if override[:email_attributes] override[:email_attributes] = extracted_email_attributes if extracted_email_attributes # Stringify keys of the hash that we receive from Hyla override = Configuration[override].stringify_keys - Hyla::logger.debug("OVERRIDE Keys: #{override.inspect}") + Hyla::logger2.debug("OVERRIDE Keys: #{override.inspect}") # Clone DEFAULTS config = DEFAULTS - Hyla::logger.debug("DEFAULTS Keys: #{config.inspect}") + Hyla::logger2.debug("DEFAULTS Keys: #{config.inspect}") # # Read the config file passed as parameter if it exists # otherwise read default _config.yaml file if it exists and # merge content with DEFAULT config @@ -175,32 +170,31 @@ alt_config = read_config_file(override['config']) if override['config'] if !alt_config.nil? config = config.deep_merge(alt_config) else new_config = read_config_file(YAML_CONFIG_FILE_NAME) - Hyla::logger.debug("OVERRIDE Keys: #{new_config.inspect}") if !new_config.nil? + Hyla::logger2.debug("OVERRIDE Keys: #{new_config.inspect}") if !new_config.nil? config = config.deep_merge(new_config) if !new_config.nil? end # Merge DEFAULTS < _config.yaml or your_config.yaml file < override config = config.deep_merge(override) # Convert String Keys to Symbols Keys config = Configuration[].transform_keys_to_symbols(config) - Hyla::logger.debug("Merged Keys: #{config.inspect}") + Hyla::logger2.debug("Merged Keys: #{config.inspect}") return config end # # Read YAML Config file # def self.read_config_file(filename) f = File.expand_path(filename) - Hyla::logger.info("Config file to be parsed : #{f}") - config = safe_load_file(f) - config + Hyla::logger2.info("Config file to be parsed : #{f}") + safe_load_file(f) rescue SystemCallError - Hyla::logger.warn "No configuration file retrieved for the name : #{filename}" + Hyla::logger2.error "No configuration file retrieved for the name : #{filename}" end # # Load Safely YAML File # @@ -264,9 +258,11 @@ STYLES = '../../lib/resources/assets/styles' COVERS = '../../lib/resources/assets/cover' TEMPLATES = '../../lib/templates' + + CONFIGS = '../../lib/configs' RESOURCES = '../../lib/resources' SAMPLES = '../../lib/templates/sample' \ No newline at end of file