sprinkle 0.2.6 → 0.3.0

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.
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::Noop do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'spec')
7
+ end
8
+
9
+ def create_noop(names, options = {}, &block)
10
+ Sprinkle::Installers::Noop.new(@package, options, &block)
11
+ end
12
+
13
+ describe 'during installation' do
14
+
15
+ it 'should always be empty' do
16
+ @installer = create_noop 'spec'
17
+ @install_commands = @installer.send :install_commands
18
+ @install_commands.should == 'echo noop'
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -25,6 +25,8 @@ describe Sprinkle::Installers::Source do
25
25
 
26
26
  with %w( debug extras )
27
27
  without %w( fancyisms )
28
+
29
+ option %w( foo bar baz )
28
30
  end
29
31
 
30
32
  @installer.defaults(@deployment)
@@ -86,6 +88,10 @@ describe Sprinkle::Installers::Source do
86
88
  @installer.without.should == %w( fancyisms )
87
89
  end
88
90
 
91
+ it 'should support specification of "option" options' do
92
+ @installer.option.should == %w( foo bar baz )
93
+ end
94
+
89
95
  it 'should support customized build area' do
90
96
  @installer.prefix.should == '/usr/local'
91
97
  end
@@ -341,5 +347,25 @@ describe Sprinkle::Installers::Source do
341
347
  end
342
348
 
343
349
  end
350
+
351
+ describe 'base dir calculation' do
352
+
353
+ %w( tar tar.gz tgz tar.bz2 tb2 zip ).each do |archive|
354
+
355
+ it "should recognize #{archive} style archives" do
356
+ @installer.source = "blah.#{archive}"
357
+ @installer.send(:base_dir).should == 'blah'
358
+ end
359
+
360
+ end
361
+
362
+ # def base_dir #:nodoc:
363
+ # if archive_name.split('/').last =~ /(.*)\.(tar\.gz|tgz|tar\.bz2|tar|tb2)/
364
+ # return $1
365
+ # end
366
+ # raise "Unknown base path for source archive: #{@source}, please update code knowledge"
367
+ # end
368
+
369
+ end
344
370
 
345
371
  end
@@ -0,0 +1,98 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'tempfile'
3
+
4
+ describe Sprinkle::Installers::Transfer do
5
+ include Sprinkle::Deployment
6
+
7
+ before do
8
+ @package = mock(Sprinkle::Package, :name => 'package')
9
+ @empty = Proc.new { }
10
+ @delivery = mock(Sprinkle::Deployment, :process => true)
11
+ @source = 'source'
12
+ @destination = 'destination'
13
+ @installer = create_transfer(@source, @destination)
14
+ @roles = []
15
+ @deployment = deployment do
16
+ delivery :capistrano
17
+ installer do; prefix '/usr/bin'; end
18
+ end
19
+ end
20
+
21
+ def create_transfer(source, dest, options={}, &block)
22
+ i = Sprinkle::Installers::Transfer.new(@package, source, dest, options, &block)
23
+ i.delivery = @delivery
24
+ i
25
+ end
26
+
27
+ describe 'when created' do
28
+ it 'should accept a source and destination to install' do
29
+ @installer.source.should == @source
30
+ @installer.destination.should == @destination
31
+ end
32
+ end
33
+
34
+ describe 'during installation' do
35
+ before do
36
+ @installer = create_transfer @source, @destination do
37
+ pre :install, 'op1'
38
+ post :install, 'op2'
39
+ end
40
+
41
+ @delivery = @installer.delivery
42
+ end
43
+
44
+ it "should call the pre and post install commands around the file transfer" do
45
+ @delivery.should_receive(:process).with(@package.name, 'op1', @roles).once.ordered.and_return
46
+ @delivery.should_receive(:transfer).ordered.and_return
47
+ @delivery.should_receive(:process).with(@package.name, 'op2', @roles).once.ordered.and_return
48
+ end
49
+
50
+ it "should call transfer with recursive defaulted to nil" do
51
+ @delivery.should_receive(:process).and_return
52
+ @delivery.should_receive(:transfer).with(@package.name, @source, @destination, @roles, nil)
53
+ end
54
+
55
+ after do
56
+ @installer.process @roles
57
+ end
58
+ end
59
+
60
+ describe "if the :render flag is true" do
61
+ before do
62
+ @installer = create_transfer @source, @destination, :render => true
63
+ @delivery = @installer.delivery
64
+ @delivery.stub!(:render_template_file)
65
+ end
66
+
67
+ it "should render the source file as a template to a tempfile" do
68
+ @tempfile = Tempfile.new("foo")
69
+ @installer.should_receive(:render_template_file).with(@source, anything, @package.name).and_return(@tempfile)
70
+ @delivery.stub!(:transfer)
71
+ end
72
+
73
+ it "should call transfer with recursive set to false" do
74
+ @tempfile = Tempfile.new("foo")
75
+ @installer.should_receive(:render_template_file).with(@source, anything, @package.name).and_return(@tempfile)
76
+ @delivery.should_receive(:transfer).with(@package.name, @tempfile.path, @destination, @roles, false).ordered.and_return
77
+ end
78
+
79
+ after do
80
+ @installer.process @roles
81
+ end
82
+ end
83
+
84
+ describe "if the :recursive flag is explicitly set to false" do
85
+ before do
86
+ @installer = create_transfer @source, @destination, :recursive => false
87
+ end
88
+
89
+ it "should call transfer with recursive set to false" do
90
+ delivery = @installer.delivery
91
+ delivery.should_receive(:transfer).with(@package.name, @source, @destination, @roles, false).ordered.and_return
92
+ end
93
+
94
+ after do
95
+ @installer.process @roles
96
+ end
97
+ end
98
+ end
@@ -22,7 +22,7 @@ describe Sprinkle::Package do
22
22
  end
