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 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', 'use', gemset,
65
- :abort_on_failure => "Failed to switch to gemset '#{gemset}'")
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
- res = Command.execute('curl', '-O', '-f',
102
- "http://rvm.beginrescueend.com/releases/rvm-#{version}.tar.gz",
103
- :abort_on_failure => "Failed to download rvm #{version}")
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
- res = Command.execute('./install', :abort_on_failure => "Failed to install rvm #{version}")
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
-
@@ -69,4 +69,4 @@ module RightConf
69
69
  end
70
70
 
71
71
  # Load all progress reporters
72
- Dir[File.join(File.dirname(__FILE__), 'progress_reporters', '*.rb')].each { |r| require r }
72
+ Dir[File.join(File.dirname(__FILE__), 'progress_reporters', '*.rb')].sort.each { |r| require r }
data/lib/rconf/version.rb CHANGED
@@ -13,7 +13,7 @@ module RightConf
13
13
 
14
14
  MAJOR = 0
15
15
  MINOR = 5
16
- BUILD = 0
16
+ BUILD = 1
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
data/lib/rconf.rb CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  BASE_DIR = File.join(File.dirname(__FILE__), 'rconf')
13
13
 
14
- require 'FileUtils'
14
+ require 'fileutils'
15
15
  require File.join(BASE_DIR, 'ruby_extensions')
16
16
  require File.join(BASE_DIR, 'progress_reporter')
17
17
  require File.join(BASE_DIR, 'command')
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rconf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
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-02 00:00:00 -08:00
13
+ date: 2011-03-04 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency