Class: Perron::Configuration
- Inherits:
-
Object
- Object
- Perron::Configuration
show all
- Defined in:
- lib/perron/configuration.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/perron/configuration.rb', line 13
def initialize
@config = ActiveSupport::OrderedOptions.new
@config.site_name = nil
@config.site_description = nil
@config.site_email = nil
@config.output = "output"
@config.mode = :standalone
@config.include_root = false
@config.allowed_extensions = %w[erb md]
@config.exclude_from_public = %w[assets storage]
@config.excluded_assets = %w[action_cable actioncable actiontext activestorage rails-ujs trix turbo]
@config.view_unpublished = Rails.env.development?
@config.default_url_options = {
host: ENV.fetch("PERRON_HOST", "localhost:3000"),
protocol: ENV.fetch("PERRON_PROTOCOL", "http"),
trailing_slash: ENV.fetch("PERRON_TRAILING_SLASH", "true") == "true"
}
@config.markdown_options = {}
@config.sitemap = ActiveSupport::OrderedOptions.new
@config.sitemap.enabled = false
@config.sitemap.priority = 0.5
@config.sitemap.change_frequency = :monthly
@config.metadata = ActiveSupport::OrderedOptions.new
@config.metadata.title_separator = " — "
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/perron/configuration.rb', line 67
def method_missing(method_name, ...)
if @config.respond_to?(method_name)
@config.send(method_name, ...)
else
super
end
end
|
Instance Method Details
#exclude_root? ⇒ Boolean
58
|
# File 'lib/perron/configuration.rb', line 58
def exclude_root? = !@config.include_root
|
50
|
# File 'lib/perron/configuration.rb', line 50
def input = Rails.root.join("app", "content")
|
#mode ⇒ Object
56
|
# File 'lib/perron/configuration.rb', line 56
def mode = @config.mode.to_s.inquiry
|
#output ⇒ Object
52
53
54
|
# File 'lib/perron/configuration.rb', line 52
def output
mode.integrated? ? "public" : @config.output
end
|
#respond_to_missing?(method_name) ⇒ Boolean
75
76
77
|
# File 'lib/perron/configuration.rb', line 75
def respond_to_missing?(method_name)
@config.respond_to?(method_name) || super
end
|
#url ⇒ Object
60
61
62
63
64
65
|
# File 'lib/perron/configuration.rb', line 60
def url
options = Perron.configuration.default_url_options
path = options[:trailing_slash] ? "/" : ""
URI.join("#{options[:protocol]}://#{options[:host]}", path).to_s
end
|