Class: Jekyll::FastReader::Configuration
- Inherits:
-
Object
- Object
- Jekyll::FastReader::Configuration
- Defined in:
- lib/jekyll/fast_reader/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ "enabled" => true, "collections" => ["posts"], "exclude_selectors" => %w[code pre script style kbd samp], "css_output_path" => "/assets/fast-reader.css", "js_output_path" => "/assets/fast-reader.js", "stop_words_extra" => [], "toggle" => false, "default_on" => true }.freeze
Instance Attribute Summary collapse
-
#baseurl ⇒ Object
readonly
Returns the value of attribute baseurl.
-
#css_output_path ⇒ Object
readonly
Returns the value of attribute css_output_path.
-
#default_on ⇒ Object
readonly
Returns the value of attribute default_on.
-
#exclude_selectors ⇒ Object
readonly
Returns the value of attribute exclude_selectors.
-
#js_output_path ⇒ Object
readonly
Returns the value of attribute js_output_path.
-
#stop_words_extra ⇒ Object
readonly
Returns the value of attribute stop_words_extra.
-
#toggle ⇒ Object
readonly
Returns the value of attribute toggle.
Class Method Summary collapse
Instance Method Summary collapse
- #collection_enabled?(label) ⇒ Boolean
- #enabled? ⇒ Boolean
-
#initialize(config, baseurl = "") ⇒ Configuration
constructor
A new instance of Configuration.
- #stop_words_for(label) ⇒ Object
Constructor Details
#initialize(config, baseurl = "") ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 22 def initialize(config, baseurl = "") merged = DEFAULTS.merge(config) @enabled = merged["enabled"] @collections_map = normalize_collections(merged["collections"]) @exclude_selectors = Array(merged["exclude_selectors"]) @css_output_path = merged["css_output_path"] @js_output_path = merged["js_output_path"] @stop_words_extra = Array(merged["stop_words_extra"]).map(&:to_s) @toggle = merged["toggle"] @default_on = merged["default_on"] @baseurl = baseurl freeze end |
Instance Attribute Details
#baseurl ⇒ Object (readonly)
Returns the value of attribute baseurl.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def baseurl @baseurl end |
#css_output_path ⇒ Object (readonly)
Returns the value of attribute css_output_path.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def css_output_path @css_output_path end |
#default_on ⇒ Object (readonly)
Returns the value of attribute default_on.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def default_on @default_on end |
#exclude_selectors ⇒ Object (readonly)
Returns the value of attribute exclude_selectors.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def exclude_selectors @exclude_selectors end |
#js_output_path ⇒ Object (readonly)
Returns the value of attribute js_output_path.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def js_output_path @js_output_path end |
#stop_words_extra ⇒ Object (readonly)
Returns the value of attribute stop_words_extra.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def stop_words_extra @stop_words_extra end |
#toggle ⇒ Object (readonly)
Returns the value of attribute toggle.
15 16 17 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 15 def toggle @toggle end |
Class Method Details
.from(site) ⇒ Object
18 19 20 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 18 def self.from(site) new(site.config["fast_reader"] || {}, site.config["baseurl"].to_s.chomp("/")) end |
Instance Method Details
#collection_enabled?(label) ⇒ Boolean
40 41 42 43 44 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 40 def collection_enabled?(label) return false unless @collections_map.key?(label) @collections_map[label] != false end |
#enabled? ⇒ Boolean
36 37 38 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 36 def enabled? @enabled end |
#stop_words_for(label) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/jekyll/fast_reader/configuration.rb', line 46 def stop_words_for(label) = @collections_map[label] return @stop_words_extra unless .is_a?(Hash) per_collection = Array(["stop_words_extra"]).map(&:to_s) per_collection + @stop_words_extra end |