Class: Pot::Actor

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

Instance Method Summary collapse

Constructor Details

#initialize(instance, options = {}) ⇒ Actor

Returns a new instance of Actor.



4
5
6
7
# File 'lib/pot/actor.rb', line 4

def initialize(instance, options = {})
  @transport = Pot::Transports::Ssh.new(instance)
  @sudo = !!options[:sudo]
end

Instance Method Details

#execute(commands) ⇒ Object



9
10
11
12
13
14
# File 'lib/pot/actor.rb', line 9

def execute(commands)
  commands.each do |command|
    command = "sudo #{command}" if @sudo
    @transport.execute(command)
  end
end

#install(installer) ⇒ Object



16
17
18
# File 'lib/pot/actor.rb', line 16

def install(installer)
  execute(installer.commands)
end

#teardownObject



29
30
31
# File 'lib/pot/actor.rb', line 29

def teardown
  @transport if @transport.respond_to?(:teardown)
end

#transfer(source, destination, recursive = true) ⇒ Object



25
26
27
# File 'lib/pot/actor.rb', line 25

def transfer(source, destination, recursive = true)
  @transport.transfer(source, destination, recursive)
end

#verify(verifier) ⇒ Object



20
21
22
23
# File 'lib/pot/actor.rb', line 20

def verify(verifier)
  command = verifier.commands.join(" && ")
  @transport.execute(command) == 0
end