-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #758 from nanoc/extract-rule-dsl
Extract rule DSL
- Loading branch information
Showing
31 changed files
with
177 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Nanoc::Int | ||
# @private | ||
class ActionProvider | ||
def rep_names_for(_item) | ||
raise NotImplementedError | ||
end | ||
|
||
def memory_for(_rep) | ||
raise NotImplementedError | ||
end | ||
|
||
def snapshots_defs_for(_rep) | ||
raise NotImplementedError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Nanoc | ||
# @api private | ||
module RuleDSL | ||
autoload 'CompilerDSL', 'nanoc/rule_dsl/compiler_dsl' | ||
autoload 'ActionProvider', 'nanoc/rule_dsl/provider' | ||
autoload 'RecordingExecutor', 'nanoc/rule_dsl/recording_executor' | ||
autoload 'RuleContext', 'nanoc/rule_dsl/rule_context' | ||
autoload 'RuleMemoryCalculator', 'nanoc/rule_dsl/rule_memory_calculator' | ||
autoload 'Rule', 'nanoc/rule_dsl/rule' | ||
autoload 'RulesCollection', 'nanoc/rule_dsl/rules_collection' | ||
autoload 'RulesLoader', 'nanoc/rule_dsl/rules_loader' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Nanoc::RuleDSL | ||
class ActionProvider < Nanoc::Int::ActionProvider | ||
def initialize(rules_collection, rule_memory_calculator) | ||
@rules_collection = rules_collection | ||
@rule_memory_calculator = rule_memory_calculator | ||
end | ||
|
||
def rep_names_for(item) | ||
matching_rules = @rules_collection.item_compilation_rules_for(item) | ||
raise Nanoc::Int::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty? | ||
|
||
matching_rules.map(&:rep_name).uniq | ||
end | ||
|
||
def memory_for(rep) | ||
@rule_memory_calculator[rep] | ||
end | ||
|
||
def snapshots_defs_for(rep) | ||
@rule_memory_calculator.snapshots_defs_for(rep) | ||
end | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...nanoc/base/services/recording_executor.rb → lib/nanoc/rule_dsl/recording_executor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.