rconf 0.8.15 → 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
data/bin/rconf CHANGED
@@ -126,10 +126,14 @@ where [options] are:
126
126
  ruby = Regexp.last_match(2)
127
127
  gemsets = Command.execute('rvm', ruby, 'exec', 'rvm', 'gemset', 'list').output.split("\n")
128
128
  i = gemsets.index { |gs| gs =~ /^gemsets for #{ruby} / }
129
- gemsets = gemsets[i + 1..-1]
130
- gemsets.each do |gs|
131
- gs = gs.lstrip
132
- callback.call(ruby, gs)
129
+ if i
130
+ gemsets = gemsets[i + 1..-1]
131
+ gemsets.each do |gs|
132
+ gs = gs.lstrip
133
+ callback.call(ruby, gs)
134
+ end
135
+ else
136
+ report_fatal 'Failed to retrieve installed gemsets'
133
137
  end
134
138
  end
135
139
  end
@@ -232,7 +232,8 @@ module RightConf
232
232
  report_check('Setting up .rvmrc')
233
233
  begin
234
234
  File.open('.rvmrc', 'w') do |f|
235
- f.puts "rvm #{version}@#{gemset}"
235
+ f.puts "environment_id=\"#{version}@#{gemset}\""
236
+ f.puts RVM_HOOK
236
237
  f.puts "type -P rconf &>/dev/null && { rconf; }"
237
238
  f.puts "type -P rconf &>/dev/null || { echo 'rconf not installed, skipping (see .rvmrc)'; }"
238
239
  end
@@ -247,6 +248,33 @@ module RightConf
247
248
  true
248
249
  end
249
250
 
251
+ # rvm mojo for creating and enabling 'environments'
252
+ RVM_HOOK = <<-EOF
253
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
254
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
255
+ then
256
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
257
+
258
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
259
+ then
260
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
261
+ fi
262
+ else
263
+ # If the environment file has not yet been created, use the RVM CLI to select.
264
+ if ! rvm --create "$environment_id"
265
+ then
266
+ echo "Failed to create RVM environment '${environment_id}'."
267
+ return 1
268
+ fi
269
+ fi
270
+ if [[ $- == *i* ]] # check for interactive shells
271
+ then
272
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
273
+ else
274
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
275
+ fi
276
+ EOF
277
+
250
278
  # Setup .bashrc for rvm support
251
279
  #
252
280
  # === Return
@@ -13,7 +13,7 @@ module RightConf
13
13
 
14
14
  MAJOR = 0
15
15
  MINOR = 8
16
- BUILD = 15
16
+ BUILD = 16
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rconf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.8.15
5
+ version: 0.8.16
6
6
  platform: ruby
7
7
  authors:
8
8
  - Raphael Simon