rconf 0.5.3 → 0.5.5

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 CHANGED
@@ -10,6 +10,8 @@
10
10
  # License Agreement between RightScale.com, Inc. and
11
11
  # the licensee
12
12
 
13
+ $stdout.sync = true
14
+
13
15
  require File.join(File.dirname(__FILE__), '..', 'lib', 'rconf')
14
16
 
15
17
  module RightConf
@@ -21,19 +21,19 @@ module RightConf
21
21
 
22
22
  description 'Installs bundler and runs "bundle install"'
23
23
 
24
- settings :bundler_version => 'Version of bundler gem, e.g. "1.0.10"',
25
- :bundler_gem_path => 'Path to bundler gem, e.g. "vendor/system_gems/cache"'
24
+ settings :version => 'Version of bundler gem, e.g. "1.0.10"',
25
+ :gem_path => 'Path to bundler gem, e.g. "vendor/system_gems/cache"'
26
26
 
27
- validate_has_settings :bundler_version
27
+ validate_has_settings :version
28
28
 
29
29
  # Install bundler if needed and run bundle install
30
30
  #
31
31
  # === Return
32
32
  # true:: Always return true
33
33
  def run_linux
34
- report_check("Checking for bundler #{bundler_version}")
34
+ report_check("Checking for bundler #{version}")
35
35
  res = Command.execute('bundle', '--version')
