capistrano-fanfare 0.0.1 → 0.0.2

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.
@@ -12,7 +12,7 @@ module Capistrano::Fanfare::Bundler
12
12
 
13
13
  set(:bundle_flags) do
14
14
  flags = "--deployment"
15
- flags << " --quiet" unless ENV['VERBOSE']
15
+ flags << " --quiet" if ENV['QUIET']
16
16
  flags << " --binstubs"
17
17
  flags << " --shebang #{bundle_shebang}"
18
18
  flags
@@ -39,6 +39,11 @@ module Capistrano::Fanfare::Defaults
39
39
  end
40
40
  }
41
41
 
42
+ # =========================================================================
43
+ # These are the tasks that are available to help with deploying web apps.
44
+ # You can have cap give you a summary of them with `cap -T'.
45
+ # =========================================================================
46
+
42
47
  namespace :deploy do
43
48
  desc <<-DESC
44
49
  Deploys and starts a `cold' application. This is useful if you have not \
@@ -5,41 +5,80 @@ module Capistrano
5
5
 
6
6
  ##
7
7
  # This class defines the abstract interface for all Capistrano
8
- # foreman deployment strategies. Subclasses must implement at least the
9
- # #export, #start, and #stop methods.
8
+ # Foreman deployment strategies. Subclasses must implement at least the
9
+ # #export, #start, #stop, and #ps methods.
10
10
 
11
11
  class Base
12
12
  attr_reader :configuration
13
13
 
14
+ ##
15
+ # Instantiates a strategy with a reference to the given configuration.
16
+
14
17
  def initialize(config = {})
15
18
  @configuration = config
16
19
  end
17
20
 
21
+ ##
22
+ # Executes the necessary commands to export service definitions, run
23
+ # scripts and all artifacts required by the service backend.
24
+
18
25
  def export
19
26
  raise NotImplementedError, "`export' is not implemented by #{self.class.name}"
20
27
  end
21
28
 
29
+ ##
30
+ # Optionally takes the artifacts generated by #export and registers
31
+ # the service(s) with the underlying service backend or operating
32
+ # system. No implementation is required by subclasses, but this
33
+ # method will be invoked unconditionally.
34
+
35
+ def register
36
+ # no-op
37
+ end
38
+
39
+ ##
40
+ # Executes the necessary commands to start a specific Procfile
41
+ # process group, or to start all process groups when no arguments
42
+ # are provided.
43
+
22
44
  def start(proc_group = nil)
23
45
  raise NotImplementedError, "`start' is not implemented by #{self.class.name}"
24
46
  end
25
47
 
48
+ ##
49
+ # Executes the necessary commands to stop a specific Procfile
50
+ # process group, or to stop all process groups when no arguments
51
+ # are provided.
52
+
26
53
  def stop(proc_group = nil)
27
54
  raise NotImplementedError, "`stop' is not implemented by #{self.class.name}"
28
55
  end
29
56
 
30
- def register
31
- # no-op
32
- end
57
+ ##
58
+ # Executes the necessary commands to restart a specific Procfile
59
+ # process group, or to restart all process groups when no arguments
60
+ # are provided. A default implementation is provided if the subclass
61
+ # does not provide one.
33
62
 
34
63
  def restart(proc_group = nil)
35
64
  stop(proc_group)
36
65
  start(proc_group)
37
66
  end
38
67
 
68
+ ##
69
+ # Executes the necessary commands to display the state of running
70
+ # service processes described in the Procfile.
71
+
72
+ def ps
73
+ raise NotImplementedError, "`ps' is not implemented by #{self.class.name}"
74
+ end
75
+
39
76
  protected
40
77
 
78
+ ##
41
79
  # This is to allow helper methods like "run" and "put" to be more
42
80
  # easily accessible to strategy implementations.
81
+
43
82
  def method_missing(sym, *args, &block)
44
83
  if configuration.respond_to?(sym)
45
84
  configuration.send(sym, *args, &block)
@@ -4,6 +4,10 @@ module Capistrano
4
4
  module Fanfare
5
5
  module Foreman
6
6
  module Strategy
7
+
8
+ ##
9
+ # Implements the runit Foreman export strategy.
10
+
7
11
  class Runit < Base
8
12
  def export
9
13
  run [
@@ -2,6 +2,11 @@ module Capistrano
2
2
  module Fanfare
3
3
  module Foreman
4
4
  module Strategy
5
+
6
+ ##
7
+ # Returns a new instance of the +strategy+ Foreman export strategy,
8
+ # which has been injected with the Capistrano::Configuration instance.
9
+
5
10
  def self.new(strategy, config={})
6
11
  strategy_file = "capistrano/fanfare/foreman/strategy/#{strategy}"
7
12
  require(strategy_file)
@@ -146,6 +146,9 @@ module Capistrano::Fanfare::Foreman
146
146
  end
147
147
 
148
148
  after "deploy:update_code", "foreman:cp_env"
149
+ after "deploy:start", "foreman:start"
150
+ after "deploy:stop", "foreman:stop"
151
+ after "deploy:restart", "foreman:restart"
149
152
  end
150
153
  end
151
154
  end
@@ -22,6 +22,11 @@ module Capistrano::Fanfare::GitStyle
22
22
  capture("basename #{previous_release} | cut -d - -f 2",
23
23
  :except => { :no_release => true }).chomp if previous_release }
24
24
 
25
+ # =========================================================================
26
+ # These are the tasks that are available to help with deploying web apps.
27
+ # You can have cap give you a summary of them with `cap -T'.
28
+ # =========================================================================
29
+
25
30
  namespace :deploy do
