rconf 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rconf +2 -1
- data/lib/rconf/configurators/ruby_configurator.rb +49 -8
- data/lib/rconf/progress_reporter.rb +1 -1
- data/lib/rconf/version.rb +1 -1
- data/lib/rconf.rb +1 -1
- metadata +2 -2
data/bin/rconf
CHANGED
@@ -88,10 +88,11 @@ where [options] are:
|
|
88
88
|
report_fatal("Validation of configuration file failed:\n -#{lang.validation_errors.join("\n -").map(&:red)}") unless lang.validation_errors.empty?
|
89
89
|
Dir.chdir(File.dirname(options[:config])) { lang.configurators.each(&:run) }
|
90
90
|
report("Successfully configured #{File.basename(options[:config], '.rc').blue} for #{Platform.family.to_s.blue}")
|
91
|
-
lang.configurators.each { |c| report("NOTE: #{c.post_note}") if c.post_note }
|
92
91
|
rescue Exception => e
|
93
92
|
raise if e.is_a?(SystemExit)
|
94
93
|
report_fatal("Execution failed with exception '#{e.message.red}'\n#{e.backtrace.join("\n").map(&:grey)}")
|
94
|
+
ensure
|
95
|
+
lang.configurators.each { |c| report("!!NOTE: #{c.post_note}") if c.post_note }
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
@@ -54,6 +54,8 @@ module RightConf
|
|
54
54
|
when /^Using /
|
55
55
|
report_success
|
56
56
|
check_rvmrc
|
57
|
+
Command.execute('rvm', ruby_version, 'exec', 'gem', 'install', 'rconf',
|
58
|
+
:abort_on_failure => "Failed to install rconf gem in #{ruby_version}")
|
57
59
|
post_note 'Configuration required switching the active ruby, please "cd" into the project directory again to activate it'
|
58
60
|
else
|
59
61
|
report_fatal("Failed to use #{ruby_version}:\n#{out}")
|
@@ -61,8 +63,13 @@ module RightConf
|
|
61
63
|
end
|
62
64
|
if gemset
|
63
65
|
report_check("Switching to gemset #{gemset}")
|
64
|
-
res = Command.execute('rvm', 'gemset', '
|
65
|
-
|
66
|
+
res = Command.execute('rvm', 'gemset', 'list')
|
67
|
+
unless res.output =~ /^#{gemset}$/
|
68
|
+
Command.execute('rvm', 'gemset', 'create', gemset,
|
69
|
+
:abort_on_failure => "Failed to create gemset '#{gemset}'")
|
70
|
+
end
|
71
|
+
Command.execute('rvm', 'gemset', 'use', gemset,
|
72
|
+
:abort_on_failure => "Failed to switch to gemset '#{gemset}'")
|
66
73
|
report_success
|
67
74
|
end
|
68
75
|
Command.set_prefix("rvm #{ruby_version}@#{gemset} exec --")
|
@@ -98,13 +105,15 @@ module RightConf
|
|
98
105
|
rvm_src = File.join(ENV['HOME'] || '/root', '.rvm/src')
|
99
106
|
FileUtils.mkdir_p(rvm_src)
|
100
107
|
Dir.chdir(rvm_src) do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
Command.execute('tar', 'zxf', "rvm-#{version}.tar.gz"
|
108
|
+
Command.execute('curl', '-O', '-f',
|
109
|
+
"http://rvm.beginrescueend.com/releases/rvm-#{version}.tar.gz",
|
110
|
+
:abort_on_failure => "Failed to download rvm #{version}")
|
111
|
+
Command.execute('tar', 'zxf', "rvm-#{version}.tar.gz",
|
112
|
+
:abort_on_failure => "Failed to extract rvm tgz from #{File.join(Dir.getwd, 'rvm-' + version + '.tar.gz')}")
|
105
113
|
end
|
106
114
|
Dir.chdir(File.join(rvm_src, "rvm-#{version}")) do
|
107
|
-
|
115
|
+
Command.execute('./install', :abort_on_failure => "Failed to install rvm #{version}")
|
116
|
+
setup_bashrc
|
108
117
|
end
|
109
118
|
report_success
|
110
119
|
end
|
@@ -146,6 +155,38 @@ module RightConf
|
|
146
155
|
true
|
147
156
|
end
|
148
157
|
|
158
|
+
# Setup .bashrc for rvm support
|
159
|
+
#
|
160
|
+
# === Return
|
161
|
+
# true:: Always return true
|
162
|
+
def setup_bashrc
|
163
|
+
candidates = ['.bashrc', '.bash_profile']
|
164
|
+
candidates.map! { |c| File.join(ENV['HOME'], c) }
|
165
|
+
bashrc_path = candidates.detect { |c| File.exist?(c) }
|
166
|
+
if bashrc_path
|
167
|
+
content = IO.read(bashrc_path)
|
168
|
+
unless content.include?(rvm_bash_activation)
|
169
|
+
content = rvm_bash_activation + "\n" + content
|
170
|
+
FileUtils.mv(bashrc_path, bashrc_path + '.old')
|
171
|
+
File.open(bashrc_path, 'w') { |f| f.puts content }
|
172
|
+
post_note 'rvm was installed, please reload your shell to activate it'
|
173
|
+
end
|
174
|
+
else
|
175
|
+
report_error("Failed to update bashrc to activate rvm, no bashrc found")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# rvm bash activation code
|
180
|
+
#
|
181
|
+
# === Return
|
182
|
+
# code(String):: Code that needs to be added to bashrc to activate rvm
|
183
|
+
def rvm_bash_activation
|
184
|
+
code = <<EOS
|
185
|
+
if [[ -n "$PS1" ]]; then
|
186
|
+
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi
|
187
|
+
fi
|
188
|
+
EOS
|
189
|
+
end
|
190
|
+
|
149
191
|
end
|
150
192
|
end
|
151
|
-
|
data/lib/rconf/version.rb
CHANGED
data/lib/rconf.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Raphael Simon
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-04 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|