rconf 0.8.3 → 0.8.4
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 +6 -4
- data/lib/rconf/command.rb +2 -2
- data/lib/rconf/configurator.rb +14 -6
- data/lib/rconf/configurators/build_configurator.rb +10 -0
- data/lib/rconf/configurators/bundler_configurator.rb +30 -14
- data/lib/rconf/configurators/cassandra_configurator.rb +38 -31
- data/lib/rconf/configurators/execute_configurator.rb +10 -0
- data/lib/rconf/configurators/git_repo_configurator.rb +23 -16
- data/lib/rconf/configurators/mercurial_configurator.rb +14 -12
- data/lib/rconf/configurators/packages_configurator.rb +10 -0
- data/lib/rconf/configurators/passenger_configurator.rb +33 -11
- data/lib/rconf/configurators/ruby_configurator.rb +10 -0
- data/lib/rconf/profile.rb +22 -4
- data/lib/rconf/ruby_extensions.rb +8 -9
- data/lib/rconf/version.rb +1 -1
- data/spec/configurator_spec.rb +9 -0
- data/spec/configurators/bundler_configurator_spec.rb +3 -3
- data/spec/configurators/git_repo_configurator_spec.rb +7 -6
- data/spec/profile_spec.rb +8 -2
- metadata +1 -1
data/bin/rconf
CHANGED
@@ -37,8 +37,9 @@ where [options] are:
|
|
37
37
|
opt :remove, 'Remove rconf from all gemsets'
|
38
38
|
opt :config, 'Set path to configuration file', :type => :string
|
39
39
|
opt :output, 'Output file (output to STDOUT by default)', :type => :string
|
40
|
-
opt :
|
41
|
-
opt :
|
40
|
+
opt :reconfigure, 'Bypass all checks and force configuration'
|
41
|
+
opt :force, 'Run rconf even if configuration file has not changed'
|
42
|
+
opt :verbose,'Print debug output'
|
42
43
|
end
|
43
44
|
if opts[:config].nil? && !opts[:configurators] && !opts[:update] && !opts[:remove]
|
44
45
|
opts[:config] = Dir["./*#{CONFIG_EXTENSION}"]
|
@@ -183,7 +184,8 @@ where [options] are:
|
|
183
184
|
# === Return
|
184
185
|
# true:: Always return true
|
185
186
|
def configure(options)
|
186
|
-
Profile.
|
187
|
+
Profile.force_check if options[:force]
|
188
|
+
Profile.force_reconfigure if options[:reconfigure]
|
187
189
|
ProgressReporter.report_to_stdout
|
188
190
|
ProgressReporter.report_to_file(options[:output]) if options[:output]
|
189
191
|
begin
|
@@ -207,7 +209,7 @@ where [options] are:
|
|
207
209
|
end
|
208
210
|
rescue Exception => e
|
209
211
|
raise if e.is_a?(SystemExit)
|
210
|
-
report_fatal("Execution failed with exception '#{e.message.red}'\n#{e.backtrace.join("\n")
|
212
|
+
report_fatal("Execution failed with exception '#{e.message.red}'\n#{e.backtrace.join("\n")}")
|
211
213
|
ensure
|
212
214
|
lang.configurators.each { |c| report("\n!!NOTE: #{c.post_note}\n".green) if c.post_note }
|
213
215
|
end
|
data/lib/rconf/command.rb
CHANGED
@@ -37,8 +37,8 @@ module RightConf
|
|
37
37
|
end
|
38
38
|
res = Platform.dispatch(command, *args) { :execute }
|
39
39
|
if @verbose
|
40
|
-
msg = (
|
41
|
-
res.status.to_s + ': ' + res.output
|
40
|
+
msg = ([command] + args).compact.join(' ') + ' => ' +
|
41
|
+
res.status.to_s + ': ' + res.output
|
42
42
|
report(msg)
|
43
43
|
end
|
44
44
|
if !res.success? && msg = opts[:abort_on_failure]
|
data/lib/rconf/configurator.rb
CHANGED
@@ -111,6 +111,15 @@ module RightConf
|
|
111
111
|
error
|
112
112
|
end
|
113
113
|
|
114
|
+
# Check system to determine whether configurator needs to run
|
115
|
+
#
|
116
|
+
# === Return
|
117
|
+
# true:: If configurator needs to run
|
118
|
+
# false:: Otherwise
|
119
|
+
def check
|
120
|
+
Platform.dispatch { :check }
|
121
|
+
end
|
122
|
+
|
114
123
|
# Run configurator for current platform
|
115
124
|
#
|
116
125
|
# === Parameters
|
@@ -119,15 +128,14 @@ module RightConf
|
|
119
128
|
# === Return
|
120
129
|
# true:: Always return true
|
121
130
|
def run(*args)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
131
|
+
key = "#{self.class.key}-#{@index}"
|
132
|
+
sha = Profile.configurator_signature(key)
|
133
|
+
sig = signature
|
134
|
+
if Profile.force_reconfigure? ||
|
135
|
+
(Profile.force_check? || sha != sig && (only_if.nil? || instance_eval(only_if))) && !check
|
127
136
|
Platform.dispatch(*args) { :run }
|
128
137
|
Profile.set_configurator_signature(key, sig)
|
129
138
|
end
|
130
|
-
end
|
131
139
|
true
|
132
140
|
end
|
133
141
|
|
@@ -29,6 +29,16 @@ module RightConf
|
|
29
29
|
|
30
30
|
validate_has_settings :path
|
31
31
|
|
32
|
+
# No way to check, return false
|
33
|
+
#
|
34
|
+
# === Return
|
35
|
+
# false:: Always return false
|
36
|
+
def check_linux
|
37
|
+
false
|
38
|
+
end
|
39
|
+
alias :check_darwin :check_linux
|
40
|
+
alias :check_windows :check_linux
|
41
|
+
|
32
42
|
# Run command line
|
33
43
|
#
|
34
44
|
# === Return
|
@@ -28,25 +28,41 @@ module RightConf
|
|
28
28
|
|
29
29
|
validate_has_settings :version
|
30
30
|
|
31
|
-
#
|
31
|
+
# Check whether bundler is already installed
|
32
32
|
#
|
33
33
|
# === Return
|
34
|
-
# true::
|
35
|
-
|
34
|
+
# true:: If bundler is already installed
|
35
|
+
# false:: Otherwise
|
36
|
+
def check_linux
|
36
37
|
report_check("Checking for bundler #{version}")
|
37
38
|
res = Command.execute_in_ruby('bundle', '--version')
|
38
39
|
success = (res.output =~ /#{version}/)
|
39
40
|
report_result(success)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
success
|
42
|
+
end
|
43
|
+
alias :check_darwin :check_linux
|
44
|
+
|
45
|
+
# Not implemented on windows
|
46
|
+
#
|
47
|
+
# === Raise
|
48
|
+
# (Exception):: Always raise
|
49
|
+
def check_windows
|
50
|
+
raise "Bundler is not supported on Windows!"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Install bundler if needed and run bundle install
|
54
|
+
#
|
55
|
+
# === Return
|
56
|
+
# true:: Always return true
|
57
|
+
def run_linux
|
58
|
+
install_bundler
|
59
|
+
report_check('Installing gems')
|
60
|
+
options = [ "_#{version}_", 'install' ]
|
61
|
+
options << "--without=#{exclusions.delete(' ')}" unless exclusions.nil?
|
62
|
+
options += [ '--path', bundle_path ] unless bundle_path.nil?
|
63
|
+
options << { :abort_on_failure => 'Failed to install gems' }
|
64
|
+
res = Command.execute_in_ruby('bundle', *options)
|
65
|
+
report_success
|
50
66
|
true
|
51
67
|
end
|
52
68
|
alias :run_darwin :run_linux
|
@@ -71,7 +87,7 @@ module RightConf
|
|
71
87
|
def install_bundler
|
72
88
|
res = Command.execute_in_ruby('bundle', '--version')
|
73
89
|
exists = res.success? && res.output !~ /exec: bundle: not found/
|
74
|
-
if exists
|
90
|
+
if exists && res.output !~ /#{version}/
|
75
91
|
report_check('Uninstalling existing versions of bundler')
|
76
92
|
Command.execute_in_ruby('gem', 'uninstall', 'bundler', '-a', '-x')
|
77
93
|
report_success
|
@@ -29,6 +29,27 @@ module RightConf
|
|
29
29
|
|
30
30
|
validate_has_settings :version
|
31
31
|
|
32
|
+
# Check whether Cassandra is installed
|
33
|
+
#
|
34
|
+
# === Return
|
35
|
+
# true:: If Cassandra is installed
|
36
|
+
# false:: Otherwise
|
37
|
+
def check_linux
|
38
|
+
report_check('Checking for Cassandra')
|
39
|
+
installed = Command.execute('cassandra', '-h').success?
|
40
|
+
report_result(installed)
|
41
|
+
installed
|
42
|
+
end
|
43
|
+
alias :check_darwin :check_linux
|
44
|
+
|
45
|
+
# Check on windows
|
46
|
+
#
|
47
|
+
# === Return
|
48
|
+
# true:: Always return true
|
49
|
+
def check_windows
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
32
53
|
# Install Linux Mercurial package
|
33
54
|
#
|
34
55
|
# === Return
|
@@ -36,26 +57,24 @@ module RightConf
|
|
36
57
|
def run_linux
|
37
58
|
install_path(default_install_path) if install_path.nil?
|
38
59
|
abort_on_failure(true) if abort_on_failure.nil?
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
Command.execute('tar', 'xvzf', File.basename(url), abort_option('Failed to untar Cassandra'))
|
51
|
-
end
|
52
|
-
bin_path = File.join(install_path, "apache-cassandra-#{version}", 'bin')
|
53
|
-
if EnvironmentUpdater.update("PATH=$PATH:#{bin_path}", ['PATH'])
|
54
|
-
post_note 'Cassandra was installed, please reload your shell to activate it and re-run rconf'
|
55
|
-
aborting(true)
|
56
|
-
end
|
57
|
-
report_success
|
60
|
+
report_check('Installing Cassandra')
|
61
|
+
url = SOURCE_BASE_URL.gsub('VERSION', version)
|
62
|
+
if File.exist?(install_path)
|
63
|
+
FileUtils.rm_rf("#{install_path}_old")
|
64
|
+
FileUtils.mv(install_path, "#{install_path}_old")
|
65
|
+
post_note "Had to move #{install_path} to #{install_path}_old"
|
66
|
+
end
|
67
|
+
FileUtils.mkdir_p(install_path)
|
68
|
+
Dir.chdir(install_path) do
|
69
|
+
Command.execute('curl', '-O', '-f', url, abort_option('Failed to download Cassandra')) unless File.exist?(File.join(install_path, File.basename(url)))
|
70
|
+
Command.execute('tar', 'xvzf', File.basename(url), abort_option('Failed to untar Cassandra'))
|
58
71
|
end
|
72
|
+
bin_path = File.join(install_path, "apache-cassandra-#{version}", 'bin')
|
73
|
+
if EnvironmentUpdater.update("PATH=$PATH:#{bin_path}", ['PATH'])
|
74
|
+
post_note 'Cassandra was installed, please reload your shell to activate it and re-run rconf'
|
75
|
+
aborting(true)
|
76
|
+
end
|
77
|
+
report_success
|
59
78
|
end
|
60
79
|
alias :run_darwin :run_linux
|
61
80
|
|
@@ -69,18 +88,6 @@ module RightConf
|
|
69
88
|
|
70
89
|
protected
|
71
90
|
|
72
|
-
# Check whether Cassandra is installed
|
73
|
-
#
|
74
|
-
# === Return
|
75
|
-
# true:: If Mercurial is installed
|
76
|
-
# false:: Otherwise
|
77
|
-
def cassandra_installed
|
78
|
-
report_check("Checking for Cassandra")
|
79
|
-
installed = Command.execute('cassandra', '-h').success?
|
80
|
-
report_result(installed)
|
81
|
-
installed
|
82
|
-
end
|
83
|
-
|
84
91
|
# Retrieve default install path
|
85
92
|
# Try /opt/cassandra and revert to ~/cassandra if not writable
|
86
93
|
#
|
@@ -26,6 +26,16 @@ module RightConf
|
|
26
26
|
|
27
27
|
validate_has_settings :command_line
|
28
28
|
|
29
|
+
# No way to check, return false
|
30
|
+
#
|
31
|
+
# === Return
|
32
|
+
# false:: Always return false
|
33
|
+
def check_linux
|
34
|
+
false
|
35
|
+
end
|
36
|
+
alias :check_darwin :check_linux
|
37
|
+
alias :check_windows :check_linux
|
38
|
+
|
29
39
|
# Run command line
|
30
40
|
#
|
31
41
|
# === Return
|
@@ -24,6 +24,17 @@ module RightConf
|
|
24
24
|
:tag => 'git tag or branch or sha that should be checked out ("master" by default)'
|
25
25
|
|
26
26
|
validate_has_settings :repo, :path
|
27
|
+
|
28
|
+
# Check whether repo was already cloned
|
29
|
+
#
|
30
|
+
# === Return
|
31
|
+
# true:: If repo was already cloned
|
32
|
+
# false:: Otherwise
|
33
|
+
def check_linux
|
34
|
+
File.exist?(path) && File.exist?(File.join(path, '.git'))
|
35
|
+
end
|
36
|
+
alias :check_darwin :check_linux
|
37
|
+
alias :check_windows :check_linux
|
27
38
|
|
28
39
|
# Clone git repo and run build commands if given
|
29
40
|
#
|
@@ -31,24 +42,20 @@ module RightConf
|
|
31
42
|
# true:: Always return true
|
32
43
|
def run_linux
|
33
44
|
if File.exist?(path)
|
34
|
-
|
35
|
-
|
36
|
-
post_note "Had to move #{path} to #{path}_old"
|
37
|
-
end
|
45
|
+
FileUtils.mv(path, "#{path}_old")
|
46
|
+
post_note "Had to move #{path} to #{path}_old"
|
38
47
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
:abort_on_failure => "Failed to checkout #{tag}")
|
49
|
-
end
|
50
|
-
report_success
|
48
|
+
report_check("Cloning #{repo} into #{path}")
|
49
|
+
Command.execute('git', 'clone', repo, path,
|
50
|
+
:abort_on_failure => "Failed to clone #{repo} into #{path}")
|
51
|
+
report_success
|
52
|
+
if tag
|
53
|
+
report_check("Checking out #{tag}")
|
54
|
+
Dir.chdir(path) do
|
55
|
+
Command.execute('git', 'checkout', tag,
|
56
|
+
:abort_on_failure => "Failed to checkout #{tag}")
|
51
57
|
end
|
58
|
+
report_success
|
52
59
|
end
|
53
60
|
true
|
54
61
|
end
|
@@ -24,6 +24,20 @@ module RightConf
|
|
24
24
|
|
25
25
|
settings :abort_on_failure => 'Whether to abort if Mercurial failed to install (false by default)'
|
26
26
|
|
27
|
+
# Check whether Mercurial is installed
|
28
|
+
#
|
29
|
+
# === Return
|
30
|
+
# true:: If Mercurial is installed
|
31
|
+
# false:: Otherwise
|
32
|
+
def check_linux
|
33
|
+
report_check("Checking for Mercurial")
|
34
|
+
installed = Command.execute('hg', '--version').success?
|
35
|
+
report_result(installed)
|
36
|
+
installed
|
37
|
+
end
|
38
|
+
alias :check_darwin :check_linux
|
39
|
+
alias :check_windows :check_linux
|
40
|
+
|
27
41
|
# Install Linux Mercurial package
|
28
42
|
#
|
29
43
|
# === Return
|
@@ -72,18 +86,6 @@ module RightConf
|
|
72
86
|
|
73
87
|
protected
|
74
88
|
|
75
|
-
# Check whether Mercurial is installed
|
76
|
-
#
|
77
|
-
# === Return
|
78
|
-
# true:: If Mercurial is installed
|
79
|
-
# false:: Otherwise
|
80
|
-
def mercurial_installed
|
81
|
-
report_check("Checking for Mercurial")
|
82
|
-
installed = Command.execute('hg', '--version').success?
|
83
|
-
report_result(installed)
|
84
|
-
installed
|
85
|
-
end
|
86
|
-
|
87
89
|
# Produce abort on failure option
|
88
90
|
#
|
89
91
|
# === Parameters
|
@@ -25,6 +25,16 @@ module RightConf
|
|
25
25
|
:darwin => 'Brew packages to be installed on Mac OS X (https://github.com/mxcl/homebrew)',
|
26
26
|
:abort_on_failure => 'Whether to abort if packages failed to install (false by default)'
|
27
27
|
|
28
|
+
# Let package manager check for idempotency, return false
|
29
|
+
#
|
30
|
+
# === Return
|
31
|
+
# false:: Always return false
|
32
|
+
def check_linux
|
33
|
+
false
|
34
|
+
end
|
35
|
+
alias :check_darwin :check_linux
|
36
|
+
alias :check_windows :check_linux
|
37
|
+
|
28
38
|
# Install packages on debian based oses
|
29
39
|
#
|
30
40
|
# === Return
|
@@ -15,7 +15,7 @@ module RightConf
|
|
15
15
|
|
16
16
|
class PassengerConfigurator
|
17
17
|
|
18
|
-
PASSENGER_GEM_VERSION = '
|
18
|
+
PASSENGER_GEM_VERSION = '3.0.2'
|
19
19
|
|
20
20
|
DEFAULT_NGINX_INSTALL = ['/opt/nginx', File.join(ENV['HOME'], 'nginx')]
|
21
21
|
|
@@ -33,22 +33,44 @@ module RightConf
|
|
33
33
|
:install_path => 'Path to nginx installation directory, uses /opt/nginx if it ' +
|
34
34
|
'is writable by the current user or ~/nginx otherwise by default'
|
35
35
|
|
36
|
-
#
|
36
|
+
# Check that passenger gem is installed and that passenger+nginx is installed
|
37
37
|
#
|
38
38
|
# === Return
|
39
|
-
# true::
|
40
|
-
|
39
|
+
# true:: If both are installed
|
40
|
+
# false:: Otherwise
|
41
|
+
def check_linux
|
41
42
|
set_defaults
|
42
43
|
report_check("Checking for passenger gem #{gem_version}")
|
43
44
|
res = Command.execute_in_ruby('gem', 'list', 'passenger')
|
44
45
|
success = (res.output =~ /^passenger \(#{gem_version}\)$/)
|
45
46
|
report_result(success)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
if success
|
48
|
+
report_check('Checking for passenger+nginx')
|
49
|
+
res = Command.execute('which', 'nginx').success?
|
50
|
+
res = File.exists?(File.join(install_path, 'sbin', 'nginx')) unless res
|
51
|
+
report_result(res)
|
52
|
+
success = res
|
53
|
+
end
|
54
|
+
success
|
55
|
+
end
|
56
|
+
alias :check_darwin :check_linux
|
57
|
+
|
58
|
+
# Not implemented on Windows
|
59
|
+
#
|
60
|
+
# === Raise
|
61
|
+
# (Exception):: Always raise
|
62
|
+
def check_windows
|
63
|
+
raise "Passenger is not supported on Windows!"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Install passenger gem in given ruby then run nginx install script
|
67
|
+
#
|
68
|
+
# === Return
|
69
|
+
# true:: Always return true
|
70
|
+
def run_linux
|
71
|
+
set_defaults
|
72
|
+
install_gem
|
73
|
+
install_passenger
|
52
74
|
true
|
53
75
|
end
|
54
76
|
alias :run_darwin :run_linux
|
@@ -175,7 +197,7 @@ module RightConf
|
|
175
197
|
# config(String):: Nginx config
|
176
198
|
def nginx_config
|
177
199
|
ruby_bin = Command.execute_in_ruby('which', 'ruby').output.chomp
|
178
|
-
res = Command.execute_in_ruby('ruby', '-e', "require 'rubygems';puts Gem.source_index.find_name('passenger').detect { |g| g.version.to_s == '#{
|
200
|
+
res = Command.execute_in_ruby('ruby', '-e', "require 'rubygems';puts Gem.source_index.find_name('passenger').detect { |g| g.version.to_s == '#{gem_version}' }.full_gem_path",
|
179
201
|
:abort_on_failure => 'Could not find passenger gem to build passenger_root')
|
180
202
|
passenger_root = res.output.chomp
|
181
203
|
report_fatal('Could not find passenger gem') if passenger_root.empty?
|
@@ -32,6 +32,16 @@ module RightConf
|
|
32
32
|
|
33
33
|
validate_has_settings :version, :rubygems
|
34
34
|
|
35
|
+
# Let configurator run, it is idempotent
|
36
|
+
#
|
37
|
+
# === Return
|
38
|
+
# false:: Always return false
|
39
|
+
def check_linux
|
40
|
+
false
|
41
|
+
end
|
42
|
+
alias :check_darwin :check_linux
|
43
|
+
alias :check_windows :check_linux
|
44
|
+
|
35
45
|
# Switch to ruby version defined in settings
|
36
46
|
# Use rvm and install it if needed
|
37
47
|
#
|
data/lib/rconf/profile.rb
CHANGED
@@ -76,8 +76,8 @@ module RightConf
|
|
76
76
|
#
|
77
77
|
# === Return
|
78
78
|
# true:: Always return true
|
79
|
-
def
|
80
|
-
@
|
79
|
+
def force_check
|
80
|
+
@force_check = true
|
81
81
|
reset
|
82
82
|
end
|
83
83
|
|
@@ -86,8 +86,26 @@ module RightConf
|
|
86
86
|
# === Return
|
87
87
|
# true:: If re-configuration should be forced
|
88
88
|
# false:: Otherwise
|
89
|
-
def
|
90
|
-
res = @
|
89
|
+
def force_check?
|
90
|
+
res = @force_check || false
|
91
|
+
end
|
92
|
+
|
93
|
+
# Bypass checks and always reconfigure
|
94
|
+
#
|
95
|
+
# === Return
|
96
|
+
# true:: Always return true
|
97
|
+
def force_reconfigure
|
98
|
+
@force_reconfigure = true
|
99
|
+
reset
|
100
|
+
end
|
101
|
+
|
102
|
+
# Should next configuration bypass checks?
|
103
|
+
#
|
104
|
+
# === Return
|
105
|
+
# true:: If re-configuration should bypass checks
|
106
|
+
# false:: Otherwise
|
107
|
+
def force_reconfigure?
|
108
|
+
res = @force_reconfigure || false
|
91
109
|
end
|
92
110
|
|
93
111
|
protected
|
@@ -38,15 +38,14 @@ end
|
|
38
38
|
# e.g.: puts "Hello".red
|
39
39
|
class String
|
40
40
|
def bold; colorize("\e[1m\e[29m"); end
|
41
|
-
def
|
42
|
-
def red; colorize("\e[
|
43
|
-
def
|
44
|
-
def
|
45
|
-
def
|
46
|
-
def
|
47
|
-
def
|
48
|
-
def
|
49
|
-
def pur; colorize("\e[1m\e[35m"); end
|
41
|
+
def black; colorize("\e[30m"); end
|
42
|
+
def red; colorize("\e[31m"); end
|
43
|
+
def green; colorize("\e[32m"); end
|
44
|
+
def yellow; colorize("\e[33m"); end
|
45
|
+
def blue; colorize("\e[34m"); end
|
46
|
+
def purple; colorize("\e[35m"); end
|
47
|
+
def cyan; colorize("\e[36m"); end
|
48
|
+
def white; colorize("\e[37m"); end
|
50
49
|
def colorize(color_code)
|
51
50
|
# Doesn't work with the Windows prompt...
|
52
51
|
(RightConf::Platform.windows? || !$stdout.isatty) ? to_s : "#{color_code}#{to_s}\e[0m"
|
data/lib/rconf/version.rb
CHANGED
data/spec/configurator_spec.rb
CHANGED
@@ -21,6 +21,9 @@ describe RightConf::Configurator do
|
|
21
21
|
def test_setter(value)
|
22
22
|
@custom_setting = value
|
23
23
|
end
|
24
|
+
def check_darwin; end
|
25
|
+
alias :check_linux :check_darwin
|
26
|
+
alias :check_windows :check_darwin
|
24
27
|
def run_darwin; end
|
25
28
|
alias :run_linux :run_darwin
|
26
29
|
alias :run_windows :run_darwin
|
@@ -55,6 +58,12 @@ describe RightConf::Configurator do
|
|
55
58
|
@configurator.custom_setting.should == 43
|
56
59
|
end
|
57
60
|
|
61
|
+
it 'should check' do
|
62
|
+
flexmock(@configurator).should_receive(:check).and_return(true).once
|
63
|
+
flexmock(RightConf::Platform.instance).should_receive(:dispatch).never
|
64
|
+
@configurator.run
|
65
|
+
end
|
66
|
+
|
58
67
|
it 'should validate' do
|
59
68
|
@configurator.validate.should =~ /^Required setting.*missing for configuration/
|
60
69
|
@configurator.instance_eval { required 42 }
|
@@ -28,11 +28,11 @@ describe RightConf::BundlerConfigurator do
|
|
28
28
|
|
29
29
|
it 'should succeed when bundler succeeds' do
|
30
30
|
should_execute_in_ruby('bundle', '--version').once.and_return(success_result('0'))
|
31
|
-
@configurator.
|
31
|
+
@configurator.check_linux.should be_true
|
32
32
|
end
|
33
33
|
|
34
|
-
it 'should install
|
35
|
-
should_execute_in_ruby('bundle', '--version').
|
34
|
+
it 'should install bundler if needed' do
|
35
|
+
should_execute_in_ruby('bundle', '--version').once.and_return(success_result('1'))
|
36
36
|
should_execute_in_ruby('bundle','_0_', 'install',
|
37
37
|
{:abort_on_failure=>"Failed to install gems"}).once.and_return(success_result)
|
38
38
|
should_execute_in_ruby('gem', 'uninstall', 'bundler', '-a', '-x').once.and_return(success_result)
|
@@ -19,14 +19,15 @@ describe RightConf::GitRepoConfigurator do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should clone' do
|
22
|
-
flexmock(File).should_receive(:exist?).with('./git').and_return(false)
|
22
|
+
flexmock(File).should_receive(:exist?).with('./git').twice.and_return(false)
|
23
23
|
should_execute('git', 'clone', 'git', './git', @abf).once
|
24
|
+
@configurator.check
|
24
25
|
@configurator.run_linux
|
25
26
|
end
|
26
27
|
|
27
28
|
it 'should checkout the right tag' do
|
28
|
-
flexmock(File).should_receive(:exist?).with('./git').and_return(false)
|
29
29
|
@configurator.instance_eval { tag('tag') }
|
30
|
+
flexmock(File).should_receive(:exist?).with('./git').once.and_return(false)
|
30
31
|
should_execute('git', 'clone', 'git', './git', @abf).once
|
31
32
|
flexmock(Dir).should_receive(:chdir).with('./git', Proc).and_yield
|
32
33
|
should_execute('git', 'checkout', 'tag', {:abort_on_failure=>"Failed to checkout tag"}).once
|
@@ -34,18 +35,18 @@ describe RightConf::GitRepoConfigurator do
|
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'should skip checkout if directory already exists and contains a .git subdirectory' do
|
37
|
-
flexmock(File).should_receive(:exist?).with('./git').
|
38
|
+
flexmock(File).should_receive(:exist?).with('./git').once.and_return(true)
|
38
39
|
flexmock(File).should_receive(:exist?).with('./git/.git').once.and_return(true)
|
39
|
-
|
40
|
-
@configurator.run_linux
|
40
|
+
@configurator.check.should be_true
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should move directory if already exists but not a git repo' do
|
44
44
|
flexmock(File).should_receive(:exist?).with('./git').once.ordered.and_return(true)
|
45
45
|
flexmock(File).should_receive(:exist?).with('./git/.git').once.ordered.and_return(false)
|
46
|
-
flexmock(File).should_receive(:exist?).with('./git').once.ordered.and_return(
|
46
|
+
flexmock(File).should_receive(:exist?).with('./git').once.ordered.and_return(true)
|
47
47
|
flexmock(FileUtils).should_receive(:mv).once
|
48
48
|
should_execute('git', 'clone', 'git', './git', @abf).once
|
49
|
+
@configurator.check
|
49
50
|
@configurator.run_linux
|
50
51
|
end
|
51
52
|
|
data/spec/profile_spec.rb
CHANGED
@@ -18,10 +18,16 @@ describe RightConf::Profile do
|
|
18
18
|
RightConf::Profile.set_configurator_signature(:test, '42')
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'should reset when forcing checks' do
|
22
|
+
flexmock(RightConf::Profile.instance).should_receive(:reset).once
|
23
|
+
RightConf::Profile.force_check
|
24
|
+
RightConf::Profile.force_check?.should be_true
|
25
|
+
end
|
26
|
+
|
21
27
|
it 'should reset when forcing re-configuration' do
|
22
28
|
flexmock(RightConf::Profile.instance).should_receive(:reset).once
|
23
|
-
RightConf::Profile.
|
24
|
-
RightConf::Profile.
|
29
|
+
RightConf::Profile.force_reconfigure
|
30
|
+
RightConf::Profile.force_reconfigure?.should be_true
|
25
31
|
end
|
26
32
|
|
27
33
|
end
|