Class: Nanoc::RuleDSL::ActionProvider Private
- Inherits:
-
Core::ActionProvider
- Object
- Core::ActionProvider
- Nanoc::RuleDSL::ActionProvider
- Defined in:
- lib/nanoc/rule_dsl/action_provider.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #rules_collection ⇒ Object readonly private
Class Method Summary collapse
- .for(site) ⇒ Object private
Instance Method Summary collapse
- #action_sequence_for(obj) ⇒ Object private
-
#initialize(rules_collection, action_sequence_calculator) ⇒ ActionProvider
constructor
private
A new instance of ActionProvider.
- #need_preprocessing? ⇒ Boolean private
- #new_postprocessor_context(site, view_context) ⇒ Object private
- #new_preprocessor_context(site) ⇒ Object private
- #postprocess(site, compiler) ⇒ Object private
- #preprocess(site) ⇒ Object private
- #rep_names_for(item) ⇒ Object private
Constructor Details
#initialize(rules_collection, action_sequence_calculator) ⇒ ActionProvider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ActionProvider.
25 26 27 28 29 30 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 25 def initialize(rules_collection, action_sequence_calculator) super() @rules_collection = rules_collection @action_sequence_calculator = action_sequence_calculator end |
Instance Attribute Details
#rules_collection ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 8 def rules_collection @rules_collection end |
Class Method Details
.for(site) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 10 def self.for(site) rules_collection = Nanoc::RuleDSL::RulesCollection.new action_sequence_calculator = Nanoc::RuleDSL::ActionSequenceCalculator.new( rules_collection:, site:, ) action_provider = new(rules_collection, action_sequence_calculator) Nanoc::RuleDSL::RulesLoader.new(site.config, rules_collection).load action_provider end |
Instance Method Details
#action_sequence_for(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 39 def action_sequence_for(obj) @action_sequence_calculator[obj] end |
#need_preprocessing? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 43 def need_preprocessing? !@rules_collection.preprocessors.empty? end |
#new_postprocessor_context(site, view_context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 95 96 97 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 92 def new_postprocessor_context(site, view_context) Nanoc::Core::Context.new( config: Nanoc::Core::ConfigView.new(site.config, view_context), items: Nanoc::Core::PostCompileItemCollectionView.new(site.items, view_context), ) end |
#new_preprocessor_context(site) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 80 def new_preprocessor_context(site) view_context = Nanoc::Core::ViewContextForPreCompilation.new(items: site.items) Nanoc::Core::Context.new( config: Nanoc::Core::MutableConfigView.new(site.config, view_context), items: Nanoc::Core::MutableItemCollectionView.new(site.items, view_context), layouts: Nanoc::Core::MutableLayoutCollectionView.new(site.layouts, view_context), ) end |
#postprocess(site, compiler) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 58 def postprocess(site, compiler) dependency_tracker = Nanoc::Core::DependencyTracker::Null.new res = compiler.run_until_reps_built reps = res.fetch(:reps) view_context = Nanoc::Core::ViewContextForCompilation.new( reps:, items: site.items, dependency_tracker:, compilation_context: compiler.compilation_context(reps:), compiled_content_repo: Nanoc::Core::CompiledContentRepo.new, ) ctx = new_postprocessor_context(site, view_context) @rules_collection.postprocessors.each_value do |postprocessor| ctx.instance_eval(&postprocessor) end end |
#preprocess(site) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 47 def preprocess(site) ctx = new_preprocessor_context(site) @rules_collection.preprocessors.each_value do |preprocessor| ctx.instance_eval(&preprocessor) end site.data_source = Nanoc::Core::InMemoryDataSource.new(ctx.items._unwrap, ctx.layouts._unwrap, site.data_source) end |
#rep_names_for(item) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 |
# File 'lib/nanoc/rule_dsl/action_provider.rb', line 32 def rep_names_for(item) matching_rules = @rules_collection.item_compilation_rules_for(item) raise Nanoc::RuleDSL::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty? matching_rules.map(&:rep_name).uniq end |