sprinkle 0.6.2 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,3 +3,9 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ group :development do
8
+ gem 'pry'
9
+ gem 'pry_debug'
10
+ gem 'pry-rescue'
11
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sprinkle (0.6.1.1)
4
+ sprinkle (0.6.2)
5
5
  activesupport (>= 2.0.2)
6
6
  capistrano (>= 2.5.5)
7
7
  highline (>= 1.4.0)
@@ -19,35 +19,51 @@ GEM
19
19
  net-sftp (>= 2.0.0)
20
20
  net-ssh (>= 2.0.14)
21
21
  net-ssh-gateway (>= 1.1.0)
22
- diff-lcs (1.1.3)
23
- highline (1.6.18)
22
+ coderay (1.0.9)
23
+ diff-lcs (1.2.4)
24
+ highline (1.6.19)
24
25
  i18n (0.6.1)
25
- json (1.7.5)
26
- multi_json (1.7.2)
27
- net-scp (1.1.0)
26
+ interception (0.3)
27
+ json (1.8.0)
28
+ method_source (0.8.1)
29
+ multi_json (1.7.7)
30
+ net-scp (1.1.1)
28
31
  net-ssh (>= 2.6.5)
29
- net-sftp (2.1.1)
32
+ net-sftp (2.1.2)
30
33
  net-ssh (>= 2.6.5)
31
34
  net-ssh (2.6.7)
32
35
  net-ssh-gateway (1.2.0)
33
36
  net-ssh (>= 2.6.5)
34
37
  open4 (1.3.0)
38
+ pry (0.9.12.2)
39
+ coderay (~> 1.0.5)
40
+ method_source (~> 0.8)
41
+ slop (~> 3.4)
42
+ pry-rescue (1.1.1)
43
+ interception (>= 0.3)
44
+ pry
45
+ pry_debug (0.1.0)
46
+ pry (~> 0.9.0)
35
47
  rake (10.0.4)
36
- rdoc (3.12)
48
+ rdoc (4.0.1)
37
49
  json (~> 1.4)
38
- rspec (2.12.0)
39
- rspec-core (~> 2.12.0)
40
- rspec-expectations (~> 2.12.0)
41
- rspec-mocks (~> 2.12.0)
42
- rspec-core (2.12.0)
43
- rspec-expectations (2.12.0)
44
- diff-lcs (~> 1.1.3)
45
- rspec-mocks (2.12.0)
50
+ rspec (2.13.0)
51
+ rspec-core (~> 2.13.0)
52
+ rspec-expectations (~> 2.13.0)
53
+ rspec-mocks (~> 2.13.0)
54
+ rspec-core (2.13.1)
55
+ rspec-expectations (2.13.0)
56
+ diff-lcs (>= 1.1.3, < 2.0)
57
+ rspec-mocks (2.13.1)
58
+ slop (3.4.5)
46
59
 
47
60
  PLATFORMS
48
61
  ruby
49
62
 
50
63
  DEPENDENCIES
64
+ pry
65
+ pry-rescue
66
+ pry_debug
51
67
  rake (>= 0.8.7)
52
68
  rdoc (>= 3.12)
53
69
  rspec (>= 2.5)
data/README.md CHANGED
@@ -60,7 +60,7 @@ Packages can be grouped into polices to define several packages that should be i
60
60
 
