lib/hyla/configuration.rb in hyla-1.0.6 vs lib/hyla/configuration.rb in hyla-1.0.7.pre.1

- old
+ new

@@ -25,11 +25,10 @@ 'stylesheet' => 'asciidoctor.css', 'stylesdir' => 'styles' }, 'safe' => 'unsafe', 'header_footer' => true - } # # Matches an include preprocessor directive. # @@ -44,49 +43,39 @@ INCLUDE_SUFFIX = '[]' INDEX_SUFFIX = '_AllSlides.txt' + INDEX_FILE = 'AllSlides.txt' + SNIPPET_TAG = 'snippet' - HEADER = ":data-uri:\n" + - ":icons: font\n" + - ":last-update-label!:\n" + - ":source-highlighter: coderay\n" - HEADER_INDEX = ":data-uri:\n" + - ":navigation: # navigation attribute used for DeckJS Slideshow\n" + - ":menu: # navigation attribute used for DeckJS Slideshow\n" + - ":status: # navigation attribute used for DeckJS Slideshow\n" + - ":goto: # navigation attribute used for DeckJS Slideshow\n" + - ":notitle: \n" + - ":toc: left # Comment or uncomment this attribute if you don't need to display left part of the HTML page a table of content\n" + # 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 = '== ' SKIP_CHARACTERS = '>>' - ADOC_EXT = '.ad' + #ADOC_EXT = '.ad' + ADOC_EXT = '.adoc' PREFIX_ARTEFACT = 'asciidoc_' - TEMPLATES = '../../lib/templates' - - RESOURCES = '../../lib/resources' - - SAMPLES = '../../lib/templates/sample' - - STYLES = '../../lib/resources/styles' - - FONTS = '../../lib/resources/fonts' - - BACKENDS = '../../lib/resources/backends' - - COVER_TEMPLATE = '../../lib/resources/cover.slim' - YAML_CONFIG_FILE_NAME = '_config.yaml' # # Cover Slim Template # @@ -144,11 +133,10 @@ # list of option names and their defaults. # # Returns the final configuration Hash. def self.parse(override) - # Extract Asciidoctor attributes received from hyla command line '-a key=value,key=value' # Convert them to a Hash of attributes 'attributes' => { 'backend' => html5 ... } # Assign hash to override[:attributes] extracted_attributes = self.extract_attributes(override[:attributes]) if override[:attributes] override[:attributes] = extracted_attributes if extracted_attributes @@ -203,10 +191,25 @@ # def self.safe_load_file(filename) YAML.safe_load_file(filename) end + # + # Retrieve asciidoctor attributes + # Could be an Arrays of Strings key=value,key=value + # or + # Could be a Hash (DEFAULTS, CONFIG_File) + def self.extract_attributes(attributes) + result = attributes.split(',') + attributes = Hash.new + result.each do |entry| + words = entry.split('=') + attributes[words[0]] = words[1] + end + return attributes + end + # Public: Turn all keys into string # # Return a copy of the hash where all its keys are strings def stringify_keys reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) } @@ -237,22 +240,39 @@ result[new_key] = new_value result } end - # - # Retrieve asciidoctor attributes - # Could be an Arrays of Strings key=value,key=value - # or - # Could be a Hash (DEFAULTS, CONFIG_File) - def self.extract_attributes(attributes) - result = attributes.split(',') - attributes = Hash.new - result.each do |entry| - words = entry.split('=') - attributes[words[0]] = words[1] - end - return attributes - end + TEMPLATES = '../../lib/templates' + + RESOURCES = '../../lib/resources' + + SAMPLES = '../../lib/templates/sample' + + STYLES = '../../lib/resources/styles' + + FONTS = '../../lib/resources/fonts' + + BACKENDS = '../../lib/resources/backends' + + COVER_TEMPLATE = '../../lib/resources/cover.slim' + + ASSESSMENT_TXT = File.open(self.resources + '/course/assessment.txt','r').read + + LABS_TXT = File.open(self.resources + '/course/labinstructions.txt','r').read + + INDEX = File.open(self.resources + '/course/index.txt','r').read + + HEADER_INDEX = File.open(self.resources + '/course/header_index.txt','r').read + + FOOTER_TXT = File.open(self.resources + '/course/footer.txt','r').read + + COVER_TXT = File.open(self.resources + '/course/cover.txt','r').read + + OBJECTIVES_TXT = File.open(self.resources + '/course/objectives.txt','r').read + + SUMMARY_TXT = File.open(self.resources + '/course/summary.txt','r').read + + AUDIO_TXT = File.open(self.resources + '/course/audio.txt','r').read end # Class Configuration end # module Hyla \ No newline at end of file