sprinkle 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,18 +42,19 @@ lib/sprinkle/extensions/dsl_accessor.rb
42
42
  lib/sprinkle/extensions/string.rb
43
43
  lib/sprinkle/extensions/symbol.rb
44
44
  lib/sprinkle/installers/apt.rb
45
+ lib/sprinkle/installers/bsd_port.rb
45
46
  lib/sprinkle/installers/deb.rb
47
+ lib/sprinkle/installers/freebsd_pkg.rb
46
48
  lib/sprinkle/installers/gem.rb
47
49
  lib/sprinkle/installers/installer.rb
50
+ lib/sprinkle/installers/mac_port.rb
51
+ lib/sprinkle/installers/openbsd_pkg.rb
52
+ lib/sprinkle/installers/opensolaris_pkg.rb
53
+ lib/sprinkle/installers/push_text.rb
48
54
  lib/sprinkle/installers/rake.rb
49
55
  lib/sprinkle/installers/rpm.rb
50
56
  lib/sprinkle/installers/source.rb
51
57
  lib/sprinkle/installers/yum.rb
52
- lib/sprinkle/installers/freebsd_pkg.rb
53
- lib/sprinkle/installers/openbsd_pkg.rb
54
- lib/sprinkle/installers/opensolaris_pkg.rb
55
- lib/sprinkle/installers/bsd_port.rb
56
- lib/sprinkle/installers/mac_port.rb
57
58
  lib/sprinkle/package.rb
58
59
  lib/sprinkle/policy.rb
59
60
  lib/sprinkle/script.rb
@@ -76,15 +77,18 @@ spec/sprinkle/deployment_spec.rb
76
77
  spec/sprinkle/extensions/array_spec.rb
77
78
  spec/sprinkle/extensions/string_spec.rb
78
79
  spec/sprinkle/installers/apt_spec.rb
80
+ spec/sprinkle/installers/bsd_port_spec.rb
81
+ spec/sprinkle/installers/freebsd_pkg_spec.rb
79
82
  spec/sprinkle/installers/gem_spec.rb
80
83
  spec/sprinkle/installers/installer_spec.rb
84
+ spec/sprinkle/installers/mac_port_spec.rb
85
+ spec/sprinkle/installers/openbsd_pkg_spec.rb
86
+ spec/sprinkle/installers/opensolaris_pkg_spec.rb
87
+ spec/sprinkle/installers/push_text_spec.rb
88
+ spec/sprinkle/installers/rake_spec.rb
81
89
  spec/sprinkle/installers/rpm_spec.rb
82
- spec/sprinkle/installers/yum_spec.rb
83
90
  spec/sprinkle/installers/source_spec.rb
84
- spec/sprinkle/installers/openbsd_pkg_spec.rb
85
- spec/sprinkle/installers/freebsd_pkg_spec.rb
86
- spec/sprinkle/installers/bsd_port_spec.rb
87
- spec/sprinkle/installers/mac_port_spec.rb
91
+ spec/sprinkle/installers/yum_spec.rb
88
92
  spec/sprinkle/package_spec.rb
89
93
  spec/sprinkle/policy_spec.rb
90
94
  spec/sprinkle/script_spec.rb
@@ -0,0 +1,45 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # Beware, strange "installer" coming your way.
4
+ #
5
+ # = Text configuration installer
6
+ #
7
+ # This installer pushes simple configuration into a file.
8
+ #
9
+ # == Example Usage
10
+ #
11
+ # Installing magic_beans into apache2.conf
12
+ #
13
+ # package :magic_beans do
14
+ # push_text 'magic_beans', '/etc/apache2/apache2.conf'
15
+ # end
16
+ #
17
+ # If you user has access to 'sudo' and theres a file that requires
18
+ # priveledges, you can pass :sudo => true
19
+ #
20
+ # package :magic_beans do
21
+ # push_text 'magic_beans', '/etc/apache2/apache2.conf', :sudo => true
22
+ # end
23
+ #
24
+ # A special verify step exists for this very installer
25
+ # its known as file_contains, it will test that a file indeed
26
+ # contains a substring that you send it.
27
+ #
28
+ class PushText < Installer
29
+ attr_accessor :text, :path #:nodoc:
30
+
31
+ def initialize(parent, text, path, options={}, &block) #:nodoc:
32
+ super parent, options, &block
33
+ @text = text
34
+ @path = path
35
+ end
36
+
37
+ protected
38
+
39
+ def install_commands #:nodoc:
40
+ "echo '#{@text}' |#{'sudo' if option?(:sudo)} tee -a #{@path}"
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -237,6 +237,8 @@ module Sprinkle
237
237
 
