Class: Blower::Local

Inherits:
Object show all
Extended by:
Forwardable
Includes:
MonitorMixin
Defined in:
lib/blower/local.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, proxy: nil) ⇒ Local

Returns a new instance of Local.



18
19
20
21
# File 'lib/blower/local.rb', line 18

def initialize (name, proxy: nil)
  @name, @proxy = name, proxy
  @data = {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



14
15
16
# File 'lib/blower/local.rb', line 14

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/blower/local.rb', line 14

def name
  @name
end

Instance Method Details

#logObject

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.

Produce a Logger prefixed with the host name.



42
43
44
# File 'lib/blower/local.rb', line 42

def log
  @log ||= Logger.instance.with_prefix("on #{name}: ")
end

#sh(command, as: nil, quiet: false) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/blower/local.rb', line 28

def sh (command, as: nil, quiet: false)
  command = "#{@proxy} #{command.shellescape}" if @proxy
  result = IO.popen(command) do |io|
    io.read
  end
  if $?.success?
    result
  else
    raise "Command failed"
  end
end

#to_sObject

Represent the host as a string.



24
25
26
# File 'lib/blower/local.rb', line 24

def to_s
  @name
end