Class: Divvy::PackageRunner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, package) ⇒ PackageRunner

Returns a new instance of PackageRunner.



3
4
5
# File 'lib/divvy/package_runner.rb', line 3

def initialize(server, package)
  @server, @package = server, package
end

Instance Attribute Details

#packageObject (readonly)

Returns the value of attribute package.



7
8
9
# File 'lib/divvy/package_runner.rb', line 7

def package
  @package
end

#serverObject (readonly)

Returns the value of attribute server.



7
8
9
# File 'lib/divvy/package_runner.rb', line 7

def server
  @server
end

Instance Method Details

#processObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/divvy/package_runner.rb', line 17

def process
  puts "==> Processing #{package.name}"
  
  unless package.verifications.empty?
    begin
      process_verifications(true)
      puts " --> #{package.name} already installed package: #{server.host}"
      return
    rescue Divvy::VerificationFailed => e
      # Yaay package not installed yet
    end
  end
  
  self.instance_eval(&package.apply_block) unless package.apply_block.nil?
      
  process_verifications
end

#run(command, options = {}) ⇒ Object



9
10
11
# File 'lib/divvy/package_runner.rb', line 9

def run(command, options = {})
  server.remote_command(command, options)
end

#scp(source, destination, options = {}) ⇒ Object



13
14
15
# File 'lib/divvy/package_runner.rb', line 13

def scp(source, destination, options = {})
  server.scp(source, destination, options)
end