class Slideoff::ConfigBuilder
Constants
- DEFAULT
- SECTION_DEFAULT
Public Class Methods
new(_dir)
click to toggle source
Calls superclass method
# File lib/slideoff/config_builder.rb, line 22 def initialize(_dir) config = DEFAULT.merge({pwd: _dir}) infos = extract_presentation_infos(_dir) || extract_showoff_presentation_infos(_dir) || {} unless infos.empty? infos['sections'] = infos['sections'].reduce({}) do |new_hash, (k, hash)| new_hash.merge!(k => SECTION_DEFAULT.merge(hash)) end Dir.chdir(_dir) do infos['css'] = Dir["**/*.css"].sort - Dir["#{DEFAULT["static_dir"]}/**/*.css"] infos['js'] = Dir["**/*.js"].sort - Dir["#{DEFAULT["static_dir"]}/**/*.js"] end ENV["FLICKR_API_KEY"] = infos['flickr_api_key'] end super(config.merge(infos)) end
Private Instance Methods
extract_presentation_infos(dir)
click to toggle source
# File lib/slideoff/config_builder.rb, line 42 def extract_presentation_infos(dir) parse_json_file(dir, "presentation") end
extract_showoff_presentation_infos(dir)
click to toggle source
backward compability for showoff
# File lib/slideoff/config_builder.rb, line 47 def extract_showoff_presentation_infos(dir) infos = parse_json_file(dir, "showoff") sections = infos["sections"].map {|s| s["section"] } { "title" => infos["name"], "theme" => "showoff", "sections" => sections } end
parse_json_file(dir, file)
click to toggle source
# File lib/slideoff/config_builder.rb, line 57 def parse_json_file(dir, file) filename = "#{dir}/#{file}.json" return {} unless File.exists?(filename) Yajl::Parser.parse(File.read filename) end