class JekyllMetrics::Config
Hold the configuration needed for {JekyllMetrics::Hook} to work
Constants
- CONFIG_NAME
- DEFAULT_CONFIG
- DEFAULT_TEMPLATE_PATH
Attributes
site[RW]
Public Class Methods
instance(site)
click to toggle source
# File lib/jekyll-metrics/config.rb, line 15 def instance(site) @instance ||= Config.new(site) end
new(site)
click to toggle source
# File lib/jekyll-metrics/config.rb, line 22 def initialize(site) @site = site end
Public Instance Methods
plugin_vars()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 30 def plugin_vars @plugin_vars ||= DEFAULT_CONFIG.merge(plugin_config) end
template_path()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 26 def template_path @template_path ||= build_template_path end
Private Instance Methods
build_template_path()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 36 def build_template_path custom_path = plugin_config['template'] return default_template_path if custom_path.nil? if custom_path.match?(%r!^\/!) Pathname.new(custom_path) else site_root_path.join(custom_path) end end
default_template_path()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 48 def default_template_path plugin_root_path.join(DEFAULT_TEMPLATE_PATH) end
plugin_config()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 62 def plugin_config @plugin_config ||= site_config[CONFIG_NAME].to_h.transform_keys(&:to_s) end
plugin_root_path()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 52 def plugin_root_path Pathname.new(File.expand_path('../..', __dir__)) end
site_config()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 66 def site_config site.config end
site_root_path()
click to toggle source
# File lib/jekyll-metrics/config.rb, line 56 def site_root_path raise ConfigurationError, 'Couldn\'t access site.source' unless site.source Pathname.new(site.source) end