36
- success = (res.output =~ /#{bundler_version}/)
36
+ success = (res.output =~ /#{version}/)
37
37
  report_result(success)
38
38
  install_bundler unless success
39
39
  report_check('Installing gems')
@@ -69,9 +69,9 @@ module RightConf
69
69
  :abort_on_failure => 'Failed to uninstall bundler')
70
70
  report_success
71
71
  end
72
- report_check("Installing bundler #{bundler_version}")
73
- bundler_gem_path DEFAULT_GEM_PATH unless bundler_gem_path
74
- bundler_file = File.join(bundler_gem_path, "bundler-#{bundler_version}.gem")
72
+ report_check("Installing bundler #{version}")
73
+ gem_path DEFAULT_GEM_PATH unless gem_path
74
+ bundler_file = File.join(gem_path, "bundler-#{version}.gem")
75
75
  report_fatal("Missing bundler gem at #{bundler_file}") unless File.exist?(bundler_file)
76
76
  res = Command.execute('gem','install', bundler_file, '--no-ri', '--no-rdoc',
77
77
  :abort_on_failure => 'Failed to install bundler')
@@ -0,0 +1,70 @@
1
+ # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
2
+ #
3
+ # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
+ # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
5
+ # reproduction, modification, or disclosure of this program is
6
+ # strictly prohibited. Any use of this program by an authorized
7
+ # licensee is strictly subject to the terms and conditions,
8
+ # including confidentiality obligations, set forth in the applicable
9
+ # License Agreement between RightScale.com, Inc. and
10
+ # the licensee
11
+
12
+ module RightConf
13
+
14
+ class PackagesConfigurator
15
+
16
+ include Configurator
17
+
18
+ register :packages
19
+
20
+ description 'Installs packages defined for running platform'
21
+
22
+ settings :debian => 'Packages to be installed on Debian based Linux',
23
+ :centos => 'Packages to be installed on RedHat / Centos',
24
+ :windows => 'Softwared to be downloaded and installed on Windows',
25
+ :mac => 'Brew packages to be installed on Mac OS X (https://github.com/mxcl/homebrew)'
26
+
27
+ # Install debian packages
28
+ #
29
+ # === Return
30
+ # true:: Always return true
31
+ def run_linux_ubuntu
32
+ return if debian.nil?
33
+ report_check("Installing the following packages:\n#{debian.join(' ')}\nThis could take a while")
34
+ opts = debian << { :abort_on_failure => 'Failed to install packages' }
35
+ Command.execute('sudo', 'aptitude', 'install', *opts)
36
+ report_success
37
+ end
38
+ alias :run_linux_debian :run_linux_ubuntu
39
+
40
+ # Install yum packages
41
+ #
42
+ # === Return
43
+ # true:: Always return true
44
+ def run_linux_centos
45
+ return if centos.nil?
46
+ report_check("Installing the following packages:\n#{centos.join(' ')}\nThis could take a while")
47
+ opts = centos << { :abort_on_failure => 'Failed to install packages' }
48
+ Command.execute('sudo', 'yum', 'install', '-y', *opts)
49
+ report_success
50
+ end
51
+ alias :run_linux_redhat :run_linux_centos
52
+
53
+ # Install Windows software
54
+ #
55
+ # === Return
56
+ # true:: Always return true
57
+ def run_windows
58
+ # TBD
59
+ end
60
+
61
+ # Use brew on Mac OS X
62
+ #
63
+ # === Return
64
+ # true:: Always return true
65
+ def run_darwin
66
+ # TBD, check brew is installed then use
67
+ end
68
+
69
+ end
70
+ end
@@ -23,11 +23,11 @@ module RightConf
23
23
  description "Installs ruby interpreter and rubygems.\n" +
24
24
  'Installs and uses rvm on supported (i.e. non-Windows) platforms'
25
25
 
26
- settings :ruby_version => 'Ruby version using rvm notation (see "rvm list known")',
27
- :rubygems_version => 'Rubygems version, e.g. "1.3.7"',
28
- :gemset => 'Gemset to be used for platforms supporting rvm'
26
+ settings :version => 'Ruby version using rvm notation (see "rvm list known")',
27
+ :rubygems => 'Rubygems version, e.g. "1.3.7"',
28
+ :gemset => 'Gemset to be used for platforms supporting rvm'
29
29
 
30
- validate_has_settings :ruby_version, :rubygems_version
30
+ validate_has_settings :version, :rubygems
31
31
 
32
32
  # Switch to ruby version defined in settings
33
33
  # Use rvm and install it if needed
@@ -36,45 +36,49 @@ module RightConf
36
36
  # true:: Always return true
37
37
  def run_linux
38
38
  check_rvm(RVM_VERSION)
39
- report_check("Checking whether #{ruby_version} is the active ruby")
39
+ report_check("Checking whether #{version} is the active ruby")
40
40
  out = Command.execute('rvm', 'list').output
41
- if out =~ /^=> #{ruby_version.gsub('.', '\\.')}/
41
+ if out =~ /^=> #{version.gsub('.', '\\.')}/
42
42
  report_success
43
43
  else
44
44
  report_failure
45
- report_check("Switching to #{ruby_version}")
46
- out = Command.execute('rvm', 'use', ruby_version).output
45
+ report_check("Switching to #{version}")
46
+ out = Command.execute('rvm', 'use', version).output
47
47
  case out
48
48
  when /is not installed\./
49
49
  report_failure
50
50
  report_fatal "Failed to install #{ruby}: #{@out}" if @out
51
- @out = install_ruby(ruby_version)
51
+ @out = install_ruby(version)
52
52
  run
53
53
  return true
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
+ Command.execute('rvm', version, 'exec', 'gem', 'install', 'rconf',
58
+ :abort_on_failure => "Failed to install rconf gem in #{version}")
59
59
  post_note "Configuration required switching the active ruby\nPlease 'cd' into the project directory again to activate it"
60
60
  else
61
- report_fatal("Failed to use #{ruby_version}:\n#{out}")
61
+ report_fatal("Failed to use #{version}:\n#{out}")
62
62
  end
63
63
  end
64
64
  if gemset
65
- report_check("Switching to gemset #{gemset}")
66
- res = Command.execute('rvm', ruby_version, 'gemset', 'list')
67
- unless res.output =~ /^#{gemset}$/
68
- report_check("Creating gemset #{gemset} for #{ruby_version}")
69
- Command.execute('rvm', ruby_version, 'gemset', 'create', gemset,
65
+ report_check("Checking whether gemset #{gemset} exists")
66
+ res = Command.execute('rvm', version, 'gemset', 'list')
67
+ if res.output =~ /^#{gemset}$/
68
+ report_success
69
+ else
70
+ report_fail
71
+ report_check("Creating gemset #{gemset} for #{version}")
72
+ Command.execute('rvm', version, 'gemset', 'create', gemset,
70
73
  :abort_on_failure => "Failed to create gemset '#{gemset}'")
71
74
  report_success
72
75
  end
73
- Command.execute('rvm', ruby_version, 'gemset', 'use', gemset,
76
+ report_check("Switching to gemset #{gemset}")
77
+ Command.execute('rvm', version, 'gemset', 'use', gemset,
74
78
  :abort_on_failure => "Failed to switch to gemset '#{gemset}'")
75
79
  report_success
76
80
  end
77
- Command.set_prefix("rvm #{ruby_version}@#{gemset} exec --")
81
+ Command.set_prefix("rvm #{version}@#{gemset} exec --")
78
82
  true
79
83
  end
80
84
  alias :run_darwin :run_linux
@@ -130,12 +134,51 @@ module RightConf
130
134
  # === Return
131
135
  # out(String):: Installation output
132
136
  def install_ruby(ruby)
137
+ Platform.dispatch(ruby) { :install_ruby_prerequesites }
133
138
  report_check("Installing #{ruby} (this will take a while, please be patient)")
134
139
  res = Command.execute('rvm', 'install', ruby)
135
140
  report_result(res.success?)
136
141
  res.output
137
142
  end
138
143
 
144
+ # Make sure to install all required linux packages first
145
+ #
146
+ # === Return
147
+ # true:: Always return true
148
+ def install_ruby_prerequesites_linux_ubuntu(ruby)
149
+ report_check("Installing required packages, this could take a while")
150
+ packages = []
151
+ if ruby =~ /^ree-|^ruby-/
152
+ packages = %w(build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev)
153
+ end # TBD Define packages needed for other rubies
154
+ Command.execute('sudo', 'aptitude', 'install', *packages)
155
+ report_success
156
+ end
157
+
158
+ # Make sure to install all required CentOS / RedHhat packages first
159
+ # NOTE: For centos 5.4 final iconv-devel might not be available :(
160
+ #
161
+ # === Return
162
+ # true:: Always return true
163
+ def install_ruby_prerequesites_linux_centos(ruby)
164
+ report_check("Installing required packages, this could take a while")
165
+ packages = []
166
+ if ruby =~ /^ree-|^ruby-/
167
+ packages = %w(gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel iconv-devel)
168
+ end # TBD Define packages needed for other rubies
169
+ Command.execute('sudo', 'yum', 'install', '-y', *packages)
170
+ report_success
171
+ end
172
+ alias :install_ruby_prerequesites_linux_redhat :install_ruby_prerequesites_linux_centos
173
+
174
+ # No pre-requesites to install ree or Matz ruby on Mac (TBD others)
175
+ #
176
+ # === Return
177
+ # true:: Always return true
178
+ def install_ruby_prerequesites_darwin(ruby)
179
+ true
180
+ end
181
+
139
182
  # Check .rvmrc and its content
140
183
  #
141
184
  # === Return
@@ -144,7 +187,7 @@ module RightConf
144
187
  report_check('Setting up .rvmrc')
145
188
  begin
146
189
  File.open('.rvmrc', 'w') do |f|
147
- f.puts "rvm #{ruby_version}@#{gemset}"
190
+ f.puts "rvm #{version}@#{gemset}"
148
191
  f.puts "type -P rconf &>/dev/null && { rconf; }"
149
192
  f.puts "type -P rconf &>/dev/null || { echo 'rconf not installed, skipping (see .rvmrc)'; }"
150
193
  end
@@ -37,7 +37,7 @@ module RightConf
37
37
  # text(String):: Formatted text
38
38
  def format_message(msg)
39
39
  text = @in_check ? "\n" : ''
40
- text += super(msg).green
40
+ text += super(msg)
41
41
  @in_check = false
42
42
  text
43
43
  end
data/lib/rconf/version.rb CHANGED
@@ -13,7 +13,7 @@ module RightConf
13
13
 
14
14
  MAJOR = 0
15
15
  MINOR = 5
16
- BUILD = 3
16
+ BUILD = 5
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
@@ -18,7 +18,7 @@ describe RightConf::BundlerConfigurator do
18
18
  end
19
19
 
20
20
  before(:each) do
21
- lang = RightConf::Language.parse('bundler { bundler_version "0" }')
21
+ lang = RightConf::Language.parse('bundler { version "0" }')
22
22
  @configurator = lang.configurators.first
23
23
  [:report_check, :report_result, :report_fatal, :report_success].each do |meth|
24
24
  flexmock(@configurator).should_receive(meth)
@@ -34,7 +34,7 @@ describe RightConf::BundlerConfigurator do
34
34
  end
35
35
 
36
36
  it 'should install bunlder if needed' do
37
- flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
37
+ flexmock(RightConf::Command.instance).should_receive(:execute).twice.with(
38
38
  'bundle', '--version').and_return(success_result('1'))
39
39
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
40
40
  'bundle', 'install', {:abort_on_failure=>"Failed to install gems"}).and_return(success_result)
@@ -0,0 +1,43 @@
1
+ # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
2
+ #
3
+ # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
+ # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
5
+ # reproduction, modification, or disclosure of this program is
6
+ # strictly prohibited. Any use of this program by an authorized
7
+ # licensee is strictly subject to the terms and conditions,
8
+ # including confidentiality obligations, set forth in the applicable
9
+ # License Agreement between RightScale.com, Inc. and
10
+ # the licensee
11
+
12
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
13
+
14
+ describe RightConf::PackagesConfigurator do
15
+
16
+ def success_result(output=nil)
17
+ flexmock('res', :success? => true, :output => output)
18
+ end
19
+
20
+ before(:each) do
21
+ lang = RightConf::Language.parse('packages { debian %w(deb1 deb2); centos %w(cent1 cent2) }')
22
+ @configurator = lang.configurators.first
23
+ [:report_check, :report_result, :report_fatal, :report_success].each do |meth|
24
+ flexmock(@configurator).should_receive(meth)
25
+ end
26
+ end
27
+
28
+ it 'should install packages on Ubuntu' do
29
+ flexmock(RightConf::Command.instance).should_receive(:execute).with(
30
+ 'sudo', 'aptitude', 'install', 'deb1', 'deb2',
31
+ {:abort_on_failure=>"Failed to install packages"}).and_return(success_result)
32
+ @configurator.run_linux_ubuntu
33
+ end
34
+
35
+ it 'should install packages on Centos' do
36
+ flexmock(RightConf::Command.instance).should_receive(:execute).with(
37
+ 'sudo', 'yum', 'install', '-y', 'cent1', 'cent2',
38
+ {:abort_on_failure=>"Failed to install packages"}).and_return(success_result)
39
+ @configurator.run_linux_centos
40
+ end
41
+
42
+ end
43
+
@@ -18,7 +18,7 @@ describe RightConf::RubyConfigurator do
18
18
  end
19
19
 
20
20
  before(:each) do
21
- lang = RightConf::Language.parse('ruby { ruby_version "0"; rubygems_version "1" }')
21
+ lang = RightConf::Language.parse('ruby { version "0"; rubygems "1" }')
22
22
  @configurator = lang.configurators.first
23
23
  [:report_check, :report_result, :report_fatal, :report_success, :report].each do |meth|
24
24
  flexmock(@configurator).should_receive(meth)
@@ -46,7 +46,8 @@ describe RightConf::RubyConfigurator do
46
46
  "http://rvm.beginrescueend.com/releases/#{rvm_tar}",
47
47
  {:abort_on_failure=>"Failed to download rvm #{RightConf::RubyConfigurator::RVM_VERSION}"}).and_return(success_result)
48
48
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
49
- 'tar', 'zxf', rvm_tar).and_return(success_result)
49
+ 'tar', 'zxf', rvm_tar,
50
+ {:abort_on_failure=>"Failed to extract rvm tgz from /Users/raphael/src/right_env/rvm-1.2.6.tar.gz"}).and_return(success_result)
50
51
  flexmock(Dir).should_receive(:chdir).and_yield
