rconf 0.5.1 → 0.5.3
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/.gitignore
ADDED
data/bin/rconf
CHANGED
@@ -20,7 +20,7 @@ module RightConf
|
|
20
20
|
|
21
21
|
def self.run
|
22
22
|
opts = Trollop::options do
|
23
|
-
version
|
23
|
+
version "rconf #{VERSION} (c) 2011 RightScale"
|
24
24
|
banner <<-EOS
|
25
25
|
#{DESCRIPTION}
|
26
26
|
|
@@ -33,6 +33,7 @@ where [options] are:
|
|
33
33
|
opt :configurators, 'Show available configurators'
|
34
34
|
opt :config, 'Set path to configuration file', :type => :string
|
35
35
|
opt :output, 'Output file (output to STDOUT by default)', :type => :string
|
36
|
+
opt :verbose, 'Print debug output'
|
36
37
|
end
|
37
38
|
if opts[:config].nil?
|
38
39
|
opts[:config] = Dir['./*.rc']
|
@@ -83,6 +84,7 @@ where [options] are:
|
|
83
84
|
end
|
84
85
|
ProgressReporter.report_to_stdout
|
85
86
|
ProgressReporter.report_to_file(options[:output]) if options[:output]
|
87
|
+
Command.set_verbose if options[:verbose]
|
86
88
|
begin
|
87
89
|
lang = Language.load(options[:config])
|
88
90
|
report_fatal("Validation of configuration file failed:\n -#{lang.validation_errors.join("\n -").map(&:red)}") unless lang.validation_errors.empty?
|
@@ -92,7 +94,7 @@ where [options] are:
|
|
92
94
|
raise if e.is_a?(SystemExit)
|
93
95
|
report_fatal("Execution failed with exception '#{e.message.red}'\n#{e.backtrace.join("\n").map(&:grey)}")
|
94
96
|
ensure
|
95
|
-
lang.configurators.each { |c| report("!!NOTE: #{c.post_note}") if c.post_note }
|
97
|
+
lang.configurators.each { |c| report("\n!!NOTE: #{c.post_note}\n".green) if c.post_note }
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
data/lib/rconf/command.rb
CHANGED
@@ -33,6 +33,11 @@ module RightConf
|
|
33
33
|
args = args[0..-2]
|
34
34
|
end
|
35
35
|
res = Platform.dispatch(command, *args) { :execute }
|
36
|
+
if @verbose
|
37
|
+
msg = (([command] + args).join(' ') + ' => ' +
|
38
|
+
res.status.to_s + ': ' + res.output).grey
|
39
|
+
report(msg)
|
40
|
+
end
|
36
41
|
if !res.success? && msg = opts[:abort_on_failure]
|
37
42
|
report_fatal("#{msg}: '#{command} #{args.join(' ')}' returned\n#{res.output}")
|
38
43
|
end
|
@@ -77,6 +82,14 @@ module RightConf
|
|
77
82
|
true
|
78
83
|
end
|
79
84
|
|
85
|
+
# Enable debug output
|
86
|
+
#
|
87
|
+
# === Return
|
88
|
+
# true:: Always return true
|
89
|
+
def set_verbose
|
90
|
+
@verbose = true
|
91
|
+
end
|
92
|
+
|
80
93
|
end
|
81
94
|
|
82
95
|
# Command results
|
@@ -35,7 +35,7 @@ module RightConf
|
|
35
35
|
res = Command.execute('bundle', '--version')
|
36
36
|
success = (res.output =~ /#{bundler_version}/)
|
37
37
|
report_result(success)
|
38
|
-
install_bundler
|
38
|
+
install_bundler unless success
|
39
39
|
report_check('Installing gems')
|
40
40
|
res = Command.execute('bundle', 'install', :abort_on_failure => 'Failed to install gems')
|
41
41
|
report_success
|
@@ -55,16 +55,14 @@ module RightConf
|
|
55
55
|
|
56
56
|
# Install bundler from gem in cache
|
57
57
|
#
|
58
|
-
# === Parameters
|
59
|
-
# exists(FalseClass|TrueClass):: Whether bundler is already installed
|
60
|
-
# (but is the wrong version)
|
61
|
-
#
|
62
58
|
# === Return
|
63
59
|
# true:: Always return true
|
64
60
|
#
|
65
61
|
# === Raise
|
66
62
|
# (Exception):: If bundler gem cannot be found or installed
|
67
|
-
def install_bundler
|
63
|
+
def install_bundler
|
64
|
+
res = Command.execute('bundle', '--version')
|
65
|
+
exists = res.success? && res.output !~ /exec: bundle: not found/
|
68
66
|
if exists
|
69
67
|
report_check('Uninstalling existing versions of bundler')
|
70
68
|
res = Command.execute('gem', 'uninstall', 'bundler', '-a', '-x',
|
@@ -56,19 +56,21 @@ module RightConf
|
|
56
56
|
check_rvmrc
|
57
57
|
Command.execute('rvm', ruby_version, 'exec', 'gem', 'install', 'rconf',
|
58
58
|
:abort_on_failure => "Failed to install rconf gem in #{ruby_version}")
|
59
|
-
post_note
|
59
|
+
post_note "Configuration required switching the active ruby\nPlease 'cd' into the project directory again to activate it"
|
60
60
|
else
|
61
61
|
report_fatal("Failed to use #{ruby_version}:\n#{out}")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
if gemset
|
65
65
|
report_check("Switching to gemset #{gemset}")
|
66
|
-
res = Command.execute('rvm', 'gemset', 'list')
|
66
|
+
res = Command.execute('rvm', ruby_version, 'gemset', 'list')
|
67
67
|
unless res.output =~ /^#{gemset}$/
|
68
|
-
|
68
|
+
report_check("Creating gemset #{gemset} for #{ruby_version}")
|
69
|
+
Command.execute('rvm', ruby_version, 'gemset', 'create', gemset,
|
69
70
|
:abort_on_failure => "Failed to create gemset '#{gemset}'")
|
71
|
+
report_success
|
70
72
|
end
|
71
|
-
Command.execute('rvm', 'gemset', 'use', gemset,
|
73
|
+
Command.execute('rvm', ruby_version, 'gemset', 'use', gemset,
|
72
74
|
:abort_on_failure => "Failed to switch to gemset '#{gemset}'")
|
73
75
|
report_success
|
74
76
|
end
|
@@ -113,7 +115,7 @@ module RightConf
|
|
113
115
|
end
|
114
116
|
Dir.chdir(File.join(rvm_src, "rvm-#{version}")) do
|
115
117
|
Command.execute('./install', :abort_on_failure => "Failed to install rvm #{version}")
|
116
|
-
|
118
|
+
setup_bashrc
|
117
119
|
end
|
118
120
|
report_success
|
119
121
|
end
|
@@ -169,7 +171,7 @@ module RightConf
|
|
169
171
|
content = rvm_bash_activation + "\n" + content
|
170
172
|
FileUtils.mv(bashrc_path, bashrc_path + '.old')
|
171
173
|
File.open(bashrc_path, 'w') { |f| f.puts content }
|
172
|
-
post_note 'rvm was installed, please reload your shell to activate it'
|
174
|
+
post_note 'rvm was installed, please reload your shell to activate it and re-run rconf'
|
173
175
|
end
|
174
176
|
else
|
175
177
|
report_error("Failed to update bashrc to activate rvm, no bashrc found")
|
@@ -28,6 +28,20 @@ module RightConf
|
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
+
# Format standard message
|
32
|
+
#
|
33
|
+
# === Parameters
|
34
|
+
# message(String):: Message
|
35
|
+
#
|
36
|
+
# === Return
|
37
|
+
# text(String):: Formatted text
|
38
|
+
def format_message(msg)
|
39
|
+
text = @in_check ? "\n" : ''
|
40
|
+
text += super(msg).green
|
41
|
+
@in_check = false
|
42
|
+
text
|
43
|
+
end
|
44
|
+
|
31
45
|
# Format new progress report section
|
32
46
|
#
|
33
47
|
# === Parameters
|
@@ -36,6 +50,7 @@ module RightConf
|
|
36
50
|
# === Return
|
37
51
|
# text(String):: Formatted text
|
38
52
|
def format_section(section)
|
53
|
+
@in_check = false
|
39
54
|
text = super(section).green
|
40
55
|
end
|
41
56
|
|
@@ -47,6 +62,7 @@ module RightConf
|
|
47
62
|
# === Return
|
48
63
|
# text(String):: Formatted text
|
49
64
|
def format_check(check)
|
65
|
+
@in_check = true
|
50
66
|
text = super(check)
|
51
67
|
end
|
52
68
|
|
@@ -55,6 +71,7 @@ module RightConf
|
|
55
71
|
# === Return
|
56
72
|
# text(String):: Formatted text
|
57
73
|
def format_success
|
74
|
+
@in_check = false
|
58
75
|
text = super.blue
|
59
76
|
end
|
60
77
|
|
@@ -63,6 +80,7 @@ module RightConf
|
|
63
80
|
# === Return
|
64
81
|
# text(String):: Formatted text
|
65
82
|
def format_failure
|
83
|
+
@in_check = false
|
66
84
|
text = super.red
|
67
85
|
end
|
68
86
|
|
data/lib/rconf/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.3
|
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-
|
13
|
+
date: 2011-03-05 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +53,7 @@ extensions: []
|
|
53
53
|
extra_rdoc_files: []
|
54
54
|
|
55
55
|
files:
|
56
|
+
- .gitignore
|
56
57
|
- README.rdoc
|
57
58
|
- Rakefile
|
58
59
|
- bin/rconf
|