23
23
  end
24
24
 
25
- pre_count = pkg.installer.instance_variable_get(:@pre)[:install].length
25
+ pre_count = pkg.installers.first.instance_variable_get(:@pre)[:install].length
26
26
  }.should change { pre_count }.by(1)
27
27
  CODE
28
28
  end
@@ -66,7 +66,7 @@ CODE
66
66
  pkg = package @name do
67
67
  gem 'rails'
68
68
  end
69
- pkg.installer.should_not be_nil
69
+ pkg.installers.should_not be_empty
70
70
  end
71
71
 
72
72
  it 'should optionally accept dependencies' do
@@ -123,7 +123,7 @@ CODE
123
123
  apt %w( deb1 deb2 )
124
124
  end
125
125
  pkg.should respond_to(:apt)
126
- pkg.installer.class.should == Sprinkle::Installers::Apt
126
+ pkg.installers.first.class.should == Sprinkle::Installers::Apt
127
127
  end
128
128
 
129
129
  it 'should optionally accept an rpm installer' do
@@ -131,7 +131,7 @@ CODE
131
131
  rpm %w( rpm1 rpm2 )
132
132
  end
133
133
  pkg.should respond_to(:rpm)
134
- pkg.installer.class.should == Sprinkle::Installers::Rpm
134
+ pkg.installers.first.class.should == Sprinkle::Installers::Rpm
135
135
  end
136
136
 
137
137
  it 'should optionally accept a gem installer' do
@@ -139,7 +139,7 @@ CODE
139
139
  gem 'gem'
140
140
  end
141
141
  pkg.should respond_to(:gem)
142
- pkg.installer.class.should == Sprinkle::Installers::Gem
142
+ pkg.installers.first.class.should == Sprinkle::Installers::Gem
143
143
  end
144
144
 
145
145
  it 'should optionally accept a source installer' do
@@ -147,9 +147,19 @@ CODE
147
147
  source 'archive'
148
148
  end
149
149
  pkg.should respond_to(:source)
150
- pkg.installer.class.should == Sprinkle::Installers::Source
150
+ pkg.installers.first.class.should == Sprinkle::Installers::Source
151
151
  end
152
152
 
153
+ it 'should allow multiple installer steps to be defined and respect order' do
154
+ pkg = package @name do
155
+ source 'archive'
156
+ gem 'momoney'
157
+ end
158
+
159
+ pkg.installers.length.should == 2
160
+ pkg.installers[0].class.should == Sprinkle::Installers::Source
161
+ pkg.installers[1].class.should == Sprinkle::Installers::Gem
162
+ end
153
163
  end