51
52
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
52
53
  './install', {:abort_on_failure=>"Failed to install rvm #{RightConf::RubyConfigurator::RVM_VERSION}"}).and_return(success_result)
@@ -26,22 +26,22 @@ describe RightConf::Language do
26
26
  end
27
27
 
28
28
  it 'should parse correctly' do
29
- lang = RightConf::Language.parse('ruby { ruby_version "1"; rubygems_version "2" }')
29
+ lang = RightConf::Language.parse('ruby { version "1"; rubygems "2" }')
30
30
  lang.validation_errors.size.should == 0
31
31
  lang.configurators.size.should == 1
32
32
  lang.configurators.first.class.should == RightConf::RubyConfigurator
33
33
  lang.configurators.first.instance_variable_get(:@settings_values).should ==
34
- { :ruby_version => '1', :rubygems_version => '2' }
34
+ { :version => '1', :rubygems => '2' }
35
35
  end
36
36
 
37
37
  it 'should parse multiple configurations' do
38
38
  lang = RightConf::Language.parse(<<-EOS
39
39
  ruby do
40
- ruby_version "1"
41
- rubygems_version "2"
40
+ version "1"
41
+ rubygems "2"
42
42
  end
43
43
  bundler do
44
- bundler_version "3"
44
+ version "3"
45
45
  end
46
46
  EOS
47
47
  )
