rconf 0.6.15 → 0.6.16

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  tags
2
2
  pkg/*
3
3
  .rvmrc
4
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source :gemcutter
2
+
3
+ gem 'json', '> 1.1.6'
4
+
5
+ #Gems needed to execute the unit specs.
6
+ group :test do
7
+ gem 'rspec', '~> 2.5'
8
+ gem 'flexmock', '~> 0.9'
9
+ end
10
+
data/bin/rconf CHANGED
@@ -12,6 +12,7 @@
12
12
 
13
13
  $stdout.sync = true
14
14
 
15
+ require 'json'
15
16
  require File.join(File.dirname(__FILE__), '..', 'lib', 'rconf')
16
17
 
17
18
  module RightConf
@@ -33,6 +34,7 @@ where [options] are:
33
34
  EOS
34
35
 
35
36
  opt :configurators, 'Show available configurators'
37
+ opt :update, 'Update rconf to latest version'
36
38
  opt :config, 'Set path to configuration file', :type => :string
37
39
  opt :output, 'Output file (output to STDOUT by default)', :type => :string
38
40
  opt :force, 'Run rconf even if configuration file has not changed'
@@ -53,9 +55,85 @@ where [options] are:
53
55
  Trollop::die :output, "Failed to initialize output file: #{e.message}"
54
56
  end
55
57
  end
56
- new.configure(opts)
58
+ if opts[:configurators]
59
+ new.list_configurators
60
+ elsif opts[:update]
61
+ new.update
62
+ else
63
+ new.configure(opts)
64
+ end
65
+ end
66
+
67
+ # List all available configurators
68
+ #
69
+ # === Return
70
+ # true:: Always return true
71
+ def list_configurators
72
+ puts "The following configurators are registered:\n\n"
73
+ ConfiguratorRegistry.each do |key, configurator|
74
+ puts "== #{key} ==".bold
75
+ puts configurator.desc
76
+ puts 'Settings:'
77
+ max_size = configurator.all_settings.keys.map(&:to_s).map(&:size).max
78
+ configurator.all_settings.each do |name, desc|
79
+ num_spaces = max_size - name.to_s.size + 1
80
+ print " - #{name.to_s.blue}:#{' ' * num_spaces}#{desc}"
81
+ required_settings = configurator.required_settings || []
82
+ if required_settings.include?(name)
83
+ puts ' [required]'.green
84
+ else
85
+ puts
86
+ end
87
+ end
88
+ puts
89
+ end
90
+ end
91
+
92
+ # Update rconf to latest in all installed rubies
93
+ #
94
+ # === Return
95
+ # true:: Always return true
96
+ def update
97
+ ProgressReporter.report_to_stdout
98
+ report_check 'Retrieving latest rconf...'
99
+ json = Command.execute('curl', '-s', 'http://rubygems.org/api/v1/gems/rconf.json').output
100
+ info = JSON.load(json)
101
+ report_fatal 'Failed to retrieve rconf gem information, check network connectivity' unless info
102
+ version = info['version']
103
+ report_success
104
+ report('Latest rconf version is ' + version.blue)
105
+ rubies = Command.execute('rvm', 'list').output
106
+ rubies = rubies.split("\n")[3..-1]
107
+ update_rconf(rubies, version)
57
108
  end
58
109
 
110
+ # Update rconf for given rubies if required
111
+ #
112
+ # === Parameters
113
+ # rubies(Array):: List of rubies as returned by 'rvm list'
114
+ # version(String):: Latest version
115
+ #
116
+ # === Return
117
+ # true:: Always return true
118
+ def update_rconf(rubies, version)
119
+ rubies.each do |ruby|
120
+ ruby =~ /(\s+| =>)([^ ]*)\s.*/
121
+ ruby = Regexp.last_match(2)
122
+ report_check("Checking rconf for #{ruby}")
123
+ rconf = Command.execute('rvm', "#{ruby}@global", 'exec', 'gem', 'list', 'rconf').output
124
+ if rconf =~ /rconf \(#{version}\)/
125
+ report_success
126
+ next
127
+ else
128
+ report_failure
129
+ report_check("Updating rconf for #{ruby}")
130
+ res = Command.execute('rvm', "#{ruby}@global", 'exec', 'gem', 'install', 'rconf')
131
+ report_result(res.success?)
132
+ end
133
+ end
134
+ end
135
+
136
+
59
137
  # Actually configure environment
60
138
  #
61
139
  # === Parameters
@@ -65,27 +143,6 @@ where [options] are:
65
143
  # === Return
66
144
  # true:: Always return true
67
145
  def configure(options)
68
- if options[:configurators]
69
- puts "The following configurators are registered:\n\n"
70
- ConfiguratorRegistry.each do |key, configurator|
71
- puts "== #{key} ==".bold
72
- puts configurator.desc
73
- puts 'Settings:'
74
- max_size = configurator.all_settings.keys.map(&:to_s).map(&:size).max
75
- configurator.all_settings.each do |name, desc|
76
- num_spaces = max_size - name.to_s.size + 1
77
- print " - #{name.to_s.blue}:#{' ' * num_spaces}#{desc}"
78
- required_settings = configurator.required_settings || []
79
- if required_settings.include?(name)
80
- puts ' [required]'.green
81
- else
82
- puts
83
- end
84
- end
85
- puts
86
- end
87
- exit 0
88
- end
89
146
  Profile.reset if options[:force]
90
147
  ProgressReporter.report_to_stdout
91
148
  ProgressReporter.report_to_file(options[:output]) if options[:output]
@@ -75,11 +75,16 @@ module RightConf
75
75
  report_success
76
76
  end
77
77
  report_check("Installing bundler #{version}")
78
- gem_path DEFAULT_GEM_PATH unless gem_path
79
- bundler_file = File.join(gem_path, "bundler-#{version}.gem")
80
- report_fatal("Missing bundler gem at #{bundler_file}") unless File.exist?(bundler_file)
81
- res = Command.execute('gem','install', bundler_file, '--no-ri', '--no-rdoc',
82
- :abort_on_failure => 'Failed to install bundler')
78
+ if gem_path
79
+ bundler_file = [ File.join(gem_path, "bundler-#{version}.gem") ]
80
+ report_fatal("Missing bundler gem at #{bundler_file}") unless File.exist?(bundler_file)
81
+ else
82
+ bundler_file = [ 'bundler', '-v', version ]
83
+ end
84
+ options = [ 'gem','install' ]
85
+ options += bundler_file
86
+ options += [ '--no-ri', '--no-rdoc', :abort_on_failure => 'Failed to install bundler' ]
87
+ res = Command.execute(*options)
83
88
  report_success
84
89
  true
85
90
  end
data/lib/rconf/version.rb CHANGED
@@ -13,7 +13,7 @@ module RightConf
13
13
 
14
14
  MAJOR = 0
15
15
  MINOR = 6
16
- BUILD = 15
16
+ BUILD = 16
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
data/rconf.gemspec CHANGED
@@ -13,6 +13,8 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.rubyforge_project = 'rconf'
15
15
 
16
+ s.add_dependency('json', '> 1.1.6')
17
+
16
18
  s.add_development_dependency('rspec', "~> 2.5")
17
19
  s.add_development_dependency('flexmock', "~> 0.9")
18
20
 
@@ -4,4 +4,8 @@ ruby do
4
4
  rubygems '1.3.7'
5
5
  gemset 'rconf'
6
6
  end
7
+ bundler do
8
+ version '1.0.10'
9
+ end
10
+
7
11
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rconf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.15
5
+ version: 0.6.16
6
6
  platform: ruby
7
7
  authors:
8
8
  - Raphael Simon
@@ -14,27 +14,38 @@ date: 2011-03-12 23:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: rspec
17
+ name: json
18
18
  prerelease: false
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 1.1.6
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
20
31
  none: false
21
32
  requirements:
22
33
  - - ~>
23
34
  - !ruby/object:Gem::Version
24
35
  version: "2.5"
25
36
  type: :development
26
- version_requirements: *id001
37
+ version_requirements: *id002
27
38
  - !ruby/object:Gem::Dependency
28
39
  name: flexmock
29
40
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
41
+ requirement: &id003 !ruby/object:Gem::Requirement
31
42
  none: false
32
43
  requirements:
33
44
  - - ~>
34
45
  - !ruby/object:Gem::Version
35
46
  version: "0.9"
36
47
  type: :development
37
- version_requirements: *id002
48
+ version_requirements: *id003
38
49
  description: |
39
50
  rconf configures the environment for a given application. rconf reads
40
51
  the content of an application configuration file and installs and/or
@@ -54,6 +65,7 @@ extra_rdoc_files: []
54
65
 
55
66
  files:
56
67
  - .gitignore
68
+ - Gemfile
57
69
  - README.rdoc
58
70
  - Rakefile
59
71
  - bin/rconf
@@ -80,7 +92,7 @@ files:
80
92
  - lib/rconf/trollop.rb
81
93
  - lib/rconf/version.rb
82
94
  - rconf.gemspec
83
- - rconf.rc
95
+ - rconf.rconf
84
96
  - spec/command_spec.rb
85
97
  - spec/configurator_spec.rb
86
98
  - spec/configurators/bundler_configurator_spec.rb