sprinkle 0.7.1 → 0.7.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ * Officially depreciate transfer :render and the ability to render just by passing
2
+ a multi-line string as the transfer source. If you want to render templates see the
3
+ new `render()` and `template()` (rendering.rb) helpers and the `file` installer.
4
+
5
+ *Josh Goebel*
6
+
1
7
  * A users own post :install hooks should happen after a file has completely been moved
2
8
  (when using sudo this was not the case)
3
9
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sprinkle (0.6.2)
4
+ sprinkle (0.7)
5
5
  activesupport (>= 2.0.2)
6
6
  capistrano (>= 2.5.5)
7
+ erubis (>= 2.7.0)
7
8
  highline (>= 1.4.0)
8
9
  open4 (>= 1.1.0)
9
10
 
@@ -21,6 +22,7 @@ GEM
21
22
  net-ssh-gateway (>= 1.1.0)
22
23
  coderay (1.0.9)
23
24
  diff-lcs (1.2.4)
25
+ erubis (2.7.0)
24
26
  highline (1.6.19)
25
27
  i18n (0.6.1)
26
28
  interception (0.3)
data/bad.rb ADDED
@@ -0,0 +1,16 @@
1
+ package :ubuntu_version do
2
+ runner "lsb_release -r"
3
+ end
4
+
5
+
6
+ policy :myapp, :roles => :app do
7
+ requires :ubuntu_version
8
+ end
9
+
10
+ deployment do
11
+ delivery :ssh do
12
+ user 'root'
13
+ password 'secret'
14
+ role :app, 'server'
15
+ end
16
+ end
data/config/deploy.rb ADDED
@@ -0,0 +1,25 @@
1
+ set :application, "set your application name here"
2
+ set :repository, "set your repository location here"
3
+
4
+ # set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
5
+ # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
6
+
7
+ role :web, "pastie.org" # Your HTTP server, Apache/etc
8
+ role :app, "pastie.org" # This may be the same as your `Web` server
9
+ role :db, "pastie.org", :primary => true # This is where Rails migrations will run
10
+ role :db, "pastie.org"
11
+
12
+ # if you want to clean up old releases on each deploy uncomment this:
13
+ # after "deploy:restart", "deploy:cleanup"
14
+
15
+ # if you're still using the script/reaper helper you will need
16
+ # these http://github.com/rails/irs_process_scripts
17
+
18
+ # If you are using Passenger mod_rails uncomment this:
19
+ namespace :deploy do
20
+ task :start do ; end
21
+ # task :stop do ; end
22
+ # task :restart, :roles => :app, :except => { :no_release => true } do
23
+ # run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
24
+ # end
25
+ end
@@ -17,12 +17,12 @@
17
17
  # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
18
18
  # relationships to each other via dependencies.
19
19
 
20
- require 'packages/essential'
21
- require 'packages/rails'
22
- require 'packages/database'
23
- require 'packages/server'
24
- require 'packages/search'
25
- require 'packages/scm'
20
+ require './packages/essential'
21
+ require './packages/rails'
22
+ require './packages/database'
23
+ require './packages/server'
24
+ require './packages/search'
25
+ require './packages/scm'
26
26
 
27
27
 
28
28
  # Policies
