Class: Middleman::Sitemap::Extensions::MoveFile
- Defined in:
- lib/middleman-core/sitemap/extensions/move_file.rb
Overview
Manages the list of proxy configurations and manipulates the sitemap to include new resources based on those configurations
Defined Under Namespace
Classes: MoveFileDescriptor
Constant Summary
Constants included from Contracts
Instance Attribute Summary
Attributes inherited from Extension
Instance Method Summary collapse
- #after_configuration ⇒ Object
- #create_anonymous_move(from, to) ⇒ Object
- #create_move_file(from, to) ⇒ Object
-
#initialize(app, config = {}, &block) ⇒ MoveFile
constructor
A new instance of MoveFile.
- #manipulate_resource_list(resources) ⇒ Object
-
#String ⇒ MoveFileDescriptor
Setup a move from one path to another.
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) ⇒ MoveFile
Returns a new instance of MoveFile.
17 18 19 20 21 |
# File 'lib/middleman-core/sitemap/extensions/move_file.rb', line 17 def initialize(app, config={}, &block) super @move_configs = Set.new end |
Instance Method Details
#after_configuration ⇒ Object
23 24 25 |
# File 'lib/middleman-core/sitemap/extensions/move_file.rb', line 23 def after_configuration ::Middleman::CoreExtensions::Collections::StepContext.add_to_context(:move_file, &method(:create_move_file)) end |
#create_anonymous_move(from, to) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/middleman-core/sitemap/extensions/move_file.rb', line 42 def create_anonymous_move(from, to) MoveFileDescriptor.new( ::Middleman::Util.normalize_path(from), ::Middleman::Util.normalize_path(to) ) end |
#create_move_file(from, to) ⇒ Object
32 33 34 35 |
# File 'lib/middleman-core/sitemap/extensions/move_file.rb', line 32 def create_move_file(from, to) @move_configs << create_anonymous_move(from, to) @app.sitemap.rebuild_resource_list!(:added_move_file) end |
#manipulate_resource_list(resources) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/middleman-core/sitemap/extensions/move_file.rb', line 52 def manipulate_resource_list(resources) resources.each do |r| matches = @move_configs.select do |c| c.from == r.path || c.from == r.destination_path end if c = matches.last r.destination_path = c.to end end resources end |
#String ⇒ MoveFileDescriptor
Setup a move from one path to another
31 |
# File 'lib/middleman-core/sitemap/extensions/move_file.rb', line 31 Contract String, String => Any |