Class: Indexmap::Configuration
- Inherits:
-
Object
- Object
- Indexmap::Configuration
- Defined in:
- lib/indexmap/configuration.rb
Constant Summary collapse
- VALID_FORMATS =
%i[index single_file].freeze
Instance Attribute Summary collapse
- #base_url ⇒ Object
- #entries ⇒ Object
- #format ⇒ Object
- #index_filename ⇒ Object
- #public_path ⇒ Object
- #sections ⇒ Object
Instance Method Summary collapse
- #after_create(&block) ⇒ Object
- #google ⇒ Object
- #index_now ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #output(name) {|output| ... } ⇒ Object
- #output_for(name = :default) ⇒ Object
- #run_after_create_callbacks ⇒ Object
- #writer ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 |
# File 'lib/indexmap/configuration.rb', line 9 def initialize @format = :index @index_filename = "sitemap.xml" @after_create_callbacks = [] @outputs = {} end |
Instance Attribute Details
#base_url ⇒ Object
16 17 18 |
# File 'lib/indexmap/configuration.rb', line 16 def base_url resolve(@base_url) end |
#entries ⇒ Object
20 21 22 |
# File 'lib/indexmap/configuration.rb', line 20 def entries Array(resolve(@entries)) end |
#format ⇒ Object
24 25 26 27 |
# File 'lib/indexmap/configuration.rb', line 24 def format value = resolve(@format) value.nil? ? :index : value.to_sym end |
#index_filename ⇒ Object
33 34 35 |
# File 'lib/indexmap/configuration.rb', line 33 def index_filename resolve(@index_filename) end |
#public_path ⇒ Object
41 42 43 44 45 46 |
# File 'lib/indexmap/configuration.rb', line 41 def public_path value = resolve(@public_path) return Pathname("public") if value.nil? Pathname(value) end |
#sections ⇒ Object
48 49 50 |
# File 'lib/indexmap/configuration.rb', line 48 def sections Array(resolve(@sections)) end |
Instance Method Details
#after_create(&block) ⇒ Object
63 64 65 66 67 |
# File 'lib/indexmap/configuration.rb', line 63 def after_create(&block) raise ArgumentError, "after_create requires a block" unless block @after_create_callbacks << block end |
#google ⇒ Object
29 30 31 |
# File 'lib/indexmap/configuration.rb', line 29 def google @google ||= GoogleConfiguration.new end |
#index_now ⇒ Object
37 38 39 |
# File 'lib/indexmap/configuration.rb', line 37 def index_now @index_now ||= IndexNowConfiguration.new end |
#output(name) {|output| ... } ⇒ Object
52 53 54 55 56 |
# File 'lib/indexmap/configuration.rb', line 52 def output(name) output = output_for(name) yield(output) if block_given? output end |
#output_for(name = :default) ⇒ Object
58 59 60 61 |
# File 'lib/indexmap/configuration.rb', line 58 def output_for(name = :default) normalized_name = name.to_sym @outputs[normalized_name] ||= Output.new(configuration: self) end |
#run_after_create_callbacks ⇒ Object
69 70 71 |
# File 'lib/indexmap/configuration.rb', line 69 def run_after_create_callbacks @after_create_callbacks.each(&:call) end |
#writer ⇒ Object
73 74 75 |
# File 'lib/indexmap/configuration.rb', line 73 def writer output_for(:default).writer end |