Class: Spud::BuildTools::SpudBuild::RuleContext
- Inherits:
-
Object
- Object
- Spud::BuildTools::SpudBuild::RuleContext
- Defined in:
- lib/build_tools/spud/rule_context.rb
Defined Under Namespace
Classes: ShOut
Instance Method Summary collapse
- #die(message = nil, code: 1) ⇒ Object
-
#initialize(spud, file_context) ⇒ RuleContext
constructor
A new instance of RuleContext.
- #invoke(rule_name, *args, **kwargs) ⇒ Object
- #sh(*args) ⇒ Object
- #sh?(*args) ⇒ Boolean
- #shh(*args) ⇒ Object
- #shh?(*args) ⇒ Boolean
- #shhh(*args) ⇒ Object
- #shhh?(*args) ⇒ Boolean
Constructor Details
#initialize(spud, file_context) ⇒ RuleContext
Returns a new instance of RuleContext.
8 9 10 11 12 13 14 |
# File 'lib/build_tools/spud/rule_context.rb', line 8 def initialize(spud, file_context) @spud = spud file_context.singleton_methods.each do |method_name| define_singleton_method(method_name, &file_context.method(method_name)) end end |
Instance Method Details
#die(message = nil, code: 1) ⇒ Object
56 57 58 59 |
# File 'lib/build_tools/spud/rule_context.rb', line 56 def die( = nil, code: 1) puts if raise Error, code end |
#invoke(rule_name, *args, **kwargs) ⇒ Object
52 53 54 |
# File 'lib/build_tools/spud/rule_context.rb', line 52 def invoke(rule_name, *args, **kwargs) @spud.invoke_rule(rule_name.to_s, *args, **kwargs) end |
#sh(*args) ⇒ Object
16 17 18 19 |
# File 'lib/build_tools/spud/rule_context.rb', line 16 def sh(*args) out = sh?(*args) raise ShellError unless out.status.exitstatus.zero? end |
#sh?(*args) ⇒ Boolean
21 22 23 24 25 26 27 28 29 |
# File 'lib/build_tools/spud/rule_context.rb', line 21 def sh?(*args) cmd = args.join(' ') puts cmd out = Spud::Shell.cmd(cmd) puts out out end |
#shh(*args) ⇒ Object
31 32 33 34 |
# File 'lib/build_tools/spud/rule_context.rb', line 31 def shh(*args) out = shh?(*args) raise ShellError unless out.status.exitstatus.zero? end |
#shh?(*args) ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/build_tools/spud/rule_context.rb', line 36 def shh?(*args) out = Spud::Shell.cmd(args.join(' ')) puts out out end |
#shhh(*args) ⇒ Object
43 44 45 46 |
# File 'lib/build_tools/spud/rule_context.rb', line 43 def shhh(*args) out = shhh?(*args) raise ShellError, out unless out.status.exitstatus.zero? end |
#shhh?(*args) ⇒ Boolean
48 49 50 |
# File 'lib/build_tools/spud/rule_context.rb', line 48 def shhh?(*args) Spud::Shell.cmd(args.join(' ')) end |