Class: Nanoc::RuleDSL::RulesLoader Private
- Inherits:
-
Object
- Object
- Nanoc::RuleDSL::RulesLoader
- Defined in:
- lib/nanoc/rule_dsl/rules_loader.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 Method Summary collapse
-
#initialize(config, rules_collection) ⇒ RulesLoader
constructor
private
A new instance of RulesLoader.
- #load ⇒ Object private
- #parse(rules_filename) ⇒ Object private
Constructor Details
#initialize(config, rules_collection) ⇒ RulesLoader
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 RulesLoader.
5 6 7 |
# File 'lib/nanoc/rule_dsl/rules_loader.rb', line 5 def initialize(config, rules_collection) @dsl = Nanoc::RuleDSL::CompilerDSL.new(rules_collection, config) end |
Instance Method Details
#load ⇒ 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.
9 10 11 12 13 14 15 16 |
# File 'lib/nanoc/rule_dsl/rules_loader.rb', line 9 def load # Find rules file rules_filenames = ['Rules', 'rules', 'Rules.rb', 'rules.rb'] rules_filename = rules_filenames.find { |f| File.file?(f) } raise Nanoc::RuleDSL::Errors::NoRulesFileFound.new if rules_filename.nil? parse(rules_filename) end |
#parse(rules_filename) ⇒ 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.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nanoc/rule_dsl/rules_loader.rb', line 18 def parse(rules_filename) rules_filename = File.absolute_path(rules_filename) # Get rule data data = File.read(rules_filename) old_rules_filename = @dsl.rules_filename @dsl.rules_filename = rules_filename @dsl.instance_eval(data, rules_filename) @dsl.rules_filename = old_rules_filename end |