Class: Spud::BuildTools::SpudBuild::Rule
- Defined in:
- lib/build_tools/spud/rule.rb
Instance Method Summary collapse
-
#initialize(spud, file_context, name, files, deps, block) ⇒ Rule
constructor
A new instance of Rule.
- #invoke(*args, **kwargs) ⇒ Object
Constructor Details
#initialize(spud, file_context, name, files, deps, block) ⇒ Rule
Returns a new instance of Rule.
9 10 11 12 13 14 15 16 |
# File 'lib/build_tools/spud/rule.rb', line 9 def initialize(spud, file_context, name, files, deps, block) @spud = spud @file_context = file_context @name = name @files = files @deps = deps @block = block end |
Instance Method Details
#invoke(*args, **kwargs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/build_tools/spud/rule.rb', line 18 def invoke(*args, **kwargs) raise Spud::Error, "'#{@name}' is up to date" if up_to_date? missing = required_params.length - args.length if missing > 0 names = required_params.map { |name| "'#{name}'" }.join(', ') arguments = missing > 1 ? 'arguments' : 'argument' raise Spud::Error, "invocation of '#{@name}' missing required #{arguments} #{names}" end unless key_params? RuleContext.new(@spud, @file_context).instance_exec(*args, &@block) return end begin RuleContext.new(@spud, @file_context).instance_exec(*args, **kwargs, &@block) rescue ArgumentError => e raise Spud::Error, "invocation of '#{@name}' with #{e.}" end end |