Class: Spud::BuildTools::SpudBuild::RuleContext

Inherits:
Object
  • Object
show all
Defined in:
lib/build_tools/spud/rule_context.rb

Instance Method Summary collapse

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

#invoke(name, *args, **kwargs) ⇒ Object



57
58
59
# File 'lib/build_tools/spud/rule_context.rb', line 57

def invoke(name, *args, **kwargs)
  @spud.invoke(name, *args, **kwargs)
end

#sh(cmd) ⇒ Object

Raises:



16
17
18
19
20
21
# File 'lib/build_tools/spud/rule_context.rb', line 16

def sh(cmd)
  out = sh?(cmd)
  raise ShellError unless out.status.exitstatus.zero?

  out
end

#sh?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
# File 'lib/build_tools/spud/rule_context.rb', line 23

def sh?(cmd)
  puts cmd

  out = Spud::Shell.cmd(cmd)
  puts out unless out.empty?

  out
end

#shh(cmd) ⇒ Object

Raises:



32
33
34
35
36
37
# File 'lib/build_tools/spud/rule_context.rb', line 32

def shh(cmd)
  out = shh?(cmd)
  raise ShellError unless out.status.exitstatus.zero?

  out
end

#shh?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
# File 'lib/build_tools/spud/rule_context.rb', line 39

def shh?(cmd)
  out = Spud::Shell.cmd(cmd)
  puts out unless out.empty?

  out
end

#shhh(cmd) ⇒ Object

Raises:



46
47
48
49
50
51
# File 'lib/build_tools/spud/rule_context.rb', line 46

def shhh(cmd)
  out = shhh?(cmd)
  raise ShellError, out unless out.status.exitstatus.zero?

  out
end

#shhh?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/build_tools/spud/rule_context.rb', line 53

def shhh?(cmd)
  Spud::Shell.cmd(cmd)
end