rconf 0.7.15 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/rconf +55 -24
- data/lib/rconf/configurators/ruby_configurator.rb +22 -14
- data/lib/rconf/version.rb +2 -2
- data/spec/configurators/ruby_configurator_spec.rb +1 -1
- metadata +2 -2
data/bin/rconf
CHANGED
@@ -35,12 +35,13 @@ where [options] are:
|
|
35
35
|
|
36
36
|
opt :configurators, 'Show available configurators'
|
37
37
|
opt :update, 'Update rconf to latest version'
|
38
|
+
opt :remove, 'Remove rconf from all gemsets'
|
38
39
|
opt :config, 'Set path to configuration file', :type => :string
|
39
40
|
opt :output, 'Output file (output to STDOUT by default)', :type => :string
|
40
41
|
opt :force, 'Run rconf even if configuration file has not changed'
|
41
42
|
opt :verbose, 'Print debug output'
|
42
43
|
end
|
43
|
-
if opts[:config].nil? && !opts[:configurators] && !opts[:update]
|
44
|
+
if opts[:config].nil? && !opts[:configurators] && !opts[:update] && !opts[:remove]
|
44
45
|
opts[:config] = Dir["./*#{CONFIG_EXTENSION}"]
|
45
46
|
if opts[:config].empty?
|
46
47
|
Trollop::die :config, "not used and could not find a '#{CONFIG_EXTENSION}' file in the working directory"
|
@@ -60,6 +61,8 @@ where [options] are:
|
|
60
61
|
new.list_configurators
|
61
62
|
elsif opts[:update]
|
62
63
|
new.update
|
64
|
+
elsif opts[:remove]
|
65
|
+
new.remove
|
63
66
|
else
|
64
67
|
new.configure(opts)
|
65
68
|
end
|
@@ -103,20 +106,21 @@ where [options] are:
|
|
103
106
|
report_fatal 'Failed to retrieve rconf gem information, check network connectivity' unless version
|
104
107
|
report_success
|
105
108
|
report('Latest rconf version is ' + version.blue)
|
106
|
-
|
107
|
-
rubies = rubies.split("\n")[3..-1]
|
108
|
-
update_rconf(rubies, version)
|
109
|
+
update_rconf(version)
|
109
110
|
end
|
110
111
|
|
111
|
-
#
|
112
|
+
# Calls given block with all combination of installed rubies/gemsets
|
112
113
|
#
|
113
|
-
# ===
|
114
|
-
#
|
115
|
-
#
|
114
|
+
# === Block
|
115
|
+
# Given block should take two arguments:
|
116
|
+
# ruby(String):: Ruby version
|
117
|
+
# gemset(String):: Gemset
|
116
118
|
#
|
117
119
|
# === Return
|
118
120
|
# true:: Always return true
|
119
|
-
def
|
121
|
+
def run_in_all_gemsets(&callback)
|
122
|
+
rubies = Command.execute('rvm', 'list').output
|
123
|
+
rubies = rubies.split("\n")[3..-1]
|
120
124
|
rubies.each do |ruby|
|
121
125
|
ruby =~ /(\s+| =>)([^ ]*)\s.*/
|
122
126
|
ruby = Regexp.last_match(2)
|
@@ -125,25 +129,52 @@ where [options] are:
|
|
125
129
|
gemsets = gemsets[i + 1..-1]
|
126
130
|
gemsets.each do |gs|
|
127
131
|
gs = gs.lstrip
|
128
|
-
|
129
|
-
rconf = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'list', 'rconf').output
|
130
|
-
if rconf =~ /rconf \(#{version}/
|
131
|
-
report_success
|
132
|
-
next
|
133
|
-
elsif rconf =~ /rconf/
|
134
|
-
report_failure
|
135
|
-
report_check("Updating rconf for #{ruby}@#{gs}")
|
136
|
-
res = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'install',
|
137
|
-
'rconf', '-v', version, '--no-ri', '--no-rdoc')
|
138
|
-
report_result(res.success?)
|
139
|
-
else
|
140
|
-
report('SKIPPED (no rconf)')
|
141
|
-
end
|
132
|
+
callback.call(ruby, gs)
|
142
133
|
end
|
143
134
|
end
|
144
135
|
end
|
145
136
|
|
146
|
-
|
137
|
+
# Update rconf for given rubies if required
|
138
|
+
#
|
139
|
+
# === Parameters
|
140
|
+
# version(String):: Latest version
|
141
|
+
#
|
142
|
+
# === Return
|
143
|
+
# true:: Always return true
|
144
|
+
def update_rconf(version)
|
145
|
+
run_in_all_gemsets do |ruby, gs|
|
146
|
+
report_check("Checking rconf for #{ruby}@#{gs}")
|
147
|
+
rconf = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'list', 'rconf').output
|
148
|
+
if rconf =~ /rconf \(#{version}/
|
149
|
+
report_success
|
150
|
+
elsif rconf =~ /^rconf /
|
151
|
+
report_failure
|
152
|
+
report_check("Updating rconf for #{ruby}@#{gs}")
|
153
|
+
res = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'install',
|
154
|
+
'rconf', '-v', version, '--no-ri', '--no-rdoc')
|
155
|
+
report_result(res.success?)
|
156
|
+
else
|
157
|
+
report('SKIPPED (no rconf)')
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Remove rconf from all rubies/gemsets
|
163
|
+
#
|
164
|
+
# === Return
|
165
|
+
# true:: Always return true
|
166
|
+
def remove
|
167
|
+
ProgressReporter.report_to_stdout
|
168
|
+
run_in_all_gemsets do |ruby, gs|
|
169
|
+
rconf = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'list', 'rconf').output
|
170
|
+
if rconf =~ /^rconf /
|
171
|
+
report_check("Removing rconf from #{ruby}@#{gs}")
|
172
|
+
res = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'uninstall', '-a', '-x', 'rconf')
|
173
|
+
report_result(res.success?)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
147
178
|
# Actually configure environment
|
148
179
|
#
|
149
180
|
# === Parameters
|
@@ -14,7 +14,10 @@ module RightConf
|
|
14
14
|
class RubyConfigurator
|
15
15
|
|
16
16
|
# RVM version used to install rubies
|
17
|
-
RVM_VERSION = '1.2
|
17
|
+
RVM_VERSION = '1.6.2'
|
18
|
+
|
19
|
+
# RVM releases URL
|
20
|
+
RVM_RELEASES_URL = 'https://rvm.beginrescueend.com/releases'
|
18
21
|
|
19
22
|
include Configurator
|
20
23
|
|
@@ -128,20 +131,25 @@ module RightConf
|
|
128
131
|
report_success
|
129
132
|
else
|
130
133
|
report_failure
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
134
|
+
if out =~ /rvm ([^\s]+)/
|
135
|
+
report_fatal "You have rvm #{Regexp.last_match[1]} installed which is not compatible with rconf.\n" +
|
136
|
+
"Please uninstall your version of rvm and re-run rconf which will install rvm #{RVM_VERSION}."
|
137
|
+
else
|
138
|
+
report_check("Installing rvm #{version}")
|
139
|
+
rvm_src = File.join(ENV['HOME'] || '/root', '.rvm/src')
|
140
|
+
FileUtils.mkdir_p(rvm_src)
|
141
|
+
Dir.chdir(rvm_src) do
|
142
|
+
Command.execute('curl', '-O', '-f',
|
143
|
+
"#{RVM_RELEASES_URL}/rvm-#{version}.tar.gz",
|
144
|
+
:abort_on_failure => "Failed to download rvm #{version}")
|
145
|
+
Command.execute('tar', 'zxf', "rvm-#{version}.tar.gz",
|
146
|
+
:abort_on_failure => "Failed to extract rvm tgz from #{File.join(Dir.getwd, 'rvm-' + version + '.tar.gz')}")
|
147
|
+
end
|
148
|
+
Dir.chdir(File.join(rvm_src, "rvm-#{version}")) do
|
149
|
+
Command.execute('./install', :abort_on_failure => "Failed to install rvm #{version}")
|
150
|
+
end
|
151
|
+
report_success
|
143
152
|
end
|
144
|
-
report_success
|
145
153
|
end
|
146
154
|
setup_bashrc
|
147
155
|
true
|
data/lib/rconf/version.rb
CHANGED
@@ -36,7 +36,7 @@ describe RightConf::RubyConfigurator do
|
|
36
36
|
rvm_tar = "rvm-#{RVM_VERSION}.tar.gz"
|
37
37
|
should_execute('rvm', '--version').once.and_return(success_result("rvm"))
|
38
38
|
should_execute('rvm', 'list').once.and_return(success_result("=> rvm #{RVM_VERSION}"))
|
39
|
-
should_execute('curl', '-O', '-f', "
|
39
|
+
should_execute('curl', '-O', '-f', "https://rvm.beginrescueend.com/releases/#{rvm_tar}",
|
40
40
|
{:abort_on_failure=>"Failed to download rvm #{RVM_VERSION}"}).once.and_return(success_result)
|
41
41
|
should_execute('tar', 'zxf', rvm_tar,
|
42
42
|
{:abort_on_failure=>"Failed to extract rvm tgz from #{File.expand_path(File.join(File.dirname(__FILE__), '..', '..', "rvm-#{RVM_VERSION}.tar.gz"))}"}).once.and_return(success_result)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.8.0
|
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-04-
|
13
|
+
date: 2011-04-14 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|