data/inner.rb ADDED
@@ -0,0 +1,45 @@
1
+ policy :twice, :roles => :app do
2
+ requires :hostname
3
+ # requires :db
4
+ # requires :web, :name => "bob"
5
+ # requires :web, :name => "suzy"
6
+ # requires :web, :name => "nick"
7
+ end
8
+
9
+ package :hostname do
10
+ apt "test" do
11
+ pre :install do
12
+ runner "BEFORE"
13
+ runner "BEFORE 2"
14
+ end
15
+ post :install do
16
+ runner "AFTER" do
17
+ pre(:install) { runner "before after" }
18
+ post(:install) { runner "after after" }
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ deployment do
25
+
26
+ # delivery :dummy do
27
+ # role :app, 'beta1.pastie.org'
28
+ # role :app, 'beta2.pastie.org'
29
+ # end
30
+
31
+ # use vlad for deployment
32
+ # delivery :ssh do
33
+ # role :app, 'beta1.pastie.org'
34
+ # user "appz"
35
+ # end
36
+
37
+ # delivery :capistrano
38
+ delivery :capistrano do
39
+ role :app, 'beta1.pastie.org'
40
+ # role :app, 'beta2.pastie.org'
41
+ set :user, "appz"
42
+ set :use_sudo, true
43
+ end
44
+
45
+ end
@@ -0,0 +1,46 @@
1
+ module Sprinkle::Errors
2
+ # Blatantly stole this from Chef
3
+ class TemplateError < RuntimeError
4
+ attr_reader :original_exception, :context
5
+ SOURCE_CONTEXT_WINDOW = 2 unless defined? SOURCE_CONTEXT_WINDOW
6
+
7
+ def initialize(original_exception, template, context)
8
+ @original_exception, @template, @context = original_exception, template, context
9
+ end
10
+
11
+ def message
12
+ @original_exception.message
13
+ end
14
+
15
+ def line_number
16
+ @line_number ||= $1.to_i if original_exception.backtrace.find {|line| line =~ /\(erubis\):(\d+)/ }
17
+ end
18
+
19
+ def source_location
20
+ "on line ##{line_number}"
21
+ end
22
+
23
+ def source_listing
24
+ return nil if line_number.nil?
25
+
26
+ @source_listing ||= begin
27
+ line_index = line_number - 1
28
+ beginning_line = line_index <= SOURCE_CONTEXT_WINDOW ? 0 : line_index - SOURCE_CONTEXT_WINDOW
29
+ source_size = SOURCE_CONTEXT_WINDOW * 2 + 1
30
+ lines = @template.split(/\n/)
31
+ contextual_lines = lines[beginning_line, source_size]
32
+ output = []
33
+ contextual_lines.each_with_index do |line, index|
34
+ line_number = (index+beginning_line+1).to_s.rjust(3)
35
+ output << "#{line_number}: #{line}"
36
+ end
37
+ output.join("\n")
38
+ end
39
+ end
40
+
41
+ def to_s
42
+ "\n\n#{self.class} (#{message}) #{source_location}:\n\n" +
43
+ "#{source_listing}\n\n #{original_exception.backtrace.join("\n ")}\n\n"
44
+ end
45
+ end
46
+ end
@@ -19,7 +19,7 @@ module Sprinkle
19
19
 
20
20
  api do
21
21
  def brew(*names, &block)
22
- @recommends << :homebrew
22
+ recommends :homebrew
23
23
  install_package(*names, &block)
24
24
  end
25
25
  end
@@ -0,0 +1,98 @@
1
+ require 'tempfile'
2
+
3
+ module Sprinkle
4
+ module Installers
5
+ class FileInstaller < Installer
6
+ # = File installer
7
+ #
8
+ # This installer creates a file on the remote server.
9
+ #
10
+ # == Example Usage
11
+ #
12
+ # Installing a nginx.conf onto remote servers
13
+ #
14
+ # package :nginx_conf do
15
+ # file '/etc/nginx.conf', :content => File.read('files/nginx.conf')
16
+ # end
17
+ #
18
+ # If you user has access to 'sudo' and theres a file that requires
19
+ # priveledges to install, you can pass :sudo => true
20
+ #
21
+ # package :nginx_conf do
22
+ # file '/etc/nginx.conf', :sudo => true,
23
+ # :content => File.read('files/nginx.conf')
24
+ # end
25
+ #
26
+ # Should you need to run commands before or after the file transfer (making
27
+ # directories or changing permissions), you can use the pre/post :install directives.
28
+ #
29
+ # == Rendering templates
30
+ #
31
+ # Use the template render helper to render an ERB template to a remote file (you
32
+ # can use variables in your templates by setting them as instance variables inside
33
+ # your package. Templates have access to package methods such as opts, args, etc.
34
+ #
35
+ # package :nginx_conf do
36
+ # @nginx_port = 8080
37
+ # file '/etc/nginx.conf',
38
+ # :contents => render("nginx.conf")
39
+ # # ./templates/nginx.conf.erb or
40
+ # # ./templates/nginx.conf should contain the erb template
41
+ # end
42
+ attr_reader :sourcepath, :destination, :contents
43
+
44
+ api do
45
+ def file(destination, options = {}, &block)
46
+ # options.merge!(:binding => binding())
47
+ install FileInstaller.new(self, destination, options, &block)
48
+ end
49
+ end
50
+
51
+ def initialize(parent, destination, options={}, &block) #:nodoc:
52
+ @destination = destination
53
+ @contents = options[:content] || options[:contents]
54
+ raise "need :contents key for file" unless @contents
55
+ super parent, options, &block
56
+
57
+ post_move_if_sudo
58
+ setup_source
59
+ # setup file attributes
60
+ owner options[:owner] if options[:owner]
61
+ mode options[:mode] if options[:mode]
62
+ end
63
+
64
+ def install_commands
65
+ :TRANSFER
66
+ end
67
+
68
+ def owner(owner)
69
+ @owner = owner
70
+ post :install, "#{sudo_cmd}chown #{owner} #{@destination}"
71
+ end
72
+
73
+ def mode(mode)
74
+ @mode = mode
75
+ post :install, "#{sudo_cmd}chmod #{mode} #{@destination}"
76
+ end
77
+
78
+ private
79
+
80
+ def post_move_if_sudo
81
+ return unless sudo? # perform the file copy in two steps if we're using sudo
82
+ final = @destination
83
+ @destination = "/tmp/sprinkle_#{File.basename(@destination)}"
84
+ # make sure we push the move ahead of any other post install tasks
85
+ # a user may have requested
86
+ post(:install).unshift ["#{sudo_cmd}mv #{@destination} #{final}"]
87
+ end
88
+
89
+ def setup_source
90
+ file=Tempfile.new(@package.name.to_s)
91
+ file.print(@contents)
92
+ file.close
93
+ @sourcepath = file.path
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -30,7 +30,7 @@ module Sprinkle
30
30
 
