Module: Jekyll::Minibundle::Environment
- Defined in:
- lib/jekyll/minibundle/environment.rb
Class Method Summary collapse
- .development?(site) ⇒ Boolean
- .find_site_config(site, keys, type) ⇒ Object
- .minifier_command(site, type) ⇒ Object
- .traverse_keys(obj, keys) ⇒ Object
Class Method Details
.development?(site) ⇒ Boolean
9 10 11 12 |
# File 'lib/jekyll/minibundle/environment.rb', line 9 def development?(site) mode = ENV['JEKYLL_MINIBUNDLE_MODE'] || Environment.find_site_config(site, ['minibundle', 'mode'], String) mode == 'development' end |
.find_site_config(site, keys, type) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/jekyll/minibundle/environment.rb', line 14 def find_site_config(site, keys, type) value = traverse_keys(site.config, keys) if value && !value.is_a?(type) fail "Invalid site configuration for key #{keys.join('.')}; expecting type #{type}" end value end |
.minifier_command(site, type) ⇒ Object
4 5 6 7 |
# File 'lib/jekyll/minibundle/environment.rb', line 4 def minifier_command(site, type) type = type.to_s ENV["JEKYLL_MINIBUNDLE_CMD_#{type.upcase}"] || Environment.find_site_config(site, ['minibundle', 'minifier_commands', type], String) end |
.traverse_keys(obj, keys) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/jekyll/minibundle/environment.rb', line 22 def traverse_keys(obj, keys) value = obj keys.each do |key| return nil unless value value = value[key] end value end |