Class: Middleman::Sitemap::Extensions::Proxies
- Defined in:
- lib/middleman-core/sitemap/extensions/proxies.rb
Overview
Manages the list of proxy configurations and manipulates the sitemap to include new resources based on those configurations
Constant Summary
Constants included from Contracts
Instance Attribute Summary
Attributes inherited from Extension
Instance Method Summary collapse
- #after_configuration ⇒ Object
-
#create_anonymous_proxy(path, target, options = {})
Setup a proxy from a path to a target.
- #create_proxy(path, target, opts = {}) ⇒ Object
-
#initialize(app, config = {}, &block) ⇒ Proxies
constructor
A new instance of Proxies.
- #manipulate_resource_list(resources) ⇒ Object
-
#String
Setup a proxy from a path to a target.
Methods inherited from Extension
activated_extension, #add_exposed_to_context, #after_build, after_extension_activated, #after_extension_activated, #before_build, #before_configuration, clear_after_extension_callbacks, config, expose_to_application, expose_to_config, expose_to_template, helpers, option, #ready, resources
Methods included from Contracts
Constructor Details
#initialize(app, config = {}, &block) ⇒ Proxies
Returns a new instance of Proxies.
18 19 20 21 22 23 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 18 def initialize(app, config={}, &block) super @proxy_configs = Set.new @post_config = false end |
Instance Method Details
#after_configuration ⇒ Object
25 26 27 28 29 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 25 def after_configuration @post_config = true ::Middleman::CoreExtensions::Collections::StepContext.add_to_context(:proxy, &method(:create_anonymous_proxy)) end |
#create_anonymous_proxy(path, target, options = {})
This method returns an undefined value.
Setup a proxy from a path to a target
58 59 60 61 62 63 64 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 58 def create_anonymous_proxy(path, target, ={}) ProxyDescriptor.new( ::Middleman::Util.normalize_path(path), ::Middleman::Util.normalize_path(target), ) end |
#create_proxy(path, target, opts = {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 41 def create_proxy(path, target, opts={}) = opts.dup @app.ignore(target) if .delete(:ignore) @proxy_configs << create_anonymous_proxy(path, target, ) @app.sitemap.rebuild_resource_list!(:added_proxy) end |
#manipulate_resource_list(resources) ⇒ Object
69 70 71 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 69 def manipulate_resource_list(resources) resources + @proxy_configs.map { |c| c.to_resource(@app) } end |