Class: Perron::Configuration
- Inherits:
-
Object
- Object
- Perron::Configuration
show all
- Defined in:
- lib/perron/configuration.rb
Instance Attribute Summary collapse
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
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/perron/configuration.rb', line 13
def initialize
@config = ActiveSupport::OrderedOptions.new
@config.output = "output"
@config.output_server_strict = true
@config.mode = :standalone
@config.live_reload = false
@config.live_reload_watch_paths = %w[app/content app/views app/assets]
@config.live_reload_skip_paths = %w[app/assets/builds]
@config.exclude_from_public = %w[assets storage]
@config.excluded_assets = %w[action_cable actioncable actiontext activestorage rails-ujs trix turbo]
@config.allowed_extensions = %w[erb md]
@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.default_processors = []
@config.search_scope = []
@config.cache_data_sources = false
@config.sitemap = ActiveSupport::OrderedOptions.new
@config.sitemap.enabled = false
@config.sitemap.priority = 0.5
@config.sitemap.change_frequency = :monthly
@config.site_name = nil
@config.site_description = nil
@config.metadata = ActiveSupport::OrderedOptions.new
@config.metadata.title_separator = " — "
@config.before_build = nil
@config.after_build = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/perron/configuration.rb', line 98
def method_missing(method_name, ...)
if @config.respond_to?(method_name)
@config.send(method_name, ...)
else
super
end
end
|
Instance Attribute Details
#additional_routes ⇒ Object
69
70
71
|
# File 'lib/perron/configuration.rb', line 69
def additional_routes
@additional_routes || (mode.integrated? ? [] : %w[root_path])
end
|
Instance Method Details
#deploy ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/perron/configuration.rb', line 73
def deploy
@deploy ||= ActiveSupport::OrderedOptions.new.tap do |config|
def config.method_missing(method_name, *args, &block)
if method_name.to_s.end_with?("=")
super
else
self[method_name] ||= ActiveSupport::OrderedOptions.new
end
end
def config.respond_to_missing?(method_name, include_private = false)
!method_name.to_s.end_with?("=") || super
end
end
end
|
61
|
# File 'lib/perron/configuration.rb', line 61
def input = Rails.root.join("app", "content")
|
#mode ⇒ Object
67
|
# File 'lib/perron/configuration.rb', line 67
def mode = @config.mode.to_s.inquiry
|
#output ⇒ Object
63
64
65
|
# File 'lib/perron/configuration.rb', line 63
def output
mode.integrated? ? "public" : @config.output
end
|
#respond_to_missing?(method_name) ⇒ Boolean
106
107
108
|
# File 'lib/perron/configuration.rb', line 106
def respond_to_missing?(method_name, ...)
@config.respond_to?(method_name, ...) || super
end
|
#url ⇒ Object
91
92
93
94
95
96
|
# File 'lib/perron/configuration.rb', line 91
def url
options = Perron.configuration.default_url_options
path = options[:trailing_slash] ? "/" : ""
URI.join("#{options[:protocol]}://#{options[:host]}", path).to_s
end
|