Class: CodeSlide::ThemeManager
- Inherits:
-
Object
- Object
- CodeSlide::ThemeManager
- Defined in:
- lib/code_slide/theme_manager.rb
Class Attribute Summary collapse
-
.search_paths ⇒ Object
readonly
Returns the value of attribute search_paths.
Class Method Summary collapse
Class Attribute Details
.search_paths ⇒ Object (readonly)
Returns the value of attribute search_paths.
12 13 14 |
# File 'lib/code_slide/theme_manager.rb', line 12 def search_paths @search_paths end |
Class Method Details
._post_process(hash) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/code_slide/theme_manager.rb', line 29 def _post_process(hash) hash.each.with_object({}) do |(key, value), result| key = key.to_sym result[key] = _post_process_value(key, value) end end |
._post_process_value(key, value) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/code_slide/theme_manager.rb', line 36 def _post_process_value(key, value) if key == :styles value.map(&:to_sym) elsif value.is_a?(Hash) _post_process(value) else value end end |
.load_theme(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/code_slide/theme_manager.rb', line 14 def load_theme(name) @cached_themes[name] ||= begin file_name = "#{name}.yml" path = @search_paths. map { |s| File.join(s, file_name) }. find { |s| File.exist?(s) } if path.nil? raise ArgumentError, "couldn't find theme #{name.inspect}" end _post_process(YAML.load_file(path)) end end |