Class: Really::Drivers::DriverBase

Inherits:
Object
  • Object
show all
Defined in:
lib/really/drivers/driver_base.rb

Direct Known Subclasses

Local, SSH

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ DriverBase

Returns a new instance of DriverBase.



9
10
11
12
# File 'lib/really/drivers/driver_base.rb', line 9

def initialize(&block)
  @role_names = []
  instance_eval &block if block
end

Instance Attribute Details

#role_namesObject

Returns the value of attribute role_names.



7
8
9
# File 'lib/really/drivers/driver_base.rb', line 7

def role_names
  @role_names
end

Instance Method Details

#closeObject



45
46
47
# File 'lib/really/drivers/driver_base.rb', line 45

def close
  # Subclasses can override this to perform any necessary driver teardown.
end

#execute_task(task, options = {}) ⇒ Object

Internal public API



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/really/drivers/driver_base.rb', line 27

def execute_task(task, options = {})
  task.commands.each do |command|
    logger.debug "command:#{command}"

    if command.kind_of?(FileTransferCommand)
      transfer_file command.source_path, command.destination_path, command.options
    else
      execute_command command, command.options unless options[:test_run]
    end
  end
end

#openObject



39
40
41
42
43
# File 'lib/really/drivers/driver_base.rb', line 39

def open
  # Subclasses can override this to perform any driver initialization
  # that is not appropriate for its constructor (like connecting to
  # remote hosts, etc.).
end

#roles(*roles) ⇒ Object Also known as: role

Public API for use within via blocks in really.rb scripts



20
21
22
# File 'lib/really/drivers/driver_base.rb', line 20

def roles(*roles)
  @role_names += roles
end

#to_sObject



14
15
16
# File 'lib/really/drivers/driver_base.rb', line 14

def to_s
  "<#{self.class} roles:#{@role_names}>"
end