154
164
 
155
165
  describe 'with a source installer' do
@@ -159,7 +169,7 @@ CODE
159
169
  source 'archive' do; end
160
170
  end
161
171
  pkg.should respond_to(:source)
162
- pkg.installer.class.should == Sprinkle::Installers::Source
172
+ pkg.installers.first.class.should == Sprinkle::Installers::Source
163
173
  end
164
174
 
165
175
  it 'should forward block to installer superclass' do
@@ -214,7 +224,7 @@ CODE
214
224
  describe 'with an installer' do
215
225
 
216
226
  before do
217
- @package.installer = @installer
227
+ @package.installers = [ @installer ]
218
228
  end
219
229
 
220
230
  it 'should configure itself against the deployment context' do
@@ -242,7 +252,7 @@ CODE
242
252
  describe 'with verifications' do
243
253
  before do
244
254
  @pkg = create_package_with_blank_verify(3)
245
- @pkg.installer = @installer
255
+ @pkg.installers = [ @installer ]
246
256
  @installer.stub!(:defaults)
247
257
  @installer.stub!(:process)
248
258
  end
@@ -303,7 +313,7 @@ CODE
303
313
  @roles = [ :app, :db ]
304
314
  @installer = mock(Sprinkle::Installers::Installer, :defaults => true, :process => true)
305
315
  @pkg = create_package_with_blank_verify(3)
306
- @pkg.installer = @installer
316
+ @pkg.installers = [ @installer ]
307
317
  @installer.stub!(:defaults)
308
318
  @installer.stub!(:process)
309
319
  @logger = mock(ActiveSupport::BufferedLogger, :debug => true, :debug? => true)
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Sprinkle::Sequence do
4
+
5
+ before do
6
+ @sequence = Sprinkle::Sequence.new do
7
+ section1 do
8
+ 'command1'
9
+ end
10
+
11
+ section2 do
12
+ 'command2'
13
+ end
14
+ end
15
+ end
16
+
17
+ describe 'during initialization' do
18
+
19
+ it 'should yield the block, storing all section definitions provided' do
20
+ @sequence.stages.size.should == 2
21
+ end
22
+
23
+ end
24
+
25
+ describe 'during iteration' do
26
+
27
+ before do
28
+ @stages = { }
29
+ @sequence.each do |stage, commands|
30
+ @stages[stage] = commands
31
+ end
32
+ end
33
+
34
+ it 'should yield to a given block with the stage and commands for that stage' do
35
+ @stages.size.should == 2
36
+ @stages.keys.should include(:section1)
37
+ @stages[:section1].should == 'command1'
38
+ @stages.keys.should include(:section2)
39
+ @stages[:section2].should == 'command2'
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -36,6 +36,9 @@ describe Sprinkle::Verify do
36
36
  # Check that a gem exists
37
37
  has_gem 'rails'
38
38
  has_gem 'rails', '2.1.0'
39
+
40
+ # Check for a certain RPM package
41
+ has_rpm 'ntp'
39
42
  end
40
43
  end
41
44
  @verification = @package.verifications[0]
@@ -90,6 +93,10 @@ describe Sprinkle::Verify do
90
93
  @verification.commands.should include("sudo gem list | grep -e '^rails (.*.*)$'")
91
94
  @verification.commands.should include("sudo gem list | grep -e '^rails (.*2\\.1\\.0.*)$'")
92
95
  end
96
+
97
+ it 'should check that an RPM is installed' do
98
+ @verification.commands.should include("rpm -qa | grep ntp")
99
+ end
93
100
  end
94
101
 
95
102
  describe 'with configurations' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -9,69 +9,66 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 +10:00
13
- default_executable:
12
+ date: 2009-12-12 00:00:00 +13:00
13
+ default_executable: sprinkle
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: activesupport
17
- type: :runtime
16
+ name: rspec
17
+ type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.0.2
23
+ version: 1.2.9
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: highline
26
+ name: activesupport
27
27
  type: :runtime
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.4.0
33
+ version: 2.0.2
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
- name: capistrano
36
+ name: highline
37
37
  type: :runtime
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 2.5.5
43
+ version: 1.4.0
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
- name: hoe
47
- type: :development
46
+ name: capistrano
47
+ type: :runtime
48
48
  version_requirement:
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 2.3.2
53
+ version: 2.5.5
54
54
  version:
