Class: Rubu::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/rubu.rb

Overview

Build activity.

Direct Known Subclasses

Build, Flow, RubyCommand, ShellCommand

Constant Summary collapse

@@host =
[]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAction

Returns a new instance of Action.



63
64
65
66
67
68
69
# File 'lib/rubu.rb', line 63

def initialize
    @status = :success
    @errmsg = nil
    @output = nil

    @subs = []
end

Instance Attribute Details

#errmsgObject (readonly)

Storage for error message.



55
56
57
# File 'lib/rubu.rb', line 55

def errmsg
  @errmsg
end

#outputObject (readonly)

Command output.



58
59
60
# File 'lib/rubu.rb', line 58

def output
  @output
end

#statusObject (readonly)

Status after execution.



52
53
54
# File 'lib/rubu.rb', line 52

def status
  @status
end

#subsObject (readonly)

Sub actions.



61
62
63
# File 'lib/rubu.rb', line 61

def subs
  @subs
end

Instance Method Details

#display(msg) ⇒ Object

Display command output.



104
105
106
107
# File 'lib/rubu.rb', line 104

def display( msg )
    @output = msg
    STDOUT.puts @output
end

#error(msg) ⇒ Object

Report (and store) error.



98
99
100
101
# File 'lib/rubu.rb', line 98

def error( msg )
    @errmsg = msg
    STDERR.puts "Rubu Error: #{@errmsg}"
end

#hostObject

Current host.



93
94
95
# File 'lib/rubu.rb', line 93

def host
    @@host[-1]
end

#host_inObject

Push host.



83
84
85
# File 'lib/rubu.rb', line 83

def host_in
    @@host.push self
end

#host_outObject

Pop host.



88
89
90
# File 'lib/rubu.rb', line 88

def host_out
    @@host.pop
end

#pick(flow) ⇒ Object

Take flow into use.



78
79
80
# File 'lib/rubu.rb', line 78

def pick( flow )
    Flow[ flow ].use
end

#useObject

Register Action to host (upper level).



72
73
74
75
# File 'lib/rubu.rb', line 72

def use
    host.subs.push( self ) if host
    self
end