rconf 1.0.7 → 1.0.8
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/Rakefile +3 -3
- data/bin/rconf +2 -1
- data/lib/rconf/configurators/bundler_configurator.rb +2 -2
- data/lib/rconf/configurators/ruby_configurator.rb +30 -16
- data/lib/rconf/version.rb +1 -1
- data/spec/configurators/bundler_configurator_spec.rb +1 -1
- data/spec/configurators/ruby_configurator_spec.rb +3 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -24,6 +24,9 @@ rescue LoadError => e
|
|
24
24
|
require 'rake/rdoctask'
|
25
25
|
end
|
26
26
|
|
27
|
+
task :default => 'spec'
|
28
|
+
task :build => [ 'spec', 'gem' ]
|
29
|
+
|
27
30
|
# == Unit Tests == #
|
28
31
|
|
29
32
|
desc "Run unit tests"
|
@@ -65,6 +68,3 @@ Rake::RDocTask.new do |rd|
|
|
65
68
|
rd.rdoc_files.include 'README.rdoc', "lib/**/*.rb"
|
66
69
|
end
|
67
70
|
|
68
|
-
task :default => 'spec'
|
69
|
-
task :build => [ 'spec', 'gem' ]
|
70
|
-
|
data/bin/rconf
CHANGED
@@ -252,7 +252,8 @@ where [options] are:
|
|
252
252
|
raise if e.is_a?(SystemExit)
|
253
253
|
report_fatal("Execution failed with exception '#{e.message.red}'\n#{e.backtrace.join("\n")}")
|
254
254
|
ensure
|
255
|
-
|
255
|
+
note = '----['.bold.white + 'NOTE'.bold.green + ']----'.bold.white
|
256
|
+
lang.configurators.each { |c| report("\n#{note}\n#{c.post_note.green}") if c.post_note }
|
256
257
|
end
|
257
258
|
end
|
258
259
|
|
@@ -73,7 +73,7 @@ module RightConf
|
|
73
73
|
def check_bundler
|
74
74
|
report_check("Checking bundler #{version}")
|
75
75
|
res = Command.execute("bundle", "_#{version}_", '--version')
|
76
|
-
success = !!(res.output =~
|
76
|
+
success = !!(res.output =~ /^Bundler version #{version}$/)
|
77
77
|
report_result(success)
|
78
78
|
success
|
79
79
|
end
|
@@ -129,7 +129,7 @@ module RightConf
|
|
129
129
|
options << { :abort_on_failure => 'Failed to install gems' }
|
130
130
|
res = Command.execute('bundle', *options)
|
131
131
|
report_success
|
132
|
-
Command.execute('rbenv', 'rehash') # this is
|
132
|
+
Command.execute('rbenv', 'rehash') # this is optional; don't bother to report failures
|
133
133
|
true
|
134
134
|
end
|
135
135
|
end
|
@@ -22,6 +22,14 @@ module RightConf
|
|
22
22
|
|
23
23
|
setting 'version', 'Ruby version using rbenv notation (see "rbenv versions")', :required => true
|
24
24
|
|
25
|
+
# Message to display to the user when rbenv isn't in the path.
|
26
|
+
PATH_ADVICE = "You should add 'eval \"$(rbenv init -)\"' to your .bash_profile / .bashrc etc. " +
|
27
|
+
"so rbenv is properly initialized in new shells.\n\n" +
|
28
|
+
"If you are a bash user (e.g. Mac OS X), you can add the following to ~/.bash_profile:\n\n" +
|
29
|
+
" echo 'eval \"$(rbenv init -)\"' >> ~/.bash_profile\n\n" +
|
30
|
+
"You should also update your PATH environment variable with:\n\n" +
|
31
|
+
" echo 'export PATH=\"$HOME/.rbenv/shims:$PATH\" >> ~/.bash_profile'\n"
|
32
|
+
|
25
33
|
# Let configurator run, it is idempotent
|
26
34
|
#
|
27
35
|
# === Return
|
@@ -63,7 +71,7 @@ module RightConf
|
|
63
71
|
|
64
72
|
protected
|
65
73
|
|
66
|
-
# Make version compatible with RVM
|
74
|
+
# Make our version specifier compatible with RVM-style specifiers (override base class accessor)
|
67
75
|
def ruby_version
|
68
76
|
@ruby_version ||= version.start_with?('ruby-') ? version[5..-1] : version
|
69
77
|
end
|
@@ -73,33 +81,32 @@ module RightConf
|
|
73
81
|
# === Return
|
74
82
|
# true:: Always return true
|
75
83
|
def check_rbenv
|
84
|
+
rbenv_present = File.exist?(File.join(ENV['HOME'], '.rbenv', 'bin', 'rbenv'))
|
85
|
+
|
76
86
|
res = Command.execute('rbenv')
|
77
87
|
rbenv_in_path = res.success?
|
78
|
-
|
88
|
+
|
89
|
+
if rbenv_present && !rbenv_in_path
|
90
|
+
# Bail if rbenv isn't correctly initialized (we can't use it in this state)
|
91
|
+
post_note "rconf detected rbenv is installed in #{rbenv_path} but it is not in the PATH.\n" + PATH_ADVICE
|
92
|
+
aborting(true)
|
93
|
+
elsif rbenv_present && rbenv_in_path
|
94
|
+
# rbenv is installed and initialized; make sure we have a suitable version
|
79
95
|
res.output =~ /^rbenv ([0-9]+)\.([0-9]+)\.([0-9]+)$/
|
80
96
|
maj, min, build = [$1.to_i, $2.to_i, $3.to_i]
|
81
97
|
if maj == 0 && min < 4
|
82
|
-
report_fatal("rconf requires rbenv version 0.4.0 or greater, you have #{maj}.#{min}.#{build} installed,
|
98
|
+
report_fatal("rconf requires rbenv version 0.4.0 or greater, you have #{maj}.#{min}.#{build} installed, "+
|
99
|
+
"please upgrade (e.g. via 'brew upgrade rbenv') and try again")
|
83
100
|
end
|
84
|
-
return true
|
85
|
-
end
|
86
|
-
rbenv_present = File.exist?(File.join(ENV['HOME'], '.rbenv', 'bin', 'rbenv'))
|
87
|
-
update_msg = "You should add 'eval \"$(rbenv init -)\"' to your .bash_profile / .bashrc etc. " +
|
88
|
-
"so rbenv is properly initialized in new shells, the following assumes ~/.bash_profile is used (Mac OS X):\n\n" +
|
89
|
-
"echo 'eval \"$(rbenv init -)\"' >> ~/.bash_profile\n\n".blue +
|
90
|
-
"You should also update your PATH environment variable with:\n\n" +
|
91
|
-
"echo 'export PATH=\"$HOME/.rbenv/shims:$PATH\" >> ~/.bash_profile'\n".blue
|
92
|
-
if rbenv_present
|
93
|
-
post_note "rconf detected rbenv is installed in #{rbenv_path} but it is not in the PATH.\n" + update_msg
|
94
|
-
aborting(true)
|
95
|
-
return true
|
96
101
|
else
|
102
|
+
# No sign of rbenv; try to install it
|
97
103
|
opts = { :report => true, :post_install => update_msg }.merge(abort_option('Failed to install rbenv'))
|
98
104
|
PackageInstaller.install('rbenv', opts)
|
99
105
|
opts = { :report => true }.merge(abort_option('Failed to install ruby-build'))
|
100
106
|
PackageInstaller.install('ruby-build', opts)
|
101
|
-
true
|
102
107
|
end
|
108
|
+
|
109
|
+
true
|
103
110
|
end
|
104
111
|
|
105
112
|
# Check .ruby-version and its content
|
@@ -112,6 +119,13 @@ module RightConf
|
|
112
119
|
Platform.dispatch(ruby_version) { :install_ruby }
|
113
120
|
Command.execute('rbenv', 'local', ruby_version)
|
114
121
|
end
|
122
|
+
|
123
|
+
which = Command.execute('which', 'ruby').output.strip
|
124
|
+
if (which =~ %r(^(/usr)?/bin.*ruby$))
|
125
|
+
post_note "Your PATH is not setup correctly for rbenv; ('which ruby' => #{which}).\n" + PATH_ADVICE
|
126
|
+
aborting(true)
|
127
|
+
end
|
128
|
+
|
115
129
|
true
|
116
130
|
end
|
117
131
|
|
data/lib/rconf/version.rb
CHANGED
@@ -36,7 +36,7 @@ describe RightConf::BundlerConfigurator do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should succeed when bundler succeeds' do
|
39
|
-
should_execute('bundle', '_0_', '--version').once.and_return(success_result('0'))
|
39
|
+
should_execute('bundle', '_0_', '--version').once.and_return(success_result('Bundler version 0'))
|
40
40
|
should_execute('bundle', '_0_', 'check').once.and_return(success_result('dependencies are satisfied'))
|
41
41
|
@configurator.check_linux.should be_true
|
42
42
|
end
|
@@ -33,7 +33,9 @@ describe RightConf::RubyConfigurator do
|
|
33
33
|
context "with rbenv installed" do
|
34
34
|
before(:each) do
|
35
35
|
should_execute('rvm').once.and_return(failure_result)
|
36
|
+
flexmock(File).should_receive(:exist?).with(File.join(ENV['HOME'], '.rbenv', 'bin', 'rbenv')).and_return(true)
|
36
37
|
should_execute('rbenv', 'local', '42').and_return(success_result)
|
38
|
+
should_execute('which', 'ruby').and_return(success_result(File.join(ENV['HOME'], '.rbenv', 'shims', 'ruby')))
|
37
39
|
end
|
38
40
|
|
39
41
|
it 'should succeed' do
|
@@ -53,6 +55,7 @@ describe RightConf::RubyConfigurator do
|
|
53
55
|
should_execute('rvm').once.and_return(failure_result)
|
54
56
|
should_execute('rbenv').once.and_return(failure_result)
|
55
57
|
flexmock(File).should_receive(:exist?).with(File.join(ENV['HOME'], '.rbenv', 'bin', 'rbenv')).and_return(false)
|
58
|
+
should_execute('which', 'ruby').and_return(success_result(File.join(ENV['HOME'], '.rbenv', 'shims', 'ruby')))
|
56
59
|
end
|
57
60
|
|
58
61
|
it 'should install rbenv and ruby-build' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|