31
31
  api do
32
32
  def gem(name, options = {}, &block)
33
- @recommends << :rubygems
33
+ recommends :rubygems
34
34
  install Gem.new(self, name, options, &block)
35
35
  end
36
36
  end
@@ -53,6 +53,8 @@ module Sprinkle
53
53
  class Installer
54
54
  include Sprinkle::Attributes
55
55
 
56
+ delegate :version, :to => :package
57
+
56
58
  attr_accessor :delivery, :package, :options, :pre, :post #:nodoc:
57
59
 
58
60
  def initialize(package, options = {}, &block) #:nodoc:
@@ -91,7 +91,7 @@ module Sprinkle
91
91
 
92
92
  api do
93
93
  def source(source, options = {}, &block)
94
- @recommends << :build_essential # Ubuntu/Debian
94
+ recommends :build_essential # Ubuntu/Debian
95
95
  install Source.new(self, source, options, &block)
96
96
  end
97
97
  end
@@ -1,48 +1,3 @@
1
- # Blatantly stole this from Chef
2
- class TemplateError < RuntimeError
3
- attr_reader :original_exception, :context
4
- SOURCE_CONTEXT_WINDOW = 2 unless defined? SOURCE_CONTEXT_WINDOW
5
-
6
- def initialize(original_exception, template, context)
7
- @original_exception, @template, @context = original_exception, template, context
8
- end
9
-
10
- def message
11
- @original_exception.message
12
- end
13
-
14
- def line_number
15
- @line_number ||= $1.to_i if original_exception.backtrace.find {|line| line =~ /\(erubis\):(\d+)/ }
16
- end
17
-
18
- def source_location
19
- "on line ##{line_number}"
20
- end
21
-
22
- def source_listing
23
- return nil if line_number.nil?
24
-
25
- @source_listing ||= begin
26
- line_index = line_number - 1
27
- beginning_line = line_index <= SOURCE_CONTEXT_WINDOW ? 0 : line_index - SOURCE_CONTEXT_WINDOW
28
- source_size = SOURCE_CONTEXT_WINDOW * 2 + 1
29
- lines = @template.split(/\n/)
30
- contextual_lines = lines[beginning_line, source_size]
31
- output = []
32
- contextual_lines.each_with_index do |line, index|
33
- line_number = (index+beginning_line+1).to_s.rjust(3)
34
- output << "#{line_number}: #{line}"
35
- end
36
- output.join("\n")
37
- end
38
- end
39
-
40
- def to_s
41
- "\n\n#{self.class} (#{message}) #{source_location}:\n\n" +
42
- "#{source_listing}\n\n #{original_exception.backtrace.join("\n ")}\n\n"
43
- end
44
- end
45
-
46
1
  module Sprinkle
