Class: Hocho::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/hocho/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, driver: nil, check_ssh_port: false, base_dir: '.', initializers: [], driver_options: {}) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
10
11
12
13
14
# File 'lib/hocho/runner.rb', line 5

def initialize(host, driver: nil, check_ssh_port: false, base_dir: '.', initializers: [], driver_options: {})
  @host = host
  @driver = driver && driver.to_sym
  @check_ssh_port = check_ssh_port
  @base_dir = base_dir
  @initializers = initializers
  @driver_options = driver_options

  @bundler_support = nil
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



16
17
18
# File 'lib/hocho/runner.rb', line 16

def base_dir
  @base_dir
end

#driverObject (readonly)

Returns the value of attribute driver.



16
17
18
# File 'lib/hocho/runner.rb', line 16

def driver
  @driver
end

#hostObject (readonly)

Returns the value of attribute host.



16
17
18
# File 'lib/hocho/runner.rb', line 16

def host
  @host
end

#initializersObject (readonly)

Returns the value of attribute initializers.



16
17
18
# File 'lib/hocho/runner.rb', line 16

def initializers
  @initializers
end

Instance Method Details

#run(dry_run: false) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/hocho/runner.rb', line 18

def run(dry_run: false)
  puts "=> Running on #{host.name} using #{best_driver_name}"
  driver_options = @driver_options[best_driver_name] || {}
  driver = best_driver.new(host, base_dir: base_dir, initializers: initializers, **driver_options)
  driver.run(dry_run: dry_run)
ensure
  driver.finalize if driver
end

#sshObject

def check_ssh_port

return unless @check_ssh_port

end



31
32
33
# File 'lib/hocho/runner.rb', line 31

def ssh
  host.ssh_connection
end