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
- #google ⇒ Object
- #index_now ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #writer ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 |
# File 'lib/indexmap/configuration.rb', line 9 def initialize @format = :index @index_filename = "sitemap.xml" end |
Instance Attribute Details
#base_url ⇒ Object
14 15 16 |
# File 'lib/indexmap/configuration.rb', line 14 def base_url resolve(@base_url) end |
#entries ⇒ Object
18 19 20 |
# File 'lib/indexmap/configuration.rb', line 18 def entries Array(resolve(@entries)) end |
#format ⇒ Object
22 23 24 25 |
# File 'lib/indexmap/configuration.rb', line 22 def format value = resolve(@format) value.nil? ? :index : value.to_sym end |
#index_filename ⇒ Object
31 32 33 |
# File 'lib/indexmap/configuration.rb', line 31 def index_filename resolve(@index_filename) end |
#public_path ⇒ Object
39 40 41 42 43 44 |
# File 'lib/indexmap/configuration.rb', line 39 def public_path value = resolve(@public_path) return Pathname("public") if value.nil? Pathname(value) end |
#sections ⇒ Object
46 47 48 |
# File 'lib/indexmap/configuration.rb', line 46 def sections Array(resolve(@sections)) end |
Instance Method Details
#google ⇒ Object
27 28 29 |
# File 'lib/indexmap/configuration.rb', line 27 def google @google ||= GoogleConfiguration.new end |
#index_now ⇒ Object
35 36 37 |
# File 'lib/indexmap/configuration.rb', line 35 def index_now @index_now ||= IndexNowConfiguration.new end |
#writer ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/indexmap/configuration.rb', line 50 def writer raise ConfigurationError, "Indexmap base_url is not configured" if base_url.to_s.strip.empty? unless VALID_FORMATS.include?(format) raise ConfigurationError, "Indexmap format must be one of: #{VALID_FORMATS.join(", ")}" end if format == :single_file raise ConfigurationError, "Indexmap entries are not configured" if entries.empty? elsif sections.empty? raise ConfigurationError, "Indexmap sections are not configured" if sections.empty? end Writer.new( entries: entries, format: format, sections: sections, public_path: public_path, base_url: base_url, index_filename: index_filename ) end |