26
31
  desc <<-DESC
27
32
  Copies your project to the remote servers. This is the first stage \
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Fanfare
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -17,6 +17,7 @@ end
17
17
 
18
18
  module Capistrano
19
19
  class Configuration
20
+ # injects a fanfare_recipe helper method which can be used in the Capfile
20
21
  include Capistrano::Fanfare::Configuration
21
22
  end
22
23
  end
@@ -4,15 +4,36 @@ module Capistrano
4
4
  module Deploy
5
5
  module Strategy
6
6
 
7
+ ##
8
+ # Implements a Git style deployment strategy largely propsed and
9
+ # introduced by Chris Wanstrath in a GitHub blog post entitiled
10
+ # "Deployment Script Spring Cleaning"
11
+ # (source: https://github.com/blog/470-deployment-script-spring-cleaning).
12
+ #
13
+ # All fresh checkouts and updates happen in the :current_path directory
14
+ # and the :releases_path directories get used for deployment history
15
+ # tracking (useful for rollbacks).
16
+
7
17
  class GitStyle < Remote
8
18
  protected
9
19
 
20
+ ##
21
+ # Performs a `git checkout` if :current_path does not exist and a
22
+ # `git fetch && git reset --hard` for updates.
23
+
10
24
  def command
11
25
  @command ||= "if [ -d #{configuration[:current_path]}/.git ]; then " +
12
26
  "#{source.sync(revision, configuration[:current_path])}; " +
13
27
  "else #{source.checkout(revision, configuration[:current_path])}; fi"
14
28
  end
15
29
 
30
+ ##
31
+ # Creates a stub directory representing the current release to be
32
+ # deployed with the form "20120101020304-18c322b65". The date is
33
+ # calculated similar to the default capistrano deploy recipe but
34
+ # the full Git SHA commit hash is appended which will be used to
35
+ # determine the last revision that was deployed.
36
+
16
37
  def mark
17
38
  "(mkdir -p #{File.join(configuration[:releases_path], configuration[:release_name])})"
18
39
  end
data/spec/bundler_spec.rb CHANGED
@@ -88,14 +88,14 @@ load Gem.bin_path('bundler', 'bundle')
88
88
  @config.fetch(:bundle_flags).must_match /--shebang bangbang/
89
89
  end
90
90
 
91
- it "contains --quiet by default" do
92
- @config.fetch(:bundle_flags).must_match /--quiet/
91
+ it "doesn't contain --quiet by default" do
92
+ @config.fetch(:bundle_flags).wont_match /--quiet/
93
93
  end
94
94
 
95
- it "does not contain --quiet if ENV['VERSBOSE'] is set" do
96
- ENV['VERBOSE'] = "yes"
95
+ it "contains --quiet if ENV['QUIET'] is set" do
96
+ ENV['QUIET'] = "yes"
97
97
 
98
- @config.fetch(:bundle_flags).wont_match /--quiet/
98
+ @config.fetch(:bundle_flags).must_match /--quiet/
99
99
  end
100
100
  end
101
101
 
data/spec/foreman_spec.rb CHANGED
@@ -129,6 +129,10 @@ describe Capistrano::Fanfare::Foreman do
129
129
 
130
130
  strategy.verify
131
131
  end
132
+
133
+ it "calls foreman:start task after deploy:start" do
134
+ @config.must_have_callback_after "deploy:start", "foreman:start"
135
+ end
132
136
  end
133
137
 
134
138
  describe "task :stop" do
@@ -138,6 +142,10 @@ describe Capistrano::Fanfare::Foreman do
138
142
 
139
143
  strategy.verify
140
144
  end
145
+
146
+ it "calls foreman:stop task after deploy:stop" do
147
+ @config.must_have_callback_after "deploy:stop", "foreman:stop"
148
+ end
141
149
  end
142
150
 
143
151
  describe "task :restart" do
@@ -147,6 +155,10 @@ describe Capistrano::Fanfare::Foreman do
147
155
 
148
156
  strategy.verify
149
157
  end
158
+
159
+ it "calls foreman:restart task after deploy:restart" do
160
+ @config.must_have_callback_after "deploy:restart", "foreman:restart"
161
+ end
150
162
  end
151
163
 
152
164
  describe "task :ps" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-fanfare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-17 00:00:00.000000000 Z
12
+ date: 2012-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &70216612714240 !ruby/object:Gem::Requirement
16
+ requirement: &70360322152180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.10.0.pre
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70216612714240
24
+ version_requirements: *70360322152180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capistrano_colors
27
- requirement: &70216612713480 !ruby/object:Gem::Requirement
27
+ requirement: &70360322151440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.5'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70216612713480
35
+ version_requirements: *70360322151440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70216612712740 !ruby/object:Gem::Requirement
38
+ requirement: &70360322150660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.10.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70216612712740
46
+ version_requirements: *70360322150660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest-capistrano
49
- requirement: &70216612711920 !ruby/object:Gem::Requirement
49
+ requirement: &70360322149900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70216612711920
57
+ version_requirements: *70360322149900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: timecop
60
- requirement: &70216612711380 !ruby/object:Gem::Requirement
60
+ requirement: &70360322149340 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0.3'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70216612711380
68
+ version_requirements: *70360322149340
69
69
  description: Capistrano recipes (with full test suite) for fanfare application deployment
70
70
  framework
71
71
  email:
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: -996615476762693867
120
+ hash: 805475541908766951
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: -996615476762693867
129
+ hash: 805475541908766951
130
130
  requirements: []
131
131
  rubyforge_project:
132
132
  rubygems_version: 1.8.10