55
55
  description: Ruby DSL based software provisioning tool
56
- email:
57
- - crafterm@redartisan.com
56
+ email: crafterm@redartisan.com
58
57
  executables:
59
58
  - sprinkle
60
59
  extensions: []
61
60
 
62
61
  extra_rdoc_files:
63
- - History.txt
64
- - Manifest.txt
62
+ - README.markdown
63
+ - TODO
65
64
  files:
65
+ - .gitignore
66
66
  - CREDITS
67
- - History.txt
68
67
  - MIT-LICENSE
69
- - Manifest.txt
70
68
  - README.markdown
71
69
  - Rakefile
70
+ - VERSION
72
71
  - bin/sprinkle
73
- - config/hoe.rb
74
- - config/requirements.rb
75
72
  - examples/packages/build_essential.rb
76
73
  - examples/packages/databases/mysql.rb
77
74
  - examples/packages/databases/sqlite3.rb
@@ -107,13 +104,15 @@ files:
107
104
  - lib/sprinkle/extensions/string.rb
108
105
  - lib/sprinkle/extensions/symbol.rb
109
106
  - lib/sprinkle/installers/apt.rb
110
- - lib/sprinkle/installers/noop.rb
107
+ - lib/sprinkle/installers/binary.rb
111
108
  - lib/sprinkle/installers/bsd_port.rb
112
109
  - lib/sprinkle/installers/deb.rb
113
110
  - lib/sprinkle/installers/freebsd_pkg.rb
111
+ - lib/sprinkle/installers/freebsd_portinstall.rb
114
112
  - lib/sprinkle/installers/gem.rb
115
113
  - lib/sprinkle/installers/installer.rb
116
114
  - lib/sprinkle/installers/mac_port.rb
115
+ - lib/sprinkle/installers/noop.rb
117
116
  - lib/sprinkle/installers/openbsd_pkg.rb
118
117
  - lib/sprinkle/installers/opensolaris_pkg.rb
119
118
  - lib/sprinkle/installers/push_text.rb
@@ -129,10 +128,11 @@ files:
129
128
  - lib/sprinkle/verifiers/executable.rb
130
129
  - lib/sprinkle/verifiers/file.rb
131
130
  - lib/sprinkle/verifiers/process.rb
131
+ - lib/sprinkle/verifiers/rpm.rb
132
132
  - lib/sprinkle/verifiers/ruby.rb
133
133
  - lib/sprinkle/verifiers/symlink.rb
134
134
  - lib/sprinkle/verify.rb
135
- - lib/sprinkle/version.rb
135
+ - script/console
136
136
  - script/destroy
137
137
  - script/generate
138
138
  - spec/spec.opts
@@ -146,33 +146,32 @@ files:
146
146
  - spec/sprinkle/installers/apt_spec.rb
147
147
  - spec/sprinkle/installers/bsd_port_spec.rb
148
148
  - spec/sprinkle/installers/freebsd_pkg_spec.rb
149
+ - spec/sprinkle/installers/freebsd_portinstall_spec.rb
149
150
  - spec/sprinkle/installers/gem_spec.rb
150
151
  - spec/sprinkle/installers/installer_spec.rb
151
152
  - spec/sprinkle/installers/mac_port_spec.rb
153
+ - spec/sprinkle/installers/noop_spec.rb
152
154
  - spec/sprinkle/installers/openbsd_pkg_spec.rb
153
155
  - spec/sprinkle/installers/opensolaris_pkg_spec.rb
154
156
  - spec/sprinkle/installers/push_text_spec.rb
155
157
  - spec/sprinkle/installers/rake_spec.rb
156
158
  - spec/sprinkle/installers/rpm_spec.rb
157
159
  - spec/sprinkle/installers/source_spec.rb
160
+ - spec/sprinkle/installers/transfer_spec.rb
158
161
  - spec/sprinkle/installers/yum_spec.rb
