Class: Hocho::Drivers::Bundler
Instance Attribute Summary
Attributes inherited from Base
#base_dir, #host, #initializers
Instance Method Summary
collapse
Methods inherited from SshBase
#deploy, #finalize, #ssh
Methods inherited from Base
#finalize, #run_list
Constructor Details
#initialize(host, base_dir: '.', initializers: [], itamae_options: [], bundle_without: [], bundle_path: nil, deploy_options: {}) ⇒ Bundler
Returns a new instance of Bundler.
6
7
8
9
10
11
12
13
|
# File 'lib/hocho/drivers/bundler.rb', line 6
def initialize(host, base_dir: '.', initializers: [], itamae_options: [], bundle_without: [], bundle_path: nil, deploy_options: {})
super host, base_dir: base_dir, initializers: initializers
@itamae_options = itamae_options
@bundle_without = bundle_without
@bundle_path = bundle_path
@deploy_options = deploy_options
end
|
Instance Method Details
#bundle_install ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/hocho/drivers/bundler.rb', line 24
def bundle_install
bundle_path_env = @bundle_path ? "BUNDLE_PATH=#{@bundle_path.shellescape} " : nil
check_exitstatus, check_exitsignal = ssh_run("cd #{host_basedir.shellescape} && #{bundle_path_env}bundle check", error: false)
return if check_exitstatus == 0
prepare_sudo do |sh, sudovars, sudocmd|
bundle_install = [host.bundler_cmd, 'install']
bundle_install.push('--path', @bundle_path) if @bundle_path
bundle_install.push('--without', [*@bundle_without].join(?:)) if @bundle_without
puts "=> #{host.name} # #{bundle_install.shelljoin}"
ssh_run("bash") do |c|
set_ssh_output_hook(c)
c.send_data("cd #{host_basedir.shellescape}\n#{sudovars}\n#{sudocmd}#{bundle_install.shelljoin}\n")
c.eof!
end
end
end
|
#run(dry_run: false) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/hocho/drivers/bundler.rb', line 15
def run(dry_run: false)
ssh deploy(**@deploy_options) do
bundle_install
run_itamae(dry_run: dry_run)
end
end
|
#run_itamae(dry_run: false) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/hocho/drivers/bundler.rb', line 45
def run_itamae(dry_run: false)
with_host_node_json_file do
itamae_cmd = ['itamae', 'local', '-j', host_node_json_path, *@itamae_options]
itamae_cmd.push('--dry-run') if dry_run
itamae_cmd.push('--color') if $stdout.tty?
itamae_cmd.push(*run_list)
prepare_sudo do |sh, sudovars, sudocmd|
puts "=> #{host.name} # #{host.bundler_cmd} exec #{itamae_cmd.shelljoin}"
ssh_run("bash") do |c|
set_ssh_output_hook(c)
c.send_data("cd #{host_basedir.shellescape}\n#{sudovars}\n#{sudocmd}#{host.bundler_cmd} exec #{itamae_cmd.shelljoin}\n")
c.eof!
end
end
end
end
|