238
238
  @dependencies.each do |dep|
239
239
  package = PACKAGES[dep]
240
+ package = select_package(dep, package) if package.is_a? Array
241
+
240
242
  raise "Package definition not found for key: #{dep}" unless package
241
243
  block.call(self, package, depth) if block
242
244
  packages << package.tree(depth + 1, &block)
@@ -249,6 +251,22 @@ module Sprinkle
249
251
 
250
252
  private
251
253
 
254
+ def select_package(name, packages)
255
+ if packages.size <= 1
256
+ package = packages.first
257
+ else
258
+ package = choose do |menu|
259
+ menu.prompt = "Multiple choices exist for virtual package #{name}"
260
+ menu.choices *packages.collect(&:to_s)
261
+ end
262
+ package = Sprinkle::Package::PACKAGES[package]
263
+ end
264
+
265
+ cloud_info "Selecting #{package.to_s} for virtual package #{name}"
266
+
267
+ package
268
+ end
269
+
252
270
  def meta_package?
253
271
  @installer == nil
254
272
  end
@@ -2,7 +2,7 @@ module Sprinkle #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::OpensolarisPkg do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_pkg(pkgs, &block)
10
+ Sprinkle::Installers::OpensolarisPkg.new(@package, pkgs, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_pkg 'ruby'
17
+ @installer.packages.should == [ 'ruby' ]
18
+ end
19
+
20
+ it 'should accept an array of packages to install' do
21
+ @installer = create_pkg %w( gcc gdb g++ )
22
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
23
+ end
24
+
25
+ end
26
+
27
+ describe 'during installation' do
28
+
29
+ before do
30
+ @installer = create_pkg 'ruby' do
31
+ pre :install, 'op1'
32
+ post :install, 'op2'
33
+ end
34
+ @install_commands = @installer.send :install_commands
35
+ end
36
+
37
+ it 'should invoke the freebsd_pkg installer for all specified packages' do
38
+ @install_commands.should =~ /pkg install ruby/
39
+ end
40
+
41
+ it 'should automatically insert pre/post commands for the specified package' do
42
+ @installer.send(:install_sequence).should == [ 'op1', 'pkg install ruby', 'op2' ]
43
+ end
44
+
45
+ it 'should install a specific version if defined'
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,55 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::PushText do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ @options = {:sudo => true}
8
+ end
9
+
10
+ def create_text(text, path, options={}, &block)
11
+ Sprinkle::Installers::PushText.new(@package, text, path, options, &block)
12
+ end
13
+
14
+ describe 'when created' do
15
+
16
+ it 'should accept a single package to install' do
17
+ @installer = create_text 'crazy-configuration-methods', '/etc/doomed/file.conf'
18
+ @installer.text.should == 'crazy-configuration-methods'
19
+ @installer.path.should == '/etc/doomed/file.conf'
20
+ end
21
+
22
+ end
23
+
24
+ describe 'during installation' do
25
+
26
+ before do
27
+ @installer = create_text 'another-hair-brained-idea', '/dev/mind/late-night' do
28
+ pre :install, 'op1'
29
+ post :install, 'op2'
30
+ end
31
+ @install_commands = @installer.send :install_commands
32
+ end
33
+
34
+ it 'should invoke the push text installer for all specified packages' do
35
+ @install_commands.should =~ /echo 'another-hair-brained-idea' | tee -a \/dev\/mind\/late-night/
36
+ end
37
+
38
+ it 'should automatically insert pre/post commands for the specified package' do
39
+ @installer.send(:install_sequence).should == [ 'op1', "echo 'another-hair-brained-idea' | tee -a /dev/mind/late-night", 'op2' ]
40
+ end
41
+
42
+ end
43
+
44
+ describe 'running with sudo' do
45
+ before do
46
+ @installer = create_text "I'm a special user", "/dev/mind/the-day-after", :sudo => true
47
+ @install_commands = @installer.send :install_commands
48
+ end
49
+
50
+ it "should invoke the push installer with sudo" do
51
+ @install_commands.should =~ /echo 'I\'m a special user' | sudo tee -a \/dev\/mind\/the-day-after/
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::Rake do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'spec')
7
+ end
8
+
9
+ def create_rake(names, options = {}, &block)
10
+ Sprinkle::Installers::Rake.new(@package, names, options, &block)
11
+ end
12
+
13
+ describe 'during installation' do
14
+
15
+ it 'should invoke the rake executer for all specified tasks' do
16
+ @installer = create_rake 'spec'
17
+ @install_commands = @installer.send :install_commands
18
+ @install_commands.should =~ /rake spec/
19
+ end
20
+
21
+ it 'should invoke the rake executer for all specified tasks' do
22
+ @installer = create_rake 'spec', :rakefile => '/some/Rakefile'
23
+ @install_commands = @installer.send :install_commands
24
+ @install_commands.should == "rake -f /some/Rakefile spec"
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -374,6 +374,19 @@ CODE
374
374
 
375
375
  end
376
376
 
377
+ describe 'virtual package dependencies' do
378
+ before do
379
+ @a = package :a do; requires :virtual ; end
380
+ @v1 = package :v1, :provides => :virtual do; end
381
+ @v2 = package :v2, :provides => :virtual do; end
382
+ end
383
+
384
+ it 'should select package for an array' do
385
+ @a.should_receive(:select_package).with(:virtual, [@v1,@v2]).and_return(@v1)
386
+ @a.tree do; end
387
+ end
388
+ end
389
+
377
390
  describe 'with missing dependencies' do
378
391
 
379
392
  before do
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{sprinkle}
3
- s.version = "0.2.1"
3
+ s.version = "0.2.2"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Marcus Crafter", "Mitchell Hashimoto"]
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-05 00:00:00 +11:00
12
+ date: 2009-03-11 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -108,18 +108,19 @@ files:
108
108
  - lib/sprinkle/extensions/string.rb
109
109
  - lib/sprinkle/extensions/symbol.rb
110
110
  - lib/sprinkle/installers/apt.rb
111
+ - lib/sprinkle/installers/bsd_port.rb
111
112
  - lib/sprinkle/installers/deb.rb
113
+ - lib/sprinkle/installers/freebsd_pkg.rb
112
114
  - lib/sprinkle/installers/gem.rb
113
115
  - lib/sprinkle/installers/installer.rb
116
+ - lib/sprinkle/installers/mac_port.rb
117
+ - lib/sprinkle/installers/openbsd_pkg.rb
118
+ - lib/sprinkle/installers/opensolaris_pkg.rb
119
+ - lib/sprinkle/installers/push_text.rb
114
120
  - lib/sprinkle/installers/rake.rb
115
121
  - lib/sprinkle/installers/rpm.rb
116
122
  - lib/sprinkle/installers/source.rb
117
123
  - lib/sprinkle/installers/yum.rb
118
- - lib/sprinkle/installers/freebsd_pkg.rb
119
- - lib/sprinkle/installers/openbsd_pkg.rb
120
- - lib/sprinkle/installers/opensolaris_pkg.rb
121
- - lib/sprinkle/installers/bsd_port.rb
122
- - lib/sprinkle/installers/mac_port.rb
123
124
  - lib/sprinkle/package.rb
124
125
  - lib/sprinkle/policy.rb
125
126
  - lib/sprinkle/script.rb
@@ -142,15 +143,18 @@ files:
142
143
  - spec/sprinkle/extensions/array_spec.rb
143
144
  - spec/sprinkle/extensions/string_spec.rb
144
145
  - spec/sprinkle/installers/apt_spec.rb
146
+ - spec/sprinkle/installers/bsd_port_spec.rb
147
+ - spec/sprinkle/installers/freebsd_pkg_spec.rb
145
148
  - spec/sprinkle/installers/gem_spec.rb
146
149
  - spec/sprinkle/installers/installer_spec.rb
150
+ - spec/sprinkle/installers/mac_port_spec.rb
151
+ - spec/sprinkle/installers/openbsd_pkg_spec.rb
152
+ - spec/sprinkle/installers/opensolaris_pkg_spec.rb
153
+ - spec/sprinkle/installers/push_text_spec.rb
154
+ - spec/sprinkle/installers/rake_spec.rb
147
155
  - spec/sprinkle/installers/rpm_spec.rb
148
- - spec/sprinkle/installers/yum_spec.rb
149
156
  - spec/sprinkle/installers/source_spec.rb
150
- - spec/sprinkle/installers/openbsd_pkg_spec.rb
151
- - spec/sprinkle/installers/freebsd_pkg_spec.rb
152
- - spec/sprinkle/installers/bsd_port_spec.rb
153
- - spec/sprinkle/installers/mac_port_spec.rb
157
+ - spec/sprinkle/installers/yum_spec.rb
154
158
  - spec/sprinkle/package_spec.rb
155
159
  - spec/sprinkle/policy_spec.rb
156
160
  - spec/sprinkle/script_spec.rb