159
162
  - spec/sprinkle/package_spec.rb
160
163
  - spec/sprinkle/policy_spec.rb
161
164
  - spec/sprinkle/script_spec.rb
162
165
  - spec/sprinkle/sprinkle_spec.rb
163
166
  - spec/sprinkle/verify_spec.rb
164
- - sprinkle.gemspec
165
- - tasks/deployment.rake
166
- - tasks/environment.rake
167
- - tasks/rspec.rake
167
+ - TODO
168
168
  has_rdoc: true
169
- homepage: http://sprinkle.rubyforge.org
169
+ homepage: http://github.com/crafterm/sprinkle
170
170
  licenses: []
171
171
 
172
172
  post_install_message:
173
173
  rdoc_options:
174
- - --main
175
- - README.txt
174
+ - --charset=UTF-8
176
175
  require_paths:
177
176
  - lib
178
177
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -190,9 +189,56 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
189
  requirements: []
191
190
 
192
191
  rubyforge_project: sprinkle
193
- rubygems_version: 1.3.4
192
+ rubygems_version: 1.3.5
194
193
  signing_key:
195
194
  specification_version: 3
196
195
  summary: Ruby DSL based software provisioning tool
197
- test_files: []
198
-
196
+ test_files:
197
+ - spec/spec_helper.rb
198
+ - spec/sprinkle/actors/capistrano_spec.rb
199
+ - spec/sprinkle/actors/local_spec.rb
200
+ - spec/sprinkle/configurable_spec.rb
201
+ - spec/sprinkle/deployment_spec.rb
202
+ - spec/sprinkle/extensions/array_spec.rb
203
+ - spec/sprinkle/extensions/string_spec.rb
204
+ - spec/sprinkle/installers/apt_spec.rb
205
+ - spec/sprinkle/installers/bsd_port_spec.rb
206
+ - spec/sprinkle/installers/freebsd_pkg_spec.rb
207
+ - spec/sprinkle/installers/freebsd_portinstall_spec.rb
208
+ - spec/sprinkle/installers/gem_spec.rb
209
+ - spec/sprinkle/installers/installer_spec.rb
210
+ - spec/sprinkle/installers/mac_port_spec.rb
211
+ - spec/sprinkle/installers/noop_spec.rb
212
+ - spec/sprinkle/installers/openbsd_pkg_spec.rb
213
+ - spec/sprinkle/installers/opensolaris_pkg_spec.rb
214
+ - spec/sprinkle/installers/push_text_spec.rb
215
+ - spec/sprinkle/installers/rake_spec.rb
216
+ - spec/sprinkle/installers/rpm_spec.rb
217
+ - spec/sprinkle/installers/source_spec.rb
218
+ - spec/sprinkle/installers/transfer_spec.rb
219
+ - spec/sprinkle/installers/yum_spec.rb
220
+ - spec/sprinkle/package_spec.rb
221
+ - spec/sprinkle/policy_spec.rb
222
+ - spec/sprinkle/script_spec.rb
223
+ - spec/sprinkle/sequence_spec.rb
224
+ - spec/sprinkle/sprinkle_spec.rb
225
+ - spec/sprinkle/verify_spec.rb
226
+ - examples/packages/build_essential.rb
227
+ - examples/packages/databases/mysql.rb
228
+ - examples/packages/databases/sqlite3.rb
229
+ - examples/packages/phusion.rb
230
+ - examples/packages/ruby/rails.rb
231
+ - examples/packages/ruby/ruby.rb
232
+ - examples/packages/ruby/rubygems.rb
233
+ - examples/packages/scm/git.rb
234
+ - examples/packages/scm/subversion.rb
235
+ - examples/packages/servers/apache.rb
236
+ - examples/rails/deploy.rb
237
+ - examples/rails/packages/database.rb
238
+ - examples/rails/packages/essential.rb
239
+ - examples/rails/packages/rails.rb
240
+ - examples/rails/packages/scm.rb
241
+ - examples/rails/packages/search.rb
242
+ - examples/rails/packages/server.rb
243
+ - examples/rails/rails.rb
244
+ - examples/sprinkle/sprinkle.rb