@@ -49,10 +49,10 @@ describe RightConf::Language do
49
49
  lang.configurators.size.should == 2
50
50
  lang.configurators[0].class.should == RightConf::RubyConfigurator
51
51
  lang.configurators[0].instance_variable_get(:@settings_values).should ==
52
- { :ruby_version => '1', :rubygems_version => '2' }
52
+ { :version => '1', :rubygems => '2' }
53
53
  lang.configurators[1].class.should == RightConf::BundlerConfigurator
54
54
  lang.configurators[1].instance_variable_get(:@settings_values).should ==
55
- { :bundler_version => '3' }
55
+ { :version => '3' }
56
56
  end
57
57
 
58
58
 
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rconf
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.5.3
4
+ hash: 1
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 5
10
+ version: 0.5.5
6
11
  platform: ruby
7
12
  authors:
8
13
  - Raphael Simon
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-03-05 00:00:00 -08:00
18
+ date: 2011-03-06 00:00:00 -08:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,10 @@ dependencies:
21
26
  requirements:
22
27
  - - ~>
23
28
  - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 2
32
+ - 5
24
33
  version: "2.5"
25
34
  type: :development
26
35
  version_requirements: *id001
@@ -32,6 +41,10 @@ dependencies:
32
41
  requirements:
33
42
  - - ~>
