capistrano-rbenv 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -0
- data/lib/capistrano-rbenv/deploy.rb +50 -1
- data/lib/capistrano-rbenv/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -38,6 +38,9 @@ Following options are available to manage your rbenv.
|
|
38
38
|
* `:rbenv_ruby_dependencies` - dependency packages.
|
39
39
|
* `:rbenv_ruby_version` - the ruby version to install. install `1.9.3-p194` by default.
|
40
40
|
* `:rbenv_use_bundler` - controls whether installing bundler or not. `true` by default.
|
41
|
+
* `:rbenv_use_configure` - configure rbenv in your shell config or not. `true` by default. users who are using Chef/Puppet may prefer setting this value `false`.
|
42
|
+
* `:rbenv_configure_files` - list of shell configuration files to be configured for rbenv. by default, guessing from user's `$SHELL` and `$HOME`.
|
43
|
+
* `:rbenv_configure_basenames` - advanced option for `:rbenv_configure_files`. list of filename of your shell configuration files if you don't like the default value of `:rbenv_configure_files`.
|
41
44
|
|
42
45
|
## Contributing
|
43
46
|
|
@@ -89,8 +89,57 @@ module Capistrano
|
|
89
89
|
}
|
90
90
|
}
|
91
91
|
|
92
|
+
_cset(:rbenv_configure_home) { capture("echo $HOME").chomp }
|
93
|
+
_cset(:rbenv_configure_shell) { capture("echo $SHELL").chomp }
|
94
|
+
_cset(:rbenv_configure_files) {
|
95
|
+
if fetch(:rbenv_configure_basenames, nil)
|
96
|
+
[ rbenv_configure_basenames ].flatten.map { |basename|
|
97
|
+
File.join(rbenv_configure_home, basename)
|
98
|
+
}
|
99
|
+
else
|
100
|
+
case File.basename(rbenv_configure_shell)
|
101
|
+
when /bash/
|
102
|
+
[ File.join(rbenv_configure_home, '.bash_profile') ]
|
103
|
+
when /zsh/
|
104
|
+
[ File.join(rbenv_configure_home, '.zshenv') ]
|
105
|
+
else # other sh compatible shell such like dash
|
106
|
+
[ File.join(rbenv_configure_home, '.profile') ]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
}
|
110
|
+
_cset(:rbenv_configure_script) {
|
111
|
+
(<<-EOS).gsub(/^\s*/, '')
|
112
|
+
# Configured by capistrano-rbenv. Do not edit directly.
|
113
|
+
export PATH="#{rbenv_path}/bin:$PATH"
|
114
|
+
eval "$(rbenv init -)"
|
115
|
+
EOS
|
116
|
+
}
|
117
|
+
_cset(:rbenv_configure_signature, '##rbenv:configure')
|
92
118
|
task(:configure, :except => { :no_release => true }) {
|
93
|
-
|
119
|
+
if fetch(:rbenv_use_configure, true)
|
120
|
+
script = File.join('/tmp', "rbenv.#{$$}")
|
121
|
+
config = [ rbenv_configure_files ].flatten
|
122
|
+
config_map = Hash[ config.map { |f| [f, File.join('/tmp', "#{File.basename(f)}.#{$$}")] } ]
|
123
|
+
begin
|
124
|
+
execute = []
|
125
|
+
put(rbenv_configure_script, script)
|
126
|
+
config_map.each { |file, temp|
|
127
|
+
## (1) copy original config to temporaly file and then modify
|
128
|
+
execute << "( cp -fp #{file} #{temp} || touch #{temp} )"
|
129
|
+
execute << "sed -i -e '/^#{Regexp.escape(rbenv_configure_signature)}/,/^#{Regexp.escape(rbenv_configure_signature)}/d' #{temp}"
|
130
|
+
execute << "echo #{rbenv_configure_signature.dump} >> #{temp}"
|
131
|
+
execute << "cat #{script} >> #{temp}"
|
132
|
+
execute << "echo #{rbenv_configure_signature.dump} >> #{temp}"
|
133
|
+
## (2) update config only if it is needed
|
134
|
+
execute << "cp -fp #{file} #{file}.orig"
|
135
|
+
execute << "( diff -u #{file} #{temp} || mv -f #{temp} #{file} )"
|
136
|
+
}
|
137
|
+
run(execute.join(' && '))
|
138
|
+
ensure
|
139
|
+
remove = [ script ] + config_map.values
|
140
|
+
run("rm -f #{remove.join(' ')}") rescue nil
|
141
|
+
end
|
142
|
+
end
|
94
143
|
}
|
95
144
|
|
96
145
|
_cset(:rbenv_platform) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-rbenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|