61
61
  ``` ruby
62
62
  policy :rails, :roles => :app do
63
- requires :rails_32
63
+ requires :rails, :version => "3.2"
64
64
  requires :appserver
65
65
  requires :database
66
66
  requires :webserver
@@ -160,7 +160,7 @@ package :rubygems do
160
160
  requires :ruby
161
161
  end
162
162
 
163
- package :rails_32 do
163
+ package :rails do
164
164
  description 'Ruby on Rails'
165
165
  gem 'rails'
166
166
  version '3.2'
@@ -199,7 +199,7 @@ end
199
199
  # the user is requested to select which one to use.
200
200
 
201
201
  policy :rails, :roles => :app do
202
- requires :rails
202
+ requires :rails, :version => "3.2"
203
203
  requires :appserver
204
204
  requires :database
205
205
  requires :webserver
@@ -0,0 +1,41 @@
1
+ # Install the latest MySQL database from source
2
+ package :mysql do
3
+ requires :mysql_dependencies, :mysql_user_group, :mysql_user, :mysql_core
4
+ end
5
+
6
+ package :mysql_dependencies do
7
+ description 'MySQL dependencies'
8
+ apt 'cmake'
9
+ end
10
+
11
+ package :mysql_user_group do
12
+ description 'MySQL user group'
13
+ group 'mysql'
14
+ verify do
15
+ has_group 'mysql'
16
+ end
17
+ end
18
+
19
+ package :mysql_user do
20
+ description 'MySQL user'
21
+ requires :mysql_user_group
22
+ runner 'useradd -r -g mysql mysql'
23
+ verify do
24
+ has_user 'mysql'
25
+ end
26
+ end
27
+
28
+ package :mysql_core do
29
+ description 'MySQL database'
30
+ version '5.5.25a'
31
+ requires :mysql_dependencies, :mysql_user_group, :mysql_user
32
+ source "http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-#{version}.tar.gz/from/http://cdn.mysql.com/" do
33
+ custom_archive "mysql-#{version}.tar.gz"
34
+ configure_command 'cmake .'
35
+ post :install, '/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql'
36
+ post :install, 'chown -R mysql:mysql /usr/local/mysql/data'
37
+ end
38
+ verify do
39
+ has_executable '/usr/local/mysql/bin/mysql'
40
+ end
41
+ end
@@ -34,6 +34,10 @@ module Sprinkle
34
34
  end
35
35
  end
36
36
 
37
+ def sudo?
38
+ false
39
+ end
40
+
37
41
  def verify(verifier, roles, opts = {})
38
42
  process(verifier.package.name, verifier.commands, roles, opts = {})
39
43
  end
@@ -198,8 +198,8 @@ module Sprinkle
198
198
  end
199
199
 
200
200
  def ssh(host, cmd, opts={}) #:nodoc:
201
- logger.debug "ssh: #{cmd}"
202
201
  session = host.is_a?(Net::SSH::Connection::Session) ? host : ssh_session(host)
202
+ logger.debug "[#{session.host}] ssh: #{cmd}"
203
203
  channel_runner(session, cmd)
204
204
  end
205
205
 
@@ -207,12 +207,12 @@ module Sprinkle
207
207
  session.open_channel do |channel|
208
208
  channel.on_data do |ch, data|
209
209
  @log_recorder.log :out, data
210
- logger.debug yellow("stdout said-->\n#{data}\n")
210
+ logger.debug yellow("[#{session.host}] stdout said-->\n#{data}\n")
211
211
  end
212
212
  channel.on_extended_data do |ch, type, data|
213
213
  next unless type == 1 # only handle stderr
214
214
  @log_recorder.log :err, data
215
- logger.debug red("stderr said -->\n#{data}\n")
215
+ logger.debug red("[#{session.host}] stderr said -->\n#{data}\n")
216
216
  end
217
217
 
218
218
  channel.on_request("exit-status") do |ch, data|
@@ -63,14 +63,15 @@ module Sprinkle
63
63
  module Package
64
64
  class Package
65
65
  def install_package(*names, &block)
66
+ ActiveSupport::Deprecation.warn("install_package will be removed from sprinkle 0.8, please use yum or smart installers instead.")
66
67
  @installers << Sprinkle::Installers::InstallPackage.new(self, names, &block)
67
68
  end
68
69
 
69
70
  def uninstall_package(*names, &block)
71
+ ActiveSupport::Deprecation.warn("uninstall_package will be removed from sprinkle 0.8, please use yum or smart installers instead.")
70
72
  @installers << Sprinkle::Installers::UninstallPackage.new(self, names, &block)
71
73
  end
72
74
 
73
-
74
75
  alias_method :install_packages, :install_package
75
76
  alias_method :uninstall_packages, :uninstall_package
76
77
  end
@@ -71,6 +71,17 @@ module Sprinkle
71
71
  # end
72
72
  # end
73
73
  #
74
+ # Sixth, specifying custom configure, build, and install commands:
75
+ #
76
+ # package :mysql_build do
77
+ # source 'http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a.tar.gz/from/http://cdn.mysql.com/' do
78
+ # custom_archive 'mysql-5.5.25a.tar.gz'
79
+ # configure_command 'cmake .'
80
+ # build_command 'make' # This is actually the default command but could be set to something else here.
81
+ # install_command 'make install' # This is actually the default command but could be set to something else here.
82
+ # end
83
+ # end
84
+ #
74
85
  # As you can see, setting options is as simple as creating a
75
86
  # block and calling the option as a method with the value as
76
87
  # its parameter.
@@ -89,10 +100,10 @@ module Sprinkle
89
100
  super parent, options, &block
90
101
  @source = source
91
102
  end
92
-
93
- multi_attributes :enable, :disable, :with, :without, :option,
94
- :custom_install
95
-
103
+
104
+ multi_attributes :enable, :disable, :with, :without, :option,
105
+ :custom_install, :configure_command, :build_command, :install_command
106
+
96
107
  def install_sequence #:nodoc:
97
108
  prepare + download + extract + configure + build + install
98
109
  end
@@ -126,7 +137,7 @@ module Sprinkle
126
137
  def configure_commands #:nodoc:
127
138
  return [] if custom_install?
128
139
 
129
- command = "bash -c 'cd #{build_dir} && ./configure --prefix=#{@options[:prefix]} "
140
+ command = "#{configure_command || './configure'} --prefix=#{@options[:prefix]} "
130
141
 
131
142
  extras = {
132
143
  :enable => '--enable', :disable => '--disable',
@@ -136,17 +147,17 @@ module Sprinkle
136
147
 
137
148
  extras.inject(command) { |m, (k, v)| m << create_options(k, v) if options[k]; m }
138
149
 
139
- [ command << " > #{@package.name}-configure.log 2>&1'" ]
150
+ [ in_build_dir(with_log(command,:configure)) ]
140
151
  end
141
152
 
142
153
  def build_commands #:nodoc:
143
154
  return [] if custom_install?
144
- [ "bash -c 'cd #{build_dir} && make > #{@package.name}-build.log 2>&1'" ]
155
+ [ in_build_dir(with_log("#{build_command || "make"}",:build)) ]
145
156
  end
146
157
 
147
158
  def install_commands #:nodoc:
148
159
  return custom_install_commands if custom_install?
149
- [ "bash -c 'cd #{build_dir} && make install > #{@package.name}-install.log 2>&1'" ]
160
+ [ in_build_dir(with_log("#{install_command || "make install"}",:install)) ]
150
161
  end
151
162
 
152
163
  def custom_install? #:nodoc:
@@ -160,6 +171,14 @@ module Sprinkle
160
171
 
161
172
  protected
162
173
 
174
+ def with_log(cmd, stage)
175
+ "#{cmd} > #{@package.name}-#{stage}.log 2>&1"
176
+ end
177
+
178
+ def in_build_dir(cmd)
179
+ "bash -c 'cd #{build_dir} && #{cmd}'"
180
+ end
181
+
163
182
  def pre_commands(stage) #:nodoc:
164
183
  dress @pre[stage] || [], :pre, stage
165
184
  end
@@ -45,11 +45,11 @@ end
45
45
 
46
46
  module Sprinkle
47
47
  module Installers
48
- # Beware, another strange "installer" coming your way.
49
- #
50
48
  # = File transfer installer
51
49
  #
52
- # This installer pushes files from the local disk to remote servers.
50
+ # This installer copies files from the local disk to remote servers using SCP.
51
+ # Symbolic links will be followed and the files copied, but the symbolic links
52
+ # themselves will not be preserved. That's just how SCP works.
53
53
  #
54
54
  # == Example Usage
55
55
  #
@@ -68,7 +68,13 @@ module Sprinkle
68
68
  #
69
69
  # By default, transfers are recursive and you can move whole directories
70
70
  # via this method. If you wish to disable recursive transfers, you can pass
71
- # recursive => false, although it will not be obeyed when using the Vlad actor.
71
+ # :recursive => false, although it will not be obeyed when using the Vlad actor.
72
+ #
73
+ # Should you need to run commands before or after the file transfer (making
74
+ # directories or changing permissions), you can use the pre/post :install directives
75
+ # and they will be run.
76
+ #
77
+ # == Rendering templates
72
78
  #
73
79
  # If you pass the option :render => true, this tells transfer that the source file
74
80
  # is an ERB template to be rendered locally before being transferred (you can declare
@@ -79,10 +85,6 @@ module Sprinkle
79
85
  # nginx_port = 8080
80
86
  # transfer 'files/nginx.conf', '/etc/nginx.conf', :render => true
81
87
  # end
82
- #
83
- # Finally, should you need to run commands before or after the file transfer (making
84
- # directories or changing permissions), you can use the pre/post :install directives
85
- # and they will be run.
86
88
  class Transfer < Installer
87
89
  attr_accessor :source, :destination, :sourcepath #:nodoc:
88
90
 
@@ -92,16 +92,12 @@ module Sprinkle
92
92
  # FIXME: Should probably document recommendations.
93
93
  #++
94
94
  module Package
95
- PACKAGES = {}
95
+
96
+ PACKAGES = PackageRepository.new
96
97
 
97
98
  def package(name, metadata = {}, &block)
98
99
  package = Package.new(name, metadata, &block)
99
- PACKAGES[name] = package
100
-
101
- if package.provides
102
- (PACKAGES[package.provides] ||= []) << package
103
- end
104
-
100
+ PACKAGES << package
105
101
  package
106
102
  end
107
103
 
@@ -252,7 +248,9 @@ module Sprinkle
252
248
  packages
253
249
  end
254
250
 
255
- def to_s; @name; end
251
+ def to_s
252
+ "#{@name} #{@version}".strip
253
+ end
256
254
 
257
255
  # allow an installer to request a private install queue from the package
258
256
  # for example to allow pre and post hooks to have their own installers that
@@ -289,10 +287,10 @@ module Sprinkle
289
287
  depth = opts[:depth]
290
288
  tree = []
291
289
  packages.each do |dep, config|
292
- package = PACKAGES[dep]
293
- raise "Package definition not found for key: #{dep}" if not package and opts[:required]
294
- next unless package # skip missing recommended packages as they're allowed to not exist
295
- package = select_package(dep, package) if package.is_a? Array
290
+ package = PACKAGES.find_all(dep, config)
291
+ raise "Package definition not found for key: #{dep}" if package.empty? and opts[:required]
292
+ next if package.empty? # skip missing recommended packages as they're allowed to not exist
293
+ package = Chooser.select_package(dep, package) #if package.size>1
296
294
  package = package.instance(config)
297
295
  block.call(self, package, depth) if block
298
296
  tree << package.tree(depth + 1, &block)
@@ -304,22 +302,6 @@ module Sprinkle
304
302
  logger.info(message) if Sprinkle::OPTIONS[:cloud] or logger.debug?
305
303
  end
306
304
 
307
- def select_package(name, packages)
308
- if packages.size <= 1
309
- package = packages.first
310
- else
311
- package = choose do |menu|
312
- menu.prompt = "Multiple choices exist for virtual package #{name}"
313
- menu.choices *packages.collect(&:to_s)
314
- end
315
- package = Sprinkle::Package::PACKAGES[package]
316
- end
317
-
318
- cloud_info "Selecting #{package.to_s} for virtual package #{name}"
319
-
320
- package
321
- end
322
-
323
305
  def meta_package?
324
306
  @installers.blank?
325
307
  end
@@ -0,0 +1,24 @@
1
+ module Sprinkle::Package
2
+ class Chooser
3
+ def self.select_package(name, packages)
4
+ if packages.size <= 1
5
+ package = packages.first
6
+ else
7
+ package = choose do |menu|
8
+ menu.prompt = "Multiple choices exist for virtual package #{name}"
9
+ menu.choices *packages.collect(&:to_s)
10
+ end
11
+ package = Sprinkle::Package::PACKAGES.first(package)
12
+ end
13
+
14
+ cloud_info "Selecting #{package.to_s} for virtual package #{name}"
15
+
16
+ package
17
+ end
18
+
19
+ def self.cloud_info(message)
20
+ logger.info(message) if Sprinkle::OPTIONS[:cloud] or logger.debug?
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,47 @@
1
+ module Sprinkle::Package
2
+ class PackageRepository
3
+
4
+ # sets up an empty repository
5
+ def initialize
6
+ clear
7
+ end
8
+
9
+ def clear
10
+ @packages = []
11
+ end
12
+
13
+ # adds a single package to the repository
14
+ def add(package)
15
+ @packages << package
16
+ end
17
+ def <<(package); add(package); end
18
+
19
+ # returns the first package matching the name and options given
20
+ def first(name, opts={})
21
+ find_all(name, opts).try(:first)
22
+ end
23
+
24
+ # returns all packages matching the name and options given (including via provides)
25
+ def find_all(name, opts={})
26
+ all=[@packages.select {|x| x.name.to_s == name.to_s },
27
+ find_all_by_provides(name, opts)].flatten.compact
28
+ filter(all, opts)
29
+ end
30
+
31
+ def count
32
+ @packages.size
33
+ end
34
+
35
+ private
36
+
37
+ def find_all_by_provides(name, opts={})
38
+ @packages.select {|x| x.provides and x.provides.to_s == name.to_s }
39
+ end
40
+
41
+ def filter(all, opts)
42
+ all = all.select {|x| "#{x.version}" == opts[:version].to_s} if opts[:version]
43
+ all
44
+ end
45
+
46
+ end
47
+ end
@@ -74,9 +74,8 @@ module Sprinkle
74
74
  self.instance_eval(&block)
75
75
  end
76
76
 
77
- # def requires(package, options = {})
78
- def requires(package, *args)
79
- @packages << [package, args]
77
+ def requires(package, opts={})
78
+ @packages << [package, opts]
80
79
  end
81
80
 
82
81
  def packages; @packages.map {|x| x.first }; end
@@ -95,9 +94,9 @@ module Sprinkle
95
94
  @packages.each do |p, args|
96
95
  cloud_info " * requires package #{p}"
97
96
 
98
- package = Sprinkle::Package::PACKAGES[p]
97
+ package = Sprinkle::Package::PACKAGES.find_all(p, args)
99
98
  raise "Package definition not found for key: #{p}" unless package
100
- package = select_package(p, package) if package.is_a? Array # handle virtual package selection
99
+ package = Sprinkle::Package::Chooser.select_package(p, package) if package.is_a? Array # handle virtual package selection
101
100
  # get an instance of the package and pass our config options
102
101
  package = package.instance(*args)
103
102
 
@@ -119,22 +118,6 @@ module Sprinkle
119
118
  logger.info(message) if Sprinkle::OPTIONS[:cloud] or logger.debug?
120
119
  end
121
120
 
122
- def select_package(name, packages)
123
- if packages.size <= 1
124
- package = packages.first
125
- else
126
- package = choose do |menu|
127
- menu.prompt = "Multiple choices exist for virtual package #{name}"
128
- menu.choices *packages.collect(&:to_s)
129
- end
130
- package = Sprinkle::Package::PACKAGES[package]
131
- end
132
-
133
- cloud_info "Selecting #{package.to_s} for virtual package #{name}"
134
-
135
- package
136
- end
137
-
138
121
  def normalize(all, &block)
139
122
  all = all.flatten.uniq
140
123
  cloud_info "--> Normalized installation order for all packages: #{all.collect(&:name).join(', ')}\n"
@@ -1,3 +1,3 @@
1
1
  module Sprinkle
2
- Version = "0.6.2"
2
+ Version = "0.7"
3
3
  end
@@ -48,13 +48,6 @@ describe Sprinkle::Installers::Smart do
48
48
  'smart install ruby -y 2>&1 | tee -a /var/log/smart-sprinkle', 'op2' ]
49
49
  end
50
50
 
51
- it 'should specify a non interactive mode to the apt installer' do
52
- pending
53
- end
54
- it 'should install a specific version if defined' do
55
- pending
56
- end
57
-
58
51
  end
59
52
 
60
53
  end
@@ -35,7 +35,8 @@ describe Sprinkle::Installers::Source do
35
35
  end
36
36
 
37
37
  def create_source(source, version = nil, &block)
38
- @package = mock(Sprinkle::Package, :name => 'package', :version => version)
38
+ @package = mock(Sprinkle::Package, :name => 'package', :version => version,
39
+ :installer_methods => [])
39
40
 
40
41
  Sprinkle::Installers::Source.new(@package, source, &block)
41
42
  end
@@ -207,6 +208,48 @@ describe Sprinkle::Installers::Source do
207
208
 
208
209
  end
209
210
 
211
+ describe 'with default configure, build, and install commands' do
212
+
213
+ before do
214
+ @installer = create_source @source
215
+
216
+ @installer.defaults(@deployment)
217
+ end
218
+
219
+ it 'should use the default commands' do
220
+ @installer.send(:configure_commands).first.should =~ /\.\/configure/
221
+ @installer.send(:build_commands).first.should =~ /make/
222
+ @installer.send(:install_commands).first.should =~ /make install/
223
+ end
224
+
225
+ end
226
+
227
+ describe 'with custom configure, build, and install commands' do
228
+
229
+ before do
230
+ @installer = create_source @source do
231
+ configure_command './custom-configure'
232
+ build_command 'custom-make'
233
+ install_command 'custom-make install'
234
+ end
235
+
236
+ @installer.defaults(@deployment)
237
+ end
238
+
239
+ it 'should store the custom commands' do
240
+ @installer.options[:configure_command].first.should == './custom-configure'
241
+ @installer.options[:build_command].first.should == 'custom-make'
242
+ @installer.options[:install_command].first.should == 'custom-make install'
243
+ end
244
+
245
+ it 'should use the custom commands' do
246
+ @installer.send(:configure_commands).first.should =~ /\.\/custom-configure/
247
+ @installer.send(:build_commands).first.should =~ /custom-make/
248
+ @installer.send(:install_commands).first.should =~ /custom-make install/
249
+ end
250
+
251
+ end
252
+
210
253
  describe 'during a customized install' do
211
254
 
212
255
  before do
@@ -287,7 +330,9 @@ describe Sprinkle::Installers::Source do
287
330
  end
288
331
 
289
332
  it "should be logged" do
290
- pending
333
+ @commands.each do |k, v|
334
+ @installer.send(:pre_commands, k).join.should =~ />>.*#{k}.log/i
335
+ end
291
336
  end
292
337
 
293
338
  it 'should be run relative to the source build area' do
@@ -0,0 +1,46 @@
1
+ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
2
+
3
+ describe Sprinkle::Package::PackageRepository do
4
+
5
+ before do
6
+ @repository = PackageRepository.new {}
7
+ @test_package = Package.new(:test) {}
8
+ @mysql_package = Package.new(:mysql, :provides => :db) {}
9
+ @test_v2_package = Package.new(:test) do
10
+ version "2"
11
+ end
12
+ @another_package = Package.new(:another) {}
13
+ end
14
+
15
+ it 'should allow adding a package' do
16
+ @repository.add @test_package
17
+ @repository.count.should == 1
18
+ end
19
+
20
+ it 'should allow clearing' do
21
+ @repository.add @test_package
22
+ @repository.clear
23
+ @repository.count.should == 0
24
+ end
25
+
26
+ it "should find by provides" do
27
+ @repository.add @mysql_package
28
+ @repository.find_all("db").should == [ @mysql_package ]
29
+ end
30
+
31
+ it "should find by name" do
32
+ @repository.add @test_package
33
+ @repository.find_all("test").should == [ @test_package ]
34
+ end
35
+
36
+ it "should filter by version" do
37
+ @repository.add @test_package
38
+ @repository.add @test_v2_package
39
+ @repository.find_all("test").size.should == 2
40
+ @repository.first("test", :version => "2").should == @test_v2_package
41
+ end
42
+
43
+ after do
44
+ end
45
+
46
+ end
@@ -8,6 +8,10 @@ describe Sprinkle::Package do
8
8
  @empty = Proc.new { }
9
9
  @opts = { }
10
10
  end
11
+
12
+ after do
13
+ Sprinkle::Package::PACKAGES.clear
14
+ end
11
15
 
12
16
  # Kind of a messy way to do this but it works and DRYs out
13
17
  # the specs. Checks to make sure an installer is receiving
@@ -97,21 +101,16 @@ CODE
97
101
 
98
102
  it 'should be able to represent itself as a string' do
99
103
  pkg = package @name do; end
100
- pkg.to_s.should == @name
104
+ pkg.to_s.should == @name.to_s
101
105
  end
102
106
 
103
107
  end
104
108
 
105
109
  describe 'helper method' do
106
110
 
107
- it 'should added new packages to the global package hash' do
111
+ it 'should add new packages to the global package repository' do
108
112
  pkg = package @name do; end
109
- Sprinkle::Package::PACKAGES[@name].should == pkg
110
- end
111
-
112
- it 'should add the new package to the provides list if specified' do
113
- pkg = package @name, :provides => :database do; end
114
- Sprinkle::Package::PACKAGES[:database].last.should == pkg
113
+ Sprinkle::Package::PACKAGES.count.should == 1
115
114
  end
116
115
 
117
116
  end
@@ -457,7 +456,7 @@ CODE
457
456
  end
458
457
 
459
458
  it 'should select package for an array' do
460
- @a.should_receive(:select_package).with(:virtual, [@v1,@v2]).and_return(@v1)
459
+ Sprinkle::Package::Chooser.should_receive(:select_package).with(:virtual, [@v1,@v2]).and_return(@v1)
461
460
  @a.tree do; end
462
461
  end
463
462
  end
@@ -40,7 +40,7 @@ describe Sprinkle::Policy do
40
40
  p = policy @name, :roles => :app do; end
41
41
  p.requires :appserver, :version => 2
42
42
  p.packages.should == [ :appserver ]
43
- pending 'requires version checking implementation'
43
+ # pending 'requires version checking implementation'
44
44
  end
45
45
 
46
46
  it 'should add itself to the global policy list' do
@@ -100,30 +100,31 @@ describe Sprinkle::Policy do
100
100
 
101
101
  describe 'containing package dependencies with versions' do
102
102
 
103
- it 'should be invalid if the specified package does not exist' do
104
- pending
105
- end
106
- it 'should ignore any packages of the same name that have other versions' do
107
- pending
108
- end
109
103
  it 'should select the correct package version when applying' do
110
- pending
104
+ @my3 = package :mysql do; version 3; end
105
+ @my4 = package :mysql do; version 4; end
106
+ @my5 = package :mysql do; version 5; end
107
+ @e = package :e do; requires :mysql, :version => "4"; end
108
+ @policy.requires :e
109
+ @e.stub!(:instance).and_return @e
110
+ @my4.stub!(:instance).and_return @my4
111
+ @my3.should_not_receive(:process)
112
+ @my5.should_not_receive(:process)
113
+ @my4.should_receive(:process)
111
114
  end
112
-
113
115
  end
114
116
 
115
117
  describe 'containing virtual packages' do
116
118
 
117
119
  it 'should automatically select a concrete package implementation for a virtual one when there exists only one possible selection' do
118
120
  @policy = policy :virtual, :roles => :app do; requires :xyz; end
119
- Sprinkle::Package::PACKAGES[:xyz].should == [ @b ]
121
+ @b.should_receive(:process)
120
122
  end
121
123
 
122
124
  it 'should ask the user for the concrete package implementation to use for a virtual one when more than one possible choice exists' do
123
125
  @policy = policy :virtual, :roles => :app do; requires :abc; end
124
- Sprinkle::Package::PACKAGES[:abc].should include(@c)
125
- Sprinkle::Package::PACKAGES[:abc].should include(@d)
126
126
  $terminal.should_receive(:choose).and_return(:c)
127
+ @c.should_receive(:process)
127
128
  end
128
129
 
129
130
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: '0.7'
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Marcus Crafter
@@ -9,104 +10,118 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
13
+ date: 2013-06-19 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rspec
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - '>='
20
+ - - ! '>='
19
21
  - !ruby/object:Gem::Version
20
22
  version: '2.5'
21
23
  type: :development
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
- - - '>='
28
+ - - ! '>='
26
29
  - !ruby/object:Gem::Version
27
30
  version: '2.5'
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: rake
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
- - - '>='
36
+ - - ! '>='
33
37
  - !ruby/object:Gem::Version
34
38
  version: 0.8.7
35
39
  type: :development
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
- - - '>='
44
+ - - ! '>='
40
45
  - !ruby/object:Gem::Version
41
46
  version: 0.8.7
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: rdoc
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
- - - '>='
52
+ - - ! '>='
47
53
  - !ruby/object:Gem::Version
48
54
  version: '3.12'
49
55
  type: :development
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
52
59
  requirements:
53
- - - '>='
60
+ - - ! '>='
54
61
  - !ruby/object:Gem::Version
55
62
  version: '3.12'
56
63
  - !ruby/object:Gem::Dependency
57
64
  name: open4
58
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
59
67
  requirements:
60
- - - '>='
68
+ - - ! '>='
61
69
  - !ruby/object:Gem::Version
62
70
  version: 1.1.0
63
71
  type: :runtime
64
72
  prerelease: false
65
73
  version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
66
75
  requirements:
67
- - - '>='
76
+ - - ! '>='
68
77
  - !ruby/object:Gem::Version
69
78
  version: 1.1.0
70
79
  - !ruby/object:Gem::Dependency
71
80
  name: activesupport
72
81
  requirement: !ruby/object:Gem::Requirement
82
+ none: false
73
83
  requirements:
74
- - - '>='
84
+ - - ! '>='
75
85
  - !ruby/object:Gem::Version
76
86
  version: 2.0.2
77
87
  type: :runtime
78
88
  prerelease: false
79
89
  version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
80
91
  requirements:
81
- - - '>='
92
+ - - ! '>='
82
93
  - !ruby/object:Gem::Version
83
94
  version: 2.0.2
84
95
  - !ruby/object:Gem::Dependency
85
96
  name: highline
86
97
  requirement: !ruby/object:Gem::Requirement
98
+ none: false
87
99
  requirements:
88
- - - '>='
100
+ - - ! '>='
89
101
  - !ruby/object:Gem::Version
90
102
  version: 1.4.0
91
103
  type: :runtime
92
104
  prerelease: false
93
105
  version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
94
107
  requirements:
95
- - - '>='
108
+ - - ! '>='
96
109
  - !ruby/object:Gem::Version
97
110
  version: 1.4.0
98
111
  - !ruby/object:Gem::Dependency
99
112
  name: capistrano
100
113
  requirement: !ruby/object:Gem::Requirement
114
+ none: false
101
115
  requirements:
102
- - - '>='
116
+ - - ! '>='
103
117
  - !ruby/object:Gem::Version
104
118
  version: 2.5.5
105
119
  type: :runtime
106
120
  prerelease: false
107
121
  version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
108
123
  requirements:
109
- - - '>='
124
+ - - ! '>='
110
125
  - !ruby/object:Gem::Version
111
126
  version: 2.5.5
112
127
  description: Ruby DSL based software provisioning tool
@@ -129,6 +144,7 @@ files:
129
144
  - bin/sprinkle
130
145
  - examples/packages/build_essential.rb
131
146
  - examples/packages/databases/mysql.rb
147
+ - examples/packages/databases/mysql_source.rb
132
148
  - examples/packages/databases/sqlite3.rb
133
149
  - examples/packages/phusion.rb
134
150
  - examples/packages/ruby/rails.rb
@@ -195,6 +211,8 @@ files:
195
211
  - lib/sprinkle/installers/yum.rb
196
212
  - lib/sprinkle/installers/zypper.rb
197
213
  - lib/sprinkle/package.rb
214
+ - lib/sprinkle/package/chooser.rb
215
+ - lib/sprinkle/package/package_repository.rb
198
216
  - lib/sprinkle/policy.rb
199
217
  - lib/sprinkle/script.rb
200
218
  - lib/sprinkle/utility/log_recorder.rb
@@ -246,6 +264,7 @@ files:
246
264
  - spec/sprinkle/installers/user_spec.rb
247
265
  - spec/sprinkle/installers/yum_spec.rb
248
266
  - spec/sprinkle/installers/zypper_spec.rb
267
+ - spec/sprinkle/package/package_repository_spec.rb
249
268
  - spec/sprinkle/package_spec.rb
250
269
  - spec/sprinkle/policy_spec.rb
251
270
  - spec/sprinkle/script_spec.rb
@@ -255,26 +274,27 @@ files:
255
274
  homepage: https://github.com/sprinkle-tool/sprinkle
256
275
  licenses:
257
276
  - MIT
258
- metadata: {}
259
277
  post_install_message:
260
278
  rdoc_options: []
261
279
  require_paths:
262
280
  - lib
263
281
  required_ruby_version: !ruby/object:Gem::Requirement
282
+ none: false
264
283
  requirements:
265
- - - '>='
284
+ - - ! '>='
266
285
  - !ruby/object:Gem::Version
267
286
  version: '0'
268
287
  required_rubygems_version: !ruby/object:Gem::Requirement
288
+ none: false
269
289
  requirements:
270
- - - '>='
290
+ - - ! '>='
271
291
  - !ruby/object:Gem::Version
272
292
  version: '0'
273
293
  requirements: []
274
294
  rubyforge_project: sprinkle
275
- rubygems_version: 2.0.2
295
+ rubygems_version: 1.8.23
276
296
  signing_key:
277
- specification_version: 4
297
+ specification_version: 3
278
298
  summary: Ruby DSL based software provisioning tool
279
299
  test_files:
280
300
  - spec/fixtures/my_file.txt
@@ -311,6 +331,7 @@ test_files:
311
331
  - spec/sprinkle/installers/user_spec.rb
312
332
  - spec/sprinkle/installers/yum_spec.rb
313
333
  - spec/sprinkle/installers/zypper_spec.rb
334
+ - spec/sprinkle/package/package_repository_spec.rb
314
335
  - spec/sprinkle/package_spec.rb
315
336
  - spec/sprinkle/policy_spec.rb
316
337
  - spec/sprinkle/script_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 0f1d6725ca74e75f617bcc041b6cfa9479e42cda
4
- data.tar.gz: 350bc1e155ea7094583102db987f3b6faa282306
5
- SHA512:
6
- metadata.gz: 9be3e0863b8e304adef43e50a097b96c1aaf1c722dbc8da97d67a2c89b690ce88e3b6a5d7e2b3277dee57215e75ebe5efc6fed603c994693ba8f7c18484724fc
7
- data.tar.gz: c20aa43749c3d10ccbc0659072e38fa286db9b87f71033af1bbd2199074751c57cff319b0905e75049c6fc8c0484e303dba0037c21d4dc121aafa5dcf04d14e8