34
43
  - !ruby/object:Gem::Version
44
+ hash: 25
45
+ segments:
46
+ - 0
47
+ - 9
35
48
  version: "0.9"
36
49
  type: :development
37
50
  version_requirements: *id002
@@ -63,6 +76,7 @@ files:
63
76
  - lib/rconf/configurator.rb
64
77
  - lib/rconf/configurator_registry.rb
65
78
  - lib/rconf/configurators/bundler_configurator.rb
79
+ - lib/rconf/configurators/packages_configurator.rb
66
80
  - lib/rconf/configurators/ruby_configurator.rb
67
81
  - lib/rconf/language.rb
68
82
  - lib/rconf/platform.rb
@@ -80,6 +94,7 @@ files:
80
94
  - spec/command_spec.rb
81
95
  - spec/configurator_spec.rb
82
96
  - spec/configurators/bundler_configurator_spec.rb
97
+ - spec/configurators/packages_configurator_spec.rb
83
98
  - spec/configurators/ruby_configurator_spec.rb
84
99
  - spec/language_spec.rb
85
100
  - spec/platform_spec.rb
@@ -102,17 +117,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
117
  requirements:
103
118
  - - ">="
104
119
  - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
105
123
  version: "0"
106
124
  required_rubygems_version: !ruby/object:Gem::Requirement
107
125
  none: false
108
126
  requirements:
109
127
  - - ">="
110
128
  - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
111
132
  version: "0"
112
133
  requirements: []
113
134
 
114
135
  rubyforge_project: rconf
115
- rubygems_version: 1.5.0
136
+ rubygems_version: 1.3.7
116
137
  signing_key:
117
138
  specification_version: 3
118
139
  summary: Cross platform environment configuration
@@ -120,6 +141,7 @@ test_files:
120
141
  - spec/command_spec.rb
121
142
  - spec/configurator_spec.rb
122
143
  - spec/configurators/bundler_configurator_spec.rb
144
+ - spec/configurators/packages_configurator_spec.rb
123
145
  - spec/configurators/ruby_configurator_spec.rb
124
146
  - spec/language_spec.rb
125
147
  - spec/platform_spec.rb