47
2
  module Installers
48
3
  # = File transfer installer
@@ -76,21 +31,14 @@ module Sprinkle
76
31
  #
77
32
  # == Rendering templates
78
33
  #
79
- # If you pass the option :render => true, this tells transfer that the source file
80
- # is an ERB template to be rendered locally before being transferred (you can declare
81
- # variables in the package scope). When render is true, recursive is turned off. Note
82
- # you can also explicitly pass locals in to render with the :locals option.
83
- #
84
- # package :nginx_conf do
85
- # nginx_port = 8080
86
- # transfer 'files/nginx.conf', '/etc/nginx.conf', :render => true
87
- # end
34
+ # Rendering templates with transfer has been depreciated. Please see the file
35
+ # installer if you want to use templates.
88
36
  class Transfer < Installer
89
37
  attr_accessor :source, :destination, :sourcepath #:nodoc:
90
38
 
91
39
  api do
92
40
  def transfer(source, destination, options = {}, &block)
93
- options.merge!(:binding => binding())
41
+ options.reverse_merge!(:binding => binding())
94
42
  install Transfer.new(self, source, destination, options, &block)
95
43
  end
96
44
  end
@@ -129,16 +77,11 @@ module Sprinkle
129
77
  :TRANSFER
130
78
  end
131
79
 
132
- def self.render_template(template, context, prefix)
80
+ def render_template(template, context, prefix)
133
81
  require 'tempfile'
134
82
  require 'erubis'
135
83
 
136
- begin
137
- eruby = Erubis::Eruby.new(template)
138
- output = eruby.result(context)
139
- rescue Object => e
140
- raise TemplateError.new(e, template, context)
141
- end
84
+ output = @package.template(template, context)
142
85
 
143
86
  final_tempfile = Tempfile.new(prefix.to_s)
144
87
  final_tempfile.print(output)
@@ -146,10 +89,6 @@ module Sprinkle
146
89
  final_tempfile
147
90
  end
148
91
 
149
- def render_template(template, context, prefix)
150
- self.class.render_template(template, context, prefix)
151
- end
152
-
153
92
  def render_template_file(path, context, prefix)
154
93
  template = source_is_template? ? path : File.read(path)
155
94
  tempfile = render_template(template, context, @package.name)
@@ -166,6 +105,8 @@ module Sprinkle
166
105
  return if Sprinkle::OPTIONS[:testing]
167
106
 
168
107
  if options[:render]
108
+ ActiveSupport::Deprecation.warn("transfer :render is depreciated, please use the `file` installer now.")
109
+ ActiveSupport::Deprecation.warn("transfer :render will be removed from Sprinkle v0.8")
169
110
  if options[:locals]
170
111
  context = {}
171
112
  options[:locals].each_pair do |k,v|
@@ -176,18 +117,12 @@ module Sprinkle
176
117
  end
177
118
  end
178
119
  else
179
- # context = binding()
180
120
  context = @binding
181
121
  end
182
122
 
183
123
  tempfile = render_template_file(@source, context, @package.name)
184
124
  @sourcepath = tempfile.path
185
- if source_is_template?
186
- logger.debug "Rendering inline template to temporary file #{sourcepath}"
187
- else
188
- logger.debug "Rendering template #{@source} to temporary file #{sourcepath}"
189
- end
190
- recursive = false
125
+ @options[:recursive] = false
191
126
  else
192
127
  @sourcepath = @source
193
128
  end
@@ -23,7 +23,8 @@ module Sprinkle::Package
23
23
 
24
24
  # returns all packages matching the name and options given (including via provides)
25
25
  def find_all(name, opts={})
26
- all=[@packages.select {|x| x.name.to_s == name.to_s },
26
+ # opts ||= {}
27
+ all = [@packages.select {|x| x.name.to_s == name.to_s },
27
28
  find_all_by_provides(name, opts)].flatten.compact
28
29
  filter(all, opts)
29
30
  end
@@ -0,0 +1,41 @@
1
+ require 'erubis'
2
+ require 'digest/md5'
3
+
4
+ module Sprinkle::Package
5
+ module Rendering
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ self.send :include, Helpers
10
+ end
11
+
12
+ def template(src, bound=binding)
13
+ eruby = Erubis::Eruby.new(src)
14
+ output = eruby.result(bound)
15
+ rescue Object => e
16
+ raise Sprinkle::Errors::TemplateError.new(e, src, bound)
17
+ end
18
+
19
+ def render(file)
20
+ contents=File.read(expand_filename(file))
21
+ template(contents)
22
+ end
23
+
24
+ module Helpers
25
+ def md5(s)
26
+ Digest::MD5.hexdigest(s)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def expand_filename(n)
33
+ return n.to_s if n.to_s.starts_with? "/"
34
+ ["./templates/#{n}","./templates/#{n}.erb"].each do |f|
35
+ return f if File.exist?(f)
36
+ end
37
+ raise "template file not found"
38
+ end
39
+
40
+ end
41
+ end
@@ -107,6 +107,8 @@ module Sprinkle
107
107
  cattr_reader :installer_methods
108
108
  @@installer_methods = []
109
109
 
110
+ include Rendering
111
+
110
112
  def self.add_api(&block)
111
113
  before = self.instance_methods
112
114
  self.class_eval &block
@@ -119,7 +119,7 @@ module Sprinkle
119
119
  end
120
120
 
121
121
  def normalize(all, &block)
122
- all = all.flatten.uniq
122
+ all = all.flatten.uniq {|x| [x.name, x.version] }
123
123
  cloud_info "--> Normalized installation order for all packages: #{all.collect(&:name).join(', ')}\n"
124
124
  all.each &block
125
125
  end
@@ -13,7 +13,6 @@ module Sprinkle
13
13
  module File
14
14
  Sprinkle::Verify.register(Sprinkle::Verifiers::File)
15
15
 
16
- # Checks to make sure <tt>path</tt> is a file on the remote server.
17
16
  def has_file(path)
18
17
  test "-f #{path}"
19
18
  end
@@ -29,9 +28,13 @@ module Sprinkle
29
28
  def file_contains(path, text)
30
29
  @commands << "grep '#{text}' #{path}"
31
30
  end
31
+
32
+ # TODO: remove 0.9
32
33
  def user_present(username)
34
+ ActiveSupport::Deprecation.warn("user_present is depreciated. Use has_user instead.")
33
35
  has_user username
34
36
  end
37
+
35
38
  def matches_local(localfile, remotefile, mode=nil)
36
39
  raise "Couldn't find local file #{localfile}" unless ::File.exists?(localfile)
37
40
  require 'digest/md5'
@@ -1,3 +1,4 @@
1
+ # TODO: remove
1
2
  module Sprinkle
2
3
  module Verifiers
3
4
  module Package
@@ -60,6 +60,7 @@ module Sprinkle
60
60
  # end
61
61
  class Verify
62
62
  include Sprinkle::Attributes
63
+ include Sprinkle::Package::Rendering::Helpers
63
64
  attr_accessor :package, :description, :commands #:nodoc:
64
65
 
65
66
  delegate :opts, :to => :package
@@ -1,3 +1,3 @@
1
1
  module Sprinkle
2
- Version = "0.7.1"
2
+ Version = "0.7.1.1"
3
3
  end
@@ -0,0 +1,33 @@
1
+ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
2
+
3
+ describe Sprinkle::Package::Rendering, 'rendering' do
4
+
5
+ before do
6
+ @package = package :something do
7
+ end
8
+ end
9
+
10
+ it "should be able to calculate md5s" do
11
+ @package.md5("test").should == "098f6bcd4621d373cade4e832627b4f6"
12
+ end
13
+
14
+ it "should allow passing locals to template" do
15
+ t=@package.template("hello <%= world %>", :world => "world")
16
+ t.should == "hello world"
17
+ end
18
+
19
+ it "should be able to render a file from absolute path" do
20
+ path=File.join(__FILE__, "../../templates/test.erb")
21
+ t=@package.render("test")
22
+ t.should == "hello "
23
+ end
24
+
25
+ it "should be able to render a file from templates" do
26
+ @package = package :new do
27
+ @world = "world"
28
+ end
29
+ t=@package.render("test")
30
+ t.should == "hello world"
31
+ end
32
+
33
+ end
@@ -0,0 +1,109 @@
1
+ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
2
+
3
+ describe Sprinkle::Installers::FileInstaller do
4
+ include Sprinkle::Deployment
5
+
6
+ before do
7
+ @package = mock(Sprinkle::Package, :name => 'package', :sudo? => false)
8
+ @empty = Proc.new { }
9
+ @delivery = mock(Sprinkle::Deployment, :install => true)
10
+ @source = 'source'
11
+ @destination = 'destination'
12
+ @contents = "hi"
13
+ @installer = create_file_installer(@destination, :contents => @contents)
14
+ @roles = []
15
+ @deployment = deployment do
16
+ delivery :capistrano
17
+ installer do; prefix '/usr/bin'; end
18
+ end
19
+ end
20
+
21
+ def create_file_installer(dest, options={}, &block)
22
+ i = Sprinkle::Installers::FileInstaller.new(@package, 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.contents.should == @contents
30
+ @installer.destination.should == @destination
31
+ end
32
+ end
33
+
34
+ describe 'during installation' do
35
+
36
+ context "setting mode and owner" do
37
+ before do
38
+ @installer = create_file_installer @destination, :content => @contents do
39
+ mode "744"
40
+ owner "root"
41
+ end
42
+ @installer_commands = @installer.install_sequence
43
+ end
44
+
45
+ it "should include command to set owner" do
46
+ @installer_commands.should include("chmod 744 #{@destination}")
47
+ end
48
+
49
+ it "should include command to set mode" do
50
+ @installer_commands.should include("chown root #{@destination}")
51
+ end
52
+
53
+ end
54
+
55
+ context 'single pre/post commands' do
56
+ before do
57
+ @installer = create_file_installer @destination, :content => @contents do
58
+ pre :install, 'op1'
59
+ post :install, 'op2'
60
+ end
61
+ @installer_commands = @installer.install_sequence
62
+ @delivery = @installer.delivery
63
+ end
64
+
65
+ it "should call the pre and post install commands around the file transfer" do
66
+ @installer_commands.should == ["op1",:TRANSFER, "op2"]
67
+ end
68
+
69
+ end
70
+
71
+ context 'pre/post with sudo' do
72
+ before do
73
+ @installer = create_file_installer @destination, :content => @contents do
74
+ @options[:sudo]= true
75
+ pre :install, 'op1'
76
+ post :install, 'op2'
77
+ end
78
+ @installer_commands = @installer.install_sequence
79
+ @delivery = @installer.delivery
80
+ end
81
+
82
+ it "should call the pre and post install commands around the file transfer" do
83
+ @installer_commands.should == ["op1",:TRANSFER,
84
+ "sudo mv /tmp/sprinkle_destination destination", "op2"]
85
+ end
86
+ end
87
+
88
+ context 'multiple pre/post commands' do
89
+ before do
90
+ @installer = create_file_installer @destination, :content => @contents do
91
+ pre :install, 'op1', 'op1-1'
92
+ post :install, 'op2', 'op2-1'
93
+ end
94
+ @installer_commands = @installer.install_sequence
95
+ @delivery = @installer.delivery
96
+ end
97
+
98
+ it "should call the pre and post install commands around the file transfer" do
99
+ @installer_commands.should == ["op1","op1-1",:TRANSFER, "op2","op2-1"]
100
+ end
101
+
102
+ end
103
+
104
+ after do
105
+ @installer.process @roles
106
+ end
107
+ end
108
+
109
+ end
data/sprinkle.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.add_development_dependency(%q<rspec>, [">= 2.5"])
31
31
  s.add_development_dependency(%q<rake>, [">= 0.8.7"])
32
32
  s.add_development_dependency(%q<rdoc>, [">= 3.12"])
33
+ s.add_runtime_dependency(%q<erubis>, [">= 2.7.0"])
33
34
  s.add_runtime_dependency(%q<open4>, [">= 1.1.0"])
34
35
  s.add_runtime_dependency(%q<activesupport>, [">= 2.0.2"])
35
36
  s.add_runtime_dependency(%q<highline>, [">= 1.4.0"])
data/test.rb ADDED
@@ -0,0 +1,102 @@
1
+ # package :echo do
2
+ # runner "echo hello world"
3
+ # end
4
+ #
5
+ # package :version do
6
+ # runner "cat /etc/lsb-release"
7
+ # end
8
+ #
9
+ # policy :once, :roles => :app do
10
+ # requires :echo
11
+ # requires :version
12
+ # end
13
+ #
14
+ package :db do
15
+ # go do
16
+ # puts "<eval db>"
17
+ # runner "installing the db"
18
+ # end
19
+ verify do
20
+ has_file "/etc/db"
21
+ end
22
+ # runner "finalized"
23
+ end
24
+
25
+ package :hostname do
26
+ # go do
27
+ # # puts "<eval hostname : #{hostname}>"
28
+ # runner "echo #{hostname} > /etc/hostname", :sudo => true
29
+ # end
30
+ # push_text "now", "/etc/stupid_file"
31
+ # details "using name: front.pastie.org"
32
+
33
+ # runner "echo 'hostname'"
34
+ # runner "cat /etc/hostname"
35
+
36
+ version "5"
37
+
38
+ @what = "secret"
39
+ @something = "else"
40
+ file "/Users/jgoebel/notnow#{version}", :contents => c=render(:first)
41
+ # transfer "<%= @what %>\n<%= @what + something %>", "/Users/jgoebel/notnow2", :render => true,
42
+ # :binding => binding
43
+
44
+ verify do
45
+ has_file "/Users/jgoebel/notnow#{version}"
46
+ # md5_of_file "/Users/jgoebel/notnow", md5(c)
47
+ end
48
+ # verify do
49
+ # has_executable "/bin/ccc"
50
+ # end
51
+ end
52
+
53
+ package :web do
54
+ requires :db
55
+
56
+ # go do
57
+ # # puts "<eval web>"
58
+ # runner "installing web #{opts[:name]}"
59
+ # end
60
+ # runner "finalized"
61
+
62
+ verify do
63
+ # has_file "/etc/web/#{opts[:name]}"
64
+ end
65
+ end
66
+
67
+ policy :twice, :roles => :app do
68
+ requires :hostname
69
+ # requires :db
70
+ # requires :web, :name => "bob"
71
+ # requires :web, :name => "suzy"
72
+ # requires :web, :name => "nick"
73
+ end
74
+
75
+ deployment do
76
+
77
+ # delivery :dummy do
78
+ # role :app, 'beta1.pastie.org'
79
+ # role :app, 'beta2.pastie.org'
80
+ # end
81
+
82
+ delivery :local
83
+
84
+ # delivery :vlad do
85
+ # script "vlad"
86
+ # end
87
+
88
+ # use ssh for deployment
89
+ # delivery :ssh do
90
+ # role :app, 'front.pastie.org'
91
+ # user "appz"
92
+ # end
93
+
94
+ # delivery :capistrano
95
+ # delivery :capistrano do
96
+ # role :app, 'beta1.pastie.org'
97
+ # role :app, 'beta2.pastie.org'
98
+ # set :user, "appz"
99
+ # set :use_sudo, true
100
+ # end
101
+
102
+ end
data/work/inner.rb ADDED
@@ -0,0 +1,24 @@
1
+ policy :sprinkle, :roles => :app do
2
+ requires :sprinkle
3
+ end
4
+
5
+ package :sprinkle do
6
+ i=runner "test" do
7
+ # pre(:install) { install Installers::Runner.new(self,"before") }
8
+ # pre(:install) { runner "pre" }
9
+ # post(:install) { runner "after" }
10
+ post(:install) { noop }
11
+ end
12
+ # puts runner("blah")
13
+ # puts i.inspect
14
+ runner "next"
15
+ end
16
+
17
+ deployment do
18
+
19
+ # use vlad for deployment
20
+ delivery :dummy do
21
+ # role :app, 'yourhost.com'
22
+ end
23
+
24
+ end
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.7.1
4
+ version: 0.7.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-19 00:00:00.000000000 Z
13
+ date: 2013-06-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -60,6 +60,22 @@ dependencies:
60
60
  - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3.12'
63
+ - !ruby/object:Gem::Dependency
64
+ name: erubis
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: 2.7.0
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 2.7.0
63
79
  - !ruby/object:Gem::Dependency
64
80
  name: open4
65
81
  requirement: !ruby/object:Gem::Requirement
@@ -141,7 +157,9 @@ files:
141
157
  - MIT-LICENSE
142
158
  - README.md
143
159
  - Rakefile
160
+ - bad.rb
144
161
  - bin/sprinkle
162
+ - config/deploy.rb
145
163
  - examples/packages/build_essential.rb
146
164
  - examples/packages/databases/mysql.rb
147
165
  - examples/packages/databases/mysql_source.rb
@@ -163,6 +181,7 @@ files:
163
181
  - examples/rails/packages/server.rb
164
182
  - examples/rails/rails.rb
165
183
  - examples/sprinkle/sprinkle.rb
184
+ - inner.rb
166
185
  - lib/sprinkle.rb
167
186
  - lib/sprinkle/actors/actor.rb
168
187
  - lib/sprinkle/actors/capistrano.rb
@@ -173,6 +192,7 @@ files:
173
192
  - lib/sprinkle/deployment.rb
174
193
  - lib/sprinkle/errors/pretty_failure.rb
175
194
  - lib/sprinkle/errors/remote_command_failure.rb
195
+ - lib/sprinkle/errors/template_error.rb
176
196
  - lib/sprinkle/errors/transfer_failure.rb
177
197
  - lib/sprinkle/extensions/array.rb
178
198
  - lib/sprinkle/extensions/attributes.rb
@@ -184,6 +204,7 @@ files:
184
204
  - lib/sprinkle/installers/brew.rb
185
205
  - lib/sprinkle/installers/bsd_port.rb
186
206
  - lib/sprinkle/installers/deb.rb
207
+ - lib/sprinkle/installers/file.rb
187
208
  - lib/sprinkle/installers/freebsd_pkg.rb
188
209
  - lib/sprinkle/installers/freebsd_portinstall.rb
189
210
  - lib/sprinkle/installers/gem.rb
@@ -213,6 +234,7 @@ files:
213
234
  - lib/sprinkle/package.rb
214
235
  - lib/sprinkle/package/chooser.rb
215
236
  - lib/sprinkle/package/package_repository.rb
237
+ - lib/sprinkle/package/rendering.rb
216
238
  - lib/sprinkle/policy.rb
217
239
  - lib/sprinkle/script.rb
218
240
  - lib/sprinkle/utility/log_recorder.rb
@@ -238,11 +260,13 @@ files:
238
260
  - spec/sprinkle/actors/ssh_spec.rb
239
261
  - spec/sprinkle/deployment_spec.rb
240
262
  - spec/sprinkle/extensions/array_spec.rb
263
+ - spec/sprinkle/extensions/rendering_spec.rb
241
264
  - spec/sprinkle/extensions/string_spec.rb
242
265
  - spec/sprinkle/installers/apt_spec.rb
243
266
  - spec/sprinkle/installers/binary_spec.rb
244
267
  - spec/sprinkle/installers/brew_spec.rb
245
268
  - spec/sprinkle/installers/bsd_port_spec.rb
269
+ - spec/sprinkle/installers/file_spec.rb
246
270
  - spec/sprinkle/installers/freebsd_pkg_spec.rb
247
271
  - spec/sprinkle/installers/freebsd_portinstall_spec.rb
248
272
  - spec/sprinkle/installers/gem_spec.rb
@@ -271,6 +295,8 @@ files:
271
295
  - spec/sprinkle/sprinkle_spec.rb
272
296
  - spec/sprinkle/verify_spec.rb
273
297
  - sprinkle.gemspec
298
+ - test.rb
299
+ - work/inner.rb
274
300
  homepage: https://github.com/sprinkle-tool/sprinkle
275
301
  licenses:
276
302
  - MIT
@@ -305,11 +331,13 @@ test_files:
305
331
  - spec/sprinkle/actors/ssh_spec.rb
306
332
  - spec/sprinkle/deployment_spec.rb
307
333
  - spec/sprinkle/extensions/array_spec.rb
334
+ - spec/sprinkle/extensions/rendering_spec.rb
308
335
  - spec/sprinkle/extensions/string_spec.rb
309
336
  - spec/sprinkle/installers/apt_spec.rb
310
337
  - spec/sprinkle/installers/binary_spec.rb
311
338
  - spec/sprinkle/installers/brew_spec.rb
312
339
  - spec/sprinkle/installers/bsd_port_spec.rb
340
+ - spec/sprinkle/installers/file_spec.rb
313
341
  - spec/sprinkle/installers/freebsd_pkg_spec.rb
314
342
  - spec/sprinkle/installers/freebsd_portinstall_spec.rb
315
343
  - spec/sprinkle/installers/gem_spec.rb