Class: Blower::Local
- Extended by:
- Forwardable
- Includes:
- MonitorMixin
- Defined in:
- lib/blower/local.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, proxy: nil) ⇒ Local
constructor
A new instance of Local.
-
#log ⇒ Object
private
Produce a Logger prefixed with the host name.
- #sh(command, as: nil, quiet: false) ⇒ Object
-
#to_s ⇒ Object
Represent the host as a string.
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/blower/local.rb', line 14 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/blower/local.rb', line 14 def name @name end |
Instance Method Details
#log ⇒ Object
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_s ⇒ Object
Represent the host as a string.
24 25 26 |
# File 'lib/blower/local.rb', line 24 def to_s @name end |