rconf 0.7.15 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
- rubies = Command.execute('rvm', 'list').output
107
- rubies = rubies.split("\n")[3..-1]
108
- update_rconf(rubies, version)
109
+ update_rconf(version)
109
110
  end
110
111
 
111
- # Update rconf for given rubies if required
112
+ # Calls given block with all combination of installed rubies/gemsets
112
113
  #
113
- # === Parameters
114
- # rubies(Array):: List of rubies as returned by 'rvm list'
115
- # version(String):: Latest version
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 update_rconf(rubies, version)
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
- report_check("Checking rconf for #{ruby}@#{gs}")
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.9'
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
- report_check("Installing rvm #{version}")
132
- rvm_src = File.join(ENV['HOME'] || '/root', '.rvm/src')
133
- FileUtils.mkdir_p(rvm_src)
134
- Dir.chdir(rvm_src) do
135
- Command.execute('curl', '-O', '-f',
136
- "http://rvm.beginrescueend.com/releases/rvm-#{version}.tar.gz",
137
- :abort_on_failure => "Failed to download rvm #{version}")
138
- Command.execute('tar', 'zxf', "rvm-#{version}.tar.gz",
139
- :abort_on_failure => "Failed to extract rvm tgz from #{File.join(Dir.getwd, 'rvm-' + version + '.tar.gz')}")
140
- end
141
- Dir.chdir(File.join(rvm_src, "rvm-#{version}")) do
142
- Command.execute('./install', :abort_on_failure => "Failed to install rvm #{version}")
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
@@ -12,8 +12,8 @@
12
12
  module RightConf
13
13
 
14
14
  MAJOR = 0
15
- MINOR = 7
16
- BUILD = 15
15
+ MINOR = 8
16
+ BUILD = 0
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
@@ -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', "http://rvm.beginrescueend.com/releases/#{rvm_tar}",
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.7.15
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-11 00:00:00 -07:00
13
+ date: 2011-04-14 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency