trevorturk-sprinkle 0.2.2 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/CREDITS CHANGED
@@ -1,7 +1,7 @@
1
1
  = CREDITS
2
2
 
3
3
  Many thanks to the following people who have submitted ideas, patches, helped with testing
4
- and/or generally provided support to Sprinke, I really appreciate your help:
4
+ and/or generally provided support to Sprinkle, I really appreciate your help:
5
5
 
6
6
  Kristin Baumann (http://crafterm.net/kristin/blog/)
7
7
  Ben Schwarz (http://germanforblack.com/)
@@ -20,3 +20,10 @@ Joshua Sierles (http://diluvia.net)
20
20
  Julian Russell (http://github.com/plusplus)
21
21
  Dave (Gassto) (http://github.com/gassto)
22
22
  Bodaniel Jeanes (http://bjeanes.github.com)
23
+ Jacob Harris (http://open.nytimes.com)
24
+ Justin Pease (http://jit.nuance9.com)
25
+ Tobias Lütke (http://blog.leetsoft.com)
26
+ Josh Reynolds (http://github.com/jreynolds)
27
+ Jan Ulbrich (http://www.ulbrich.net)
28
+
29
+ The transfer installer contains a piece of exception reporting code copied from the Chef library (http://wiki.opscode.com/display/chef/Home)
data/Manifest.txt CHANGED
@@ -2,7 +2,7 @@ CREDITS
2
2
  History.txt
3
3
  MIT-LICENSE
4
4
  Manifest.txt
5
- README.txt
5
+ README.markdown
6
6
  Rakefile
7
7
  bin/sprinkle
8
8
  config/hoe.rb
@@ -42,20 +42,26 @@ 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/noop.rb
45
46
  lib/sprinkle/installers/bsd_port.rb
46
47
  lib/sprinkle/installers/deb.rb
47
48
  lib/sprinkle/installers/freebsd_pkg.rb
48
49
  lib/sprinkle/installers/gem.rb
49
50
  lib/sprinkle/installers/installer.rb
50
51
  lib/sprinkle/installers/mac_port.rb
51
- lib/sprinkle/installers/noop.rb
52
52
  lib/sprinkle/installers/openbsd_pkg.rb
53
53
  lib/sprinkle/installers/opensolaris_pkg.rb
54
54
  lib/sprinkle/installers/push_text.rb
55
55
  lib/sprinkle/installers/rake.rb
56
56
  lib/sprinkle/installers/rpm.rb
57
57
  lib/sprinkle/installers/source.rb
58
+ lib/sprinkle/installers/transfer.rb
58
59
  lib/sprinkle/installers/yum.rb
60
+ lib/sprinkle/installers/freebsd_pkg.rb
61
+ lib/sprinkle/installers/openbsd_pkg.rb
62
+ lib/sprinkle/installers/opensolaris_pkg.rb
63
+ lib/sprinkle/installers/bsd_port.rb
64
+ lib/sprinkle/installers/mac_port.rb
59
65
  lib/sprinkle/package.rb
60
66
  lib/sprinkle/policy.rb
61
67
  lib/sprinkle/script.rb
@@ -90,6 +96,10 @@ spec/sprinkle/installers/rake_spec.rb
90
96
  spec/sprinkle/installers/rpm_spec.rb
91
97
  spec/sprinkle/installers/source_spec.rb
92
98
  spec/sprinkle/installers/yum_spec.rb
99
+ spec/sprinkle/installers/openbsd_pkg_spec.rb
100
+ spec/sprinkle/installers/freebsd_pkg_spec.rb
101
+ spec/sprinkle/installers/bsd_port_spec.rb
102
+ spec/sprinkle/installers/mac_port_spec.rb
93
103
  spec/sprinkle/package_spec.rb
94
104
  spec/sprinkle/policy_spec.rb
95
105
  spec/sprinkle/script_spec.rb
@@ -1,12 +1,12 @@
1
- = SPRINKLE
1
+ # SPRINKLE
2
2
 
3
- http://redartisan.com/2008/5/27/sprinkle-intro
4
- http://github.com/crafterm/sprinkle
5
- http://github.com/benschwarz/passenger-stack
6
- http://www.vimeo.com/2888665
7
- http://redartisan.lighthouseapp.com/projects/25275-sprinkle/tickets
3
+ * <http://redartisan.com/2008/5/27/sprinkle-intro>
4
+ * <http://github.com/crafterm/sprinkle>
5
+ * <http://github.com/benschwarz/passenger-stack>
6
+ * <http://www.vimeo.com/2888665>
7
+ * <http://redartisan.lighthouseapp.com/projects/25275-sprinkle/tickets>
8
8
 
9
- == DESCRIPTION:
9
+ ## DESCRIPTION:
10
10
 
11
11
  Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating
12
12
  system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after
@@ -208,18 +208,18 @@ and Git (via source with dependencies from APT):
208
208
 
209
209
  end
210
210
 
211
- Please see the examples directory for more complete examples of Sprinkle deployment scripts, and also the Passenger Stack github page and video by Ben Schwarz (http://github.com/benschwarz/passenger-stack and http://www.vimeo.com/2888665 respectively).
211
+ Please see the examples directory for more complete examples of Sprinkle deployment scripts, and also the Passenger Stack github page and video by Ben Schwarz (<http://github.com/benschwarz/passenger-stack> and <http://www.vimeo.com/2888665> respectively).
212
212
 
213
213
  Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to
214
214
  comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.
215
215
 
216
216
  Marcus Crafter <crafterm@redartisan.com>
217
217
 
218
- == LICENSE:
218
+ ## LICENSE:
219
219
 
220
220
  (The MIT License)
221
221
 
222
- Copyright (c) 2008 Marcus Crafter <crafterm@redartisan.com>
222
+ Copyright (c) 2008-2009 Marcus Crafter <crafterm@redartisan.com>
223
223
 
224
224
  Permission is hereby granted, free of charge, to any person obtaining
225
225
  a copy of this software and associated documentation files (the
data/bin/sprinkle CHANGED
@@ -73,7 +73,7 @@ def log_level(options)
73
73
  Object.logger.level = ActiveSupport::BufferedLogger::Severity::DEBUG if options[:verbose]
74
74
  end
75
75
 
76
- require 'sprinkle'
76
+ require File.dirname(__FILE__) + '/../lib/sprinkle'
77
77
 
78
78
  powder = OPTIONS[:path]
79
79
  raise "Sprinkle script is not readable: #{powder}" unless File.readable?(powder)
data/config/hoe.rb CHANGED
@@ -35,7 +35,7 @@ VERS = Sprinkle::VERSION::STRING + (REV ? ".#{REV}" : "")
35
35
  RDOC_OPTS = ['--quiet', '--title', 'sprinkle documentation',
36
36
  "--opname", "index.html",
37
37
  "--line-numbers",
38
- "--main", "README.txt",
38
+ "--main", "README.markdown",
39
39
  "--inline-source"]
40
40
 
41
41
  class Hoe
@@ -1,4 +1,4 @@
1
- = Example Rails Spinkle Deployment Script
1
+ = Example Rails Sprinkle Deployment Script
2
2
 
3
3
  The following example shows how you can provision Rails and associated packages onto a remote server (or set of servers).
4
4
 
@@ -12,4 +12,4 @@ $> sprinkle -t -s rails.rb
12
12
 
13
13
  == Information
14
14
 
15
- For more information, please see: http://github.com/crafterm/sprinkle/tree/master/README.txt
15
+ For more information, please see: http://github.com/crafterm/sprinkle/tree/master/README.markdown
@@ -3,7 +3,8 @@
3
3
  package :ruby do
4
4
  description 'Ruby Virtual Machine'
5
5
  version '1.8.6'
6
- source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz" # implicit :style => :gnu
6
+ patchlevel '369'
7
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p#{patchlevel}.tar.gz" # implicit :style => :gnu
7
8
  requires :ruby_dependencies
8
9
  end
9
10
 
@@ -14,8 +15,8 @@ end
14
15
 
15
16
  package :rubygems do
16
17
  description 'Ruby Gems Package Management System'
17
- version '1.2.0'
18
- source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
18
+ version '1.3.5'
19
+ source "http://rubyforge.org/frs/download.php/60718/rubygems-#{version}.tgz" do
19
20
  custom_install 'ruby setup.rb'
20
21
  end
21
22
  requires :ruby
@@ -24,5 +25,5 @@ end
24
25
  package :rails do
25
26
  description 'Ruby on Rails'
26
27
  gem 'rails'
27
- version '2.1.0'
28
+ version '2.3.3'
28
29
  end
@@ -1,6 +1,6 @@
1
1
  package :git, :provides => :scm do
2
2
  description 'Git Distributed Version Control'
3
- version '1.5.6.3'
3
+ version '1.6.3.3'
4
4
  source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
5
5
  requires :git_dependencies
6
6
  end
@@ -1,6 +1,6 @@
1
1
  package :sphinx, :provides => :search do
2
2
  description 'MySQL full text search engine'
3
- version '0.9.8-rc2'
3
+ version '0.9.8.1'
4
4
  source "http://www.sphinxsearch.com/downloads/sphinx-#{version}.tar.gz"
5
5
  requires :mysql_dev
6
6
  end
@@ -1,7 +1,7 @@
1
1
  package :mongrel do
2
2
  description 'Mongrel Application Server'
3
3
  gem 'mongrel'
4
- version '1.1.4'
4
+ version '1.1.5'
5
5
  end
6
6
 
7
7
  package :mongrel_cluster, :provides => :appserver do
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  package :apache, :provides => :webserver do
15
15
  description 'Apache 2 HTTP Server'
16
- version '2.2.9'
16
+ version '2.2.11'
17
17
  source "http://www.apache.org/dist/httpd/httpd-#{version}.tar.bz2" do
18
18
  enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
19
19
  prefix "/opt/local/apache2-#{version}"
@@ -35,7 +35,7 @@ require 'packages/scm'
35
35
  # the user is requested to select which one to use.
36
36
 
37
37
  policy :rails, :roles => :app do
38
- requires :rails, :version => '2.1.0'
38
+ requires :rails, :version => '2.3.3'
39
39
  requires :appserver
40
40
  requires :database
41
41
  requires :webserver
@@ -76,6 +76,22 @@ module Sprinkle
76
76
  end
77
77
  end
78
78
 
79
+ def transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false)
80
+ define_task(name, roles) do
81
+ upload source, destination, :via => :scp, :recursive => recursive
82
+ end
83
+
84
+ begin
85
+ run(name)
86
+ return true
87
+ rescue ::Capistrano::CommandError => e
88
+ return false if suppress_and_return_failures
89
+
90
+ # Reraise error if we're not suppressing it
91
+ raise
92
+ end
93
+ end
94
+
79
95
  private
80
96
 
81
97
  # REVISIT: can we set the description somehow?
@@ -25,6 +25,13 @@ module Sprinkle
25
25
  return true
26
26
  end
27
27
 
28
+ def transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false)
29
+ if recursive
30
+ flags = "-R "
31
+ end
32
+
33
+ system "cp #{flags}#{source} #{destination}"
34
+ end
28
35
  end
29
36
  end
30
37
  end
@@ -1,4 +1,5 @@
1
1
  require 'net/ssh/gateway'
2
+ require 'net/scp'
2
3
 
3
4
  module Sprinkle
4
5
  module Actors
@@ -26,7 +27,12 @@ module Sprinkle
26
27
  return process_with_gateway(name, commands, roles) if gateway_defined?
27
28
  process_direct(name, commands, roles)
28
29
  end
29
-
30
+
31
+ def transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false)
32
+ return transfer_with_gateway(name, source, destination, roles, recursive) if gateway_defined?
33
+ transfer_direct(name, source, destination, roles, recursive)
34
+ end
35
+
30
36
  protected
31
37
 
32
38
  def process_with_gateway(name, commands, roles)
@@ -39,10 +45,25 @@ module Sprinkle
39
45
  Array(roles).each { |role| execute_on_role(commands, role) }
40
46
  end
41
47
 
48
+ def transfer_with_gateway(name, source, destination, roles, recursive)
49
+ on_gateway do |gateway|
50
+ Array(roles).each { |role| transfer_to_role(source, destination, role, recursive, gateway) }
51
+ end
52
+ end
53
+
54
+ def transfer_direct(name, source, destination, roles, recursive)
55
+ Array(roles).each { |role| transfer_to_role(source, destination, role, recursive) }
56
+ end
57
+
42
58
  def execute_on_role(commands, role, gateway = nil)
43
59
  hosts = @options[:roles][role]
44
60
  Array(hosts).each { |host| execute_on_host(commands, host, gateway) }
45
61
  end
62
+
63
+ def transfer_to_role(source, destination, role, gateway = nil)
64
+ hosts = @options[:roles][role]
65
+ Array(hosts).each { |host| transfer_to_host(source, destination, host, gateway) }
66
+ end
46
67
 
47
68
  def execute_on_host(commands, host, gateway = nil)
48
69
  if gateway # SSH connection via gateway
@@ -64,6 +85,23 @@ module Sprinkle
64
85
  end
65
86
  end
66
87
 
88
+ def transfer_to_host(source, destination, host, recursive, gateway = nil)
89
+ if gateway # SSH connection via gateway
90
+ gateway.ssh(host, @options[:user]) do |ssh|
91
+ transfer_on_connection(source, destination, recursive, ssh)
92
+ end
93
+ else # direct SSH connection
94
+ Net::SSH.start(host, @options[:user]) do |ssh|
95
+ transfer_on_connection(source, destination, recursive, ssh)
96
+ end
97
+ end
98
+ end
99
+
100
+ def transfer_on_connection(source, destination, recursive, connection)
101
+ scp = Net::SCP.new(connection)
102
+ scp.upload! source, destination, :recursive => recursive
103
+ end
104
+
67
105
  private
68
106
 
69
107
  def gateway_defined?
@@ -50,6 +50,19 @@ module Sprinkle
50
50
  rescue ::Vlad::CommandFailedError => e
51
51
  return false if suppress_and_return_failures
52
52
 
53
+ # Reraise error if we're not suppressing it
54
+ raise
55
+ end
56
+ end
57
+
58
+ # Sorry, all transfers are recursive
59
+ def transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false) #:nodoc:
60
+ begin
61
+ rsync source, destination
62
+ return true
63
+ rescue ::Vlad::CommandFailedError => e
64
+ return false if suppress_and_return_failures
65
+
53
66
  # Reraise error if we're not suppressing it
54
67
  raise
55
68
  end
@@ -52,7 +52,7 @@ module Sprinkle
52
52
  # the actor. For more information on what configuration options are
53
53
  # available, view the corresponding Sprinkle::Actors page.
54
54
  def delivery(type, &block) #:doc:
55
- @style = Actors.const_get(type.to_s.titleize).new &block
55
+ @style = ("Sprinkle::Actors::" + type.to_s.titleize).constantize.new &block
56
56
  end
57
57
 
58
58
  def method_missing(sym, *args, &block) #:nodoc:
@@ -44,7 +44,7 @@ module Sprinkle
44
44
 
45
45
  def install_commands #:nodoc:
46
46
  command = @options[:dependencies_only] ? 'build-dep' : 'install'
47
- "DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qyu #{command} #{@packages.join(' ')}"
47
+ "env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get --force-yes -qyu #{command} #{@packages.join(' ')}"
48
48
  end
49
49
 
50
50
  end
@@ -54,6 +54,7 @@ module Sprinkle
54
54
  cmd << " --source #{source}" if source
55
55
  cmd << " --install-dir #{repository}" if option?(:repository)
56
56
  cmd << " --no-rdoc --no-ri" unless option?(:build_docs)
57
+ cmd << " --http-proxy #{http_proxy}" if option?(:http_proxy)
57
58
  cmd << " -- #{build_flags}" if option?(:build_flags)
58
59
  cmd
59
60
  end
@@ -5,14 +5,14 @@ module Sprinkle
5
5
  # This installer does nothing, it's simply useful for running pre / post hooks by themselves.
6
6
  #
7
7
  class Noop < Installer
8
- def initialize(parent, &block) #:nodoc:
9
- super parent, {}, &block
8
+ def initialize(parent, name, options = {}, &block) #:nodoc:
9
+ super parent, options, &block
10
10
  end
11
11
 
12
12
  protected
13
13
 
14
14
  def install_commands #:nodoc:
15
- ''
15
+ 'echo noop'
16
16
  end
17
17
 
18
18
  end
@@ -37,7 +37,7 @@ module Sprinkle
37
37
  protected
38
38
 
39
39
  def install_commands #:nodoc:
40
- "echo '#{@text}' |#{'sudo' if option?(:sudo)} tee -a #{@path}"
40
+ "echo -e '#{@text.gsub("'", "'\\\\''").gsub("\n", '\n')}' |#{'sudo ' if option?(:sudo)}tee -a #{@path}"
41
41
  end
42
42
 
43
43
  end
@@ -46,16 +46,26 @@ module Sprinkle
46
46
  # package :magic_beans do
47
47
  # source 'http://magicbeansland.com/latest-1.1.1.tar.gz' do
48
48
  # prefix '/usr/local'
49
- #
49
+ #
50
50
  # pre :prepare { 'echo "Here we go folks."' }
51
51
  # post :extract { 'echo "I believe..."' }
52
52
  # pre :build { 'echo "Cross your fingers!"' }
53
53
  # end
54
54
  # end
55
55
  #
56
+ # Fourth, specifying a custom archive name because the downloaded file name
57
+ # differs from the source URL:
58
+ #
59
+ # package :gitosis do
60
+ # source 'http://github.com/crafterm/sprinkle/tarball/master' do
61
+ # custom_archive 'crafterm-sprinkle-518e33c835986c03ec7ae8ea88c657443b006f28.tar.gz'
62
+ # end
63
+ # end
64
+ #
56
65
  # As you can see, setting options is as simple as creating a
57
66
  # block and calling the option as a method with the value as
58
67
  # its parameter.
68
+
59
69
  class Source < Installer
60
70
  attr_accessor :source #:nodoc:
61
71
 
@@ -143,7 +153,7 @@ module Sprinkle
143
153
  end
144
154
 
145
155
  def extract_command #:nodoc:
146
- case @source
156
+ case archive_name
147
157
  when /(tar.gz)|(tgz)$/
148
158
  'tar xzf'
149
159
  when /(tar.bz2)|(tb2)$/
@@ -158,7 +168,7 @@ module Sprinkle
158
168
  end
159
169
 
160
170
  def archive_name #:nodoc:
161
- name = @source.split('/').last
171
+ name = @options[:custom_archive] || @source.split('/').last
162
172
  raise "Unable to determine archive name for source: #{source}, please update code knowledge" unless name
163
173
  name
164
174
  end
@@ -168,12 +178,12 @@ module Sprinkle
168
178
  end
169
179
 
170
180
  def base_dir #:nodoc:
171
- if @source.split('/').last =~ /(.*)\.(tar\.gz|tgz|tar\.bz2|tb2)/
181
+ if archive_name.split('/').last =~ /(.*)\.(tar\.gz|tgz|tar\.bz2|tar|tb2)/
172
182
  return $1
173
183
  end
174
184
  raise "Unknown base path for source archive: #{@source}, please update code knowledge"
175
185
  end
176
-
186
+
177
187
  end
178
188
  end
179
189
  end
@@ -116,6 +116,7 @@ module Sprinkle
116
116
  @provides = metadata[:provides]
117
117
  @dependencies = []
118
118
  @recommends = []
119
+ @optional = []
119
120
  @verifications = []
120
121
  self.instance_eval &block
121
122
  end
@@ -177,7 +178,11 @@ module Sprinkle
177
178
  def push_text(text, path, options = {}, &block)
178
179
  @installer = Sprinkle::Installers::PushText.new(self, text, path, options, &block)
179
180
  end
180
-
181
+
182
+ def transfer(source, destination, options = {}, &block)
183
+ @installer = Sprinkle::Installers::Transfer.new(self, source, destination, options, &block)
184
+ end
185
+
181
186
  def verify(description = '', &block)
182
187
  @verifications << Sprinkle::Verify.new(self, description, &block)
183
188
  end
@@ -229,12 +234,17 @@ module Sprinkle
229
234
  @recommends.flatten!
230
235
  end
231
236
 
237
+ def optional(*packages)
238
+ @optional << packages
239
+ @optional.flatten!
240
+ end
241
+
232
242
  def tree(depth = 1, &block)
233
243
  packages = []
234
244
 
235
245
  @recommends.each do |dep|
236
246
  package = PACKAGES[dep]
237
- next unless package # skip missing recommended packages as they can be optional
247
+ next unless package # skip missing recommended packages as they're allowed to not exist
238
248
  block.call(self, package, depth) if block
239
249
  packages << package.tree(depth + 1, &block)
240
250
  end
@@ -249,6 +259,15 @@ module Sprinkle
249
259
  end
250
260
 
251
261
  packages << self
262
+
263
+ @optional.each do |dep|
264
+ package = PACKAGES[dep]
265
+ next unless package # skip missing optional packages as they're allow to not exist
266
+ block.call(self, package, depth) if block
267
+ packages << package.tree(depth + 1, &block)
268
+ end
269
+
270
+ packages
252
271
  end
253
272
 
254
273
  def to_s; @name; end
@@ -31,6 +31,23 @@ module Sprinkle
31
31
  @commands << "[ -n \"`echo \\`which #{path}\\``\" ]"
32
32
  end
33
33
  end
34
+
35
+ # Same as has_executable but with checking for e certain version number.
36
+ # Last option is the parameter to append for getting the version (which
37
+ # defaults to "-v").
38
+ def has_executable_with_version(path, version, get_version = '-v')
39
+ if path.include?('/')
40
+ @commands << "[ -x #{path} -a -n \"`#{path} #{get_version} 2> /dev/null | egrep -e \\\"#{version}\\\"`\" ]"
41
+ else
42
+ @commands << "[ -n \"`echo \\`which #{path}\\``\" -a -n \"`\\`which #{path}\\` #{get_version} 2>&1 | egrep -e \\\"#{version}\\\"`\" ]"
43
+ end
44
+ end
45
+
46
+ # Same as has_executable but checking output of a certain command
47
+ # with grep.
48
+ def has_version_in_grep(cmd, version)
49
+ @commands << "[ -n \"`#{cmd} 2> /dev/null | egrep -e \\\"#{version}\\\"`\" ]"
50
+ end
34
51
  end
35
52
  end
36
53
  end
@@ -2,7 +2,7 @@ module Sprinkle #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 2
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -135,6 +135,51 @@ describe Sprinkle::Actors::Capistrano do
135
135
 
136
136
  end
137
137
 
138
+ describe 'transferring files' do
139
+
140
+ before do
141
+ @source = 'source'
142
+ @dest = 'dest'
143
+ @roles = %w( app )
144
+ @name = 'name'
145
+
146
+ @cap = create_cap do; recipes 'deploy'; end
147
+ @cap.stub!(:run).and_return
148
+
149
+ @testing_errors = false
150
+ end
151
+
152
+ it 'should dynamically create a capistrano task containing calling upload' do
153
+ @cap.config.should_receive(:task).and_return
154
+ end
155
+
156
+ it 'should invoke capistrano task after creation' do
157
+ @cap.should_receive(:run).with(@name).and_return
158
+ end
159
+
160
+ it 'should raise capistrano errors when suppressing parameter is not set' do
161
+ @testing_errors = true
162
+
163
+ @cap.should_receive(:run).and_raise(::Capistrano::CommandError)
164
+ lambda { @cap.process @name, @commands, @roles }.should raise_error(::Capistrano::CommandError)
165
+ end
166
+
167
+ it 'should not raise errors and instead return false when suppressing parameter is set' do
168
+ @testing_errors = true
169
+
170
+ @cap.should_receive(:run).and_raise(::Capistrano::CommandError)
171
+
172
+ value = nil
173
+ lambda { value = @cap.process(@name, @commands, @roles, true) }.should_not raise_error(::Capistrano::CommandError)
174
+
175
+ value.should_not be
176
+ end
177
+
178
+ after do
179
+ @cap.transfer @name, @source, @dest, @roles unless @testing_errors
180
+ end
181
+ end
182
+
138
183
  describe 'generated task' do
139
184
 
140
185
  before do
@@ -167,4 +212,54 @@ describe Sprinkle::Actors::Capistrano do
167
212
 
168
213
  end
169
214
 
215
+ describe 'generated transfer' do
216
+ before do
217
+ @source = 'source'
218
+ @dest = 'dest'
219
+ @roles = %w( app )
220
+ @name = 'name'
221
+
222
+ @cap = create_cap do; recipes 'deploy'; end
223
+ @cap.config.stub!(:upload).and_return
224
+ end
225
+
226
+ it 'should call upload with the source and destination via :scp' do
227
+ @cap.config.should_receive(:upload).with(@source, @dest, :via => :scp, :recursive => true).and_return
228
+ end
229
+
230
+ it 'should be applicable for the supplied roles' do
231
+ @cap.stub!(:run).and_return
232
+ @cap.config.should_receive(:task).with(:install_name, :roles => @roles).and_return
233
+ end
234
+
235
+ after do
236
+ @cap.transfer @name, @source, @dest, @roles
237
+ end
238
+ end
239
+
240
+ describe 'generated transfer when recursive is false' do
241
+ before do
242
+ @source = 'source'
243
+ @dest = 'dest'
244
+ @roles = %w( app )
245
+ @name = 'name'
246
+
247
+ @cap = create_cap do; recipes 'deploy'; end
248
+ @cap.config.stub!(:upload).and_return
249
+ end
250
+
251
+ it 'should call upload with the source and destination via :scp' do
252
+ @cap.config.should_receive(:upload).with(@source, @dest, :via => :scp, :recursive => false).and_return
253
+ end
254
+
255
+ it 'should be applicable for the supplied roles' do
256
+ @cap.stub!(:run).and_return
257
+ @cap.config.should_receive(:task).with(:install_name, :roles => @roles).and_return
258
+ end
259
+
260
+ after do
261
+ @cap.transfer @name, @source, @dest, @roles, false
262
+ end
263
+ end
264
+
170
265
  end
@@ -40,15 +40,15 @@ describe Sprinkle::Installers::Apt do
40
40
  end
41
41
 
42
42
  it 'should invoke the apt installer for all specified packages' do
43
- @install_commands.should =~ /apt-get -qyu install ruby/
43
+ @install_commands.should =~ /apt-get --force-yes -qyu install ruby/
44
44
  end
45
45
 
46
46
  it 'should specify a non interactive mode to the apt installer' do
47
- @install_commands.should =~ /DEBIAN_FRONTEND=noninteractive/
47
+ @install_commands.should =~ /env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive/
48
48
  end
49
49
 
50
50
  it 'should automatically insert pre/post commands for the specified package' do
51
- @installer.send(:install_sequence).should == [ 'op1', %(DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qyu install ruby), 'op2' ]
51
+ @installer.send(:install_sequence).should == [ 'op1', %(env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get --force-yes -qyu install ruby), 'op2' ]
52
52
  end
53
53
 
54
54
  it 'should install a specific version if defined'
@@ -63,7 +63,7 @@ describe Sprinkle::Installers::Apt do
63
63
  end
64
64
 
65
65
  it 'should invoke the apt installer with build-dep command for all specified packages' do
66
- @install_commands.should =~ /apt-get -qyu build-dep ruby/
66
+ @install_commands.should =~ /apt-get --force-yes -qyu build-dep ruby/
67
67
  end
68
68
 
69
69
  end
@@ -5,7 +5,7 @@ describe Sprinkle::Installers::Gem do
5
5
  before do
6
6
  @gem = 'rails'
7
7
  @version = '2.0.2'
8
- @options = { :source => 'http://gems.github.com/', :repository => '/tmp/gems', :build_flags => '--build_flag=foo' }
8
+ @options = { :source => 'http://gems.github.com/', :repository => '/tmp/gems', :build_flags => '--build_flag=foo', :http_proxy => 'http://proxy:8080' }
9
9
  end
10
10
 
11
11
  def create_gem(gem, version = nil, options = {}, &block)
@@ -39,6 +39,10 @@ describe Sprinkle::Installers::Gem do
39
39
  @installer.build_flags.should == @options[:build_flags]
40
40
  end
41
41
 
42
+ it 'should optionally store the http proxy' do
43
+ @installer.http_proxy.should == @options[:http_proxy]
44
+ end
45
+
42
46
  end
43
47
 
44
48
  describe 'during installation' do
@@ -86,6 +90,18 @@ describe Sprinkle::Installers::Gem do
86
90
 
87
91
  end
88
92
 
93
+ describe 'with http proxy' do
94
+
95
+ before do
96
+ @installer = create_gem @gem, nil, :http_proxy => 'http://proxy:8080'
97
+ end
98
+
99
+ it 'should install with defined build flags' do
100
+ @installer.send(:install_commands).should == "gem install #{@gem} --no-rdoc --no-ri --http-proxy http://proxy:8080"
101
+ end
102
+
103
+ end
104
+
89
105
  end
90
106
 
91
107
  end
@@ -32,23 +32,34 @@ describe Sprinkle::Installers::PushText do
32
32
  end
33
33
 
34
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/
35
+ @install_commands.should == %q[echo -e 'another-hair-brained-idea' |tee -a /dev/mind/late-night]
36
36
  end
37
37
 
38
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' ]
39
+ @installer.send(:install_sequence).should == [ 'op1', "echo -e 'another-hair-brained-idea' |tee -a /dev/mind/late-night", 'op2' ]
40
40
  end
41
41
 
42
42
  end
43
43
 
44
44
  describe 'running with sudo' do
45
45
  before do
46
- @installer = create_text "I'm a special user", "/dev/mind/the-day-after", :sudo => true
46
+ @installer = create_text "a special user", "/dev/mind/the-day-after", :sudo => true
47
47
  @install_commands = @installer.send :install_commands
48
48
  end
49
49
 
50
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/
51
+ @install_commands.should == %q[echo -e 'a special user' |sudo tee -a /dev/mind/the-day-after]
52
+ end
53
+ end
54
+
55
+ describe 'sending a string with single quotes' do
56
+ before do
57
+ @installer = create_text "I'm a string with a single quote", "/dev/mind/the-day-after"
58
+ @install_commands = @installer.send :install_commands
59
+ end
60
+
61
+ it "should correctly encode the single quote character" do
62
+ @install_commands.should == %q[echo -e 'I'\''m a string with a single quote' |tee -a /dev/mind/the-day-after]
52
63
  end
53
64
  end
54
65
 
@@ -161,6 +161,20 @@ describe Sprinkle::Installers::Source do
161
161
  )
162
162
  end
163
163
 
164
+ describe 'with a custom archive definition' do
165
+ before do
166
+ @installer.options[:custom_archive] = 'super-foo.tar'
167
+ end
168
+
169
+ it 'should install the source from the custom archive' do
170
+ @installer.send(:extract_commands).first.should =~ /super-foo/
171
+ @installer.send(:configure_commands).first.should =~ /super-foo/
172
+ @installer.send(:build_commands).first.should =~ /super-foo/
173
+ @installer.send(:install_commands).first.should =~ /super-foo/
174
+ end
175
+
176
+ end
177
+
164
178
  describe 'during a customized install' do
165
179
 
166
180
  before do
@@ -174,7 +188,7 @@ describe Sprinkle::Installers::Source do
174
188
  it 'should store the custom install commands' do
175
189
  @installer.options[:custom_install].should == 'ruby setup.rb'
176
190
  end
177
-
191
+
178
192
  it 'should identify as having a custom install command' do
179
193
  @installer.should be_custom_install
180
194
  end
@@ -190,25 +204,25 @@ describe Sprinkle::Installers::Source do
190
204
  it 'should install the source using a custom installation command' do
191
205
  @installer.send(:custom_install_commands).first.should =~ /ruby setup.rb/
192
206
  end
193
-
207
+
194
208
  it 'should be run relative to the source build area' do
195
209
  @installer.send(:custom_install_commands).first.should =~ %r{cd /usr/builds/ruby-1.8.6-p111}
196
210
  end
197
-
211
+
198
212
  describe 'with a customized directory' do
199
-
213
+
200
214
  before do
201
215
  @installer.options[:custom_dir] = 'test'
202
216
  end
203
-
217
+
204
218
  it 'should install the source from the custom dir path' do
205
219
  @installer.send(:custom_install_commands).first.should =~ /test/
206
220
  end
207
-
221
+
208
222
  it 'should store the custom build dir path' do
209
223
  @installer.options[:custom_dir].should == 'test'
210
224
  end
211
-
225
+
212
226
  end
213
227
 
214
228
  end
data/sprinkle.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{sprinkle}
3
- s.version = "0.2.2"
3
+ s.version = "0.2.6"
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"]
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
  s.description = %q{Ruby DSL based software provisioning tool}
10
10
  s.email = ["crafterm@redartisan.com", "mitchell.hashimoto@citrusbyte.com"]
11
11
  s.executables = ["sprinkle"]
12
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
13
- s.files = ["CREDITS", "History.txt", "MIT-LICENSE", "Manifest.txt", "README.txt", "Rakefile", "bin/sprinkle",
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.markdown"]
13
+ s.files = ["CREDITS", "History.txt", "MIT-LICENSE", "Manifest.txt", "README.markdown", "Rakefile", "bin/sprinkle",
14
14
  "config/hoe.rb", "config/requirements.rb", "examples/packages/build_essential.rb",
15
15
  "examples/packages/databases/mysql.rb", "examples/packages/databases/sqlite3.rb",
16
16
  "examples/packages/phusion.rb", "examples/packages/ruby/rails.rb", "examples/packages/ruby/ruby.rb",
@@ -37,12 +37,12 @@ Gem::Specification.new do |s|
37
37
  "spec/sprinkle/extensions/array_spec.rb", "spec/sprinkle/extensions/string_spec.rb", "spec/sprinkle/installers/apt_spec.rb",
38
38
  "spec/sprinkle/installers/gem_spec.rb", "spec/sprinkle/installers/installer_spec.rb", "spec/sprinkle/installers/rpm_spec.rb",
39
39
  "spec/sprinkle/installers/yum_spec.rb", "spec/sprinkle/installers/source_spec.rb", "spec/sprinkle/installers/freebsd_pkg_spec.rb",
40
- "spec/sprinkle/installers/openbsd_pkg_spec.rb", "spec/sprinkle/installers/opensolaris_pkg_spec.rb", "spec/sprinkle/installers/noop_spec.rb",
40
+ "spec/sprinkle/installers/openbsd_pkg_spec.rb", "spec/sprinkle/installers/opensolaris_pkg_spec.rb",
41
41
  "spec/sprinkle/installers/mac_port_spec.rb", "spec/sprinkle/installers/push_text_spec.rb", "spec/sprinkle/installers/bsd_port_spec.rb", "spec/sprinkle/policy_spec.rb",
42
42
  "spec/sprinkle/script_spec.rb", "spec/sprinkle/sprinkle_spec.rb", "spec/sprinkle/installers/rake_spec.rb", "spec/sprinkle/verify_spec.rb"]
43
43
  s.has_rdoc = true
44
44
  s.homepage = %q{http://sprinkle.rubyforge.org}
45
- s.rdoc_options = ["--main", "README.txt"]
45
+ s.rdoc_options = ["--main", "README.markdown"]
46
46
  s.require_paths = ["lib"]
47
47
  s.rubyforge_project = %q{sprinkle}
48
48
  s.rubygems_version = %q{1.3.0}
@@ -21,6 +21,9 @@ task :check_version do
21
21
  end
22
22
  end
23
23
 
24
+ task :clobber_rcov do
25
+ end
26
+
24
27
  desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
28
  task :install_gem_no_doc => [:clean, :package] do
26
29
  sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trevorturk-sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -64,13 +64,13 @@ extensions: []
64
64
  extra_rdoc_files:
65
65
  - History.txt
66
66
  - Manifest.txt
67
- - README.txt
67
+ - README.markdown
68
68
  files:
69
69
  - CREDITS
70
70
  - History.txt
71
71
  - MIT-LICENSE
72
72
  - Manifest.txt
73
- - README.txt
73
+ - README.markdown
74
74
  - Rakefile
75
75
  - bin/sprinkle
76
76
  - config/hoe.rb
@@ -143,10 +143,11 @@ files:
143
143
  - tasks/rspec.rake
144
144
  has_rdoc: true
145
145
  homepage: http://sprinkle.rubyforge.org
146
+ licenses:
146
147
  post_install_message:
147
148
  rdoc_options:
148
149
  - --main
149
- - README.txt
150
+ - README.markdown
150
151
  require_paths:
151
152
  - lib
152
153
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  requirements: []
165
166
 
166
167
  rubyforge_project: sprinkle
167
- rubygems_version: 1.2.0
168
+ rubygems_version: 1.3.5
168
169
  signing_key:
169
170
  specification_version: 2
170
171
  summary: Ruby DSL based software provisioning tool
@@ -186,7 +187,6 @@ test_files:
186
187
  - spec/sprinkle/installers/freebsd_pkg_spec.rb
187
188
  - spec/sprinkle/installers/openbsd_pkg_spec.rb
188
189
  - spec/sprinkle/installers/opensolaris_pkg_spec.rb
189
- - spec/sprinkle/installers/noop_spec.rb
190
190
  - spec/sprinkle/installers/mac_port_spec.rb
191
191
  - spec/sprinkle/installers/push_text_spec.rb
192
192
  - spec/sprinkle/installers/bsd_port_spec.rb
@@ -1,23 +0,0 @@
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, &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 == ''
19
- end
20
-
21
- end
22
-
23
- end