recap 0.1.0 → 0.2.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.
Files changed (61) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +4 -0
  3. data/README.md +12 -3
  4. data/Rakefile +8 -0
  5. data/Vagrantfile +61 -0
  6. data/doc/index.html +45 -26
  7. data/doc/lib/recap/bootstrap.html +42 -0
  8. data/doc/lib/recap/bundler.html +36 -19
  9. data/doc/lib/recap/capistrano_extensions.html +28 -23
  10. data/doc/lib/recap/cli.html +3 -0
  11. data/doc/lib/recap/compatibility.html +6 -3
  12. data/doc/lib/recap/deploy.html +41 -86
  13. data/doc/lib/recap/env.html +6 -1
  14. data/doc/lib/recap/foreman.html +3 -0
  15. data/doc/lib/recap/namespace.html +42 -0
  16. data/doc/lib/recap/preflight.html +12 -7
  17. data/doc/lib/recap/rails.html +3 -0
  18. data/doc/lib/recap/version.html +3 -0
  19. data/doc/lib/recap.html +42 -0
  20. data/features/bundling-gems.feature +18 -0
  21. data/features/deploying-projects.feature +21 -0
  22. data/features/managing-processes.feature +17 -0
  23. data/features/setting-environment-variables.feature +21 -0
  24. data/features/steps/capistrano_steps.rb +98 -0
  25. data/features/support/project.rb +211 -0
  26. data/features/support/server.rb +53 -0
  27. data/features/templates/gem/binary.erb +43 -0
  28. data/features/templates/gem/gemspec.erb +11 -0
  29. data/features/templates/project/Capfile +21 -0
  30. data/features/templates/project/Capfile.erb +21 -0
  31. data/features/templates/project/Gemfile.erb +7 -0
  32. data/features/templates/project/Procfile.erb +1 -0
  33. data/index.rb +26 -17
  34. data/lib/recap/bootstrap.rb +47 -0
  35. data/lib/recap/bundler.rb +31 -21
  36. data/lib/recap/capistrano_extensions.rb +11 -9
  37. data/lib/recap/cli.rb +1 -1
  38. data/lib/recap/compatibility.rb +3 -3
  39. data/lib/recap/deploy.rb +45 -57
  40. data/lib/recap/env.rb +30 -26
  41. data/lib/recap/environment.rb +54 -0
  42. data/lib/recap/foreman.rb +28 -9
  43. data/lib/recap/namespace.rb +37 -0
  44. data/lib/recap/preflight.rb +10 -8
  45. data/lib/recap/rails.rb +6 -4
  46. data/lib/recap/ruby.rb +3 -0
  47. data/lib/recap/static.rb +1 -0
  48. data/lib/recap/version.rb +1 -1
  49. data/lib/recap.rb +12 -0
  50. data/recap.gemspec +8 -4
  51. data/spec/models/environment_spec.rb +143 -0
  52. data/spec/spec_helper.rb +7 -0
  53. data/spec/tasks/bootstrap_spec.rb +34 -0
  54. data/spec/tasks/bundler_spec.rb +126 -0
  55. data/spec/tasks/deploy_spec.rb +209 -0
  56. data/spec/tasks/env_spec.rb +38 -0
  57. data/spec/tasks/foreman_spec.rb +154 -0
  58. data/test-vm/manifests/base.pp +17 -0
  59. data/test-vm/share/.gitkeep +0 -0
  60. metadata +138 -19
  61. /data/bin/{tomafro-deploy → recap} +0 -0
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
1
  *.gem
2
2
  .bundle
3
+ .vagrant
3
4
  Gemfile.lock
4
5
  pkg/*
6
+ /test-vm/share/*
7
+ capistrano.log
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
data/README.md CHANGED
@@ -1,5 +1,14 @@
1
- [recap](http://github.com/freerange/recap) is a simple, EXPERIMENTAL, opinionated set of capistrano deployment recipes, using git's strengths to deploy applications in a fast and simple manner.
1
+ [recap](http://github.com/freerange/recap) is an opinionated set of capistrano deployment recipes, designed to use git's strengths to deploy applications and websites in a fast and simple manner.
2
2
 
3
- It started as a playaround with git, and is slowly evolving into something useful (though it isn't there) yet. There are lots of gaps, and half-thought-through ideas. Also, it needs a proper name.
3
+ Recap's core features are:
4
4
 
5
- The main documentation can be found at [http://code.gofreerange.com/recap](http://code.gofreerange.com/recap), while the code is available [on github](https://github.com/freerange/recap) and released under the [MIT License](https://github.com/freerange/recap/blob/master/LICENSE).
5
+ * Release versions are managed with git. There's no need for `releases` or `current` folders, and no symlinking.
6
+ * Intelligently decides whether tasks need to execute. e.g. The `bundle:install` task will only run if a `Gemfile.lock` exists, and if it has changed since the last deployment.
7
+ * A dedicated user account and group owns all an application's associated files and processes.
8
+ * Deployments are run using personal logins. The right to deploy is granted by adding a user to the application group.
9
+ * Environment variables are used for application specific configuration. These can easily be read and set using the `env` and `env:set` tasks.
10
+ * Out of the box support for `bundler` and `foreman`
11
+
12
+ For more information, the main documentation can be found at [http://code.gofreerange.com/recap](http://code.gofreerange.com/recap), while the code is available [on github](https://github.com/freerange/recap).
13
+
14
+ Recap was written by [Tom Ward](http://tomafro.net) and the other members of [Go Free Range](http://gofreerange.com), and is released under the [MIT License](https://github.com/freerange/recap/blob/master/LICENSE).
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rocco/tasks'
3
+ require 'rspec/core/rake_task'
3
4
 
4
5
  desc 'build docs'
5
6
  Rocco::Task.new :rocco, 'doc/', ['index.rb', 'lib/**/*.rb']
@@ -10,3 +11,10 @@ task :publish do
10
11
  commit = `echo "Publishing docs from master branch" | git commit-tree #{sha} -p refs/heads/gh-pages`.strip
11
12
  `git update-ref refs/heads/gh-pages #{commit}`
12
13
  end
14
+
15
+ RSpec::Core::RakeTask.new(:spec) do |t|
16
+ t.pattern = "spec/**/*_spec.rb"
17
+ t.rspec_opts = "-fn --color"
18
+ end
19
+
20
+ task :default => :spec
data/Vagrantfile ADDED
@@ -0,0 +1,61 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "lucid64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ # config.vm.network :hostonly, "33.33.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ config.vm.share_folder 'test', '/recap/share', 'test-vm/share'
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file base.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ config.vm.provision :puppet do |puppet|
58
+ puppet.manifests_path = "test-vm/manifests"
59
+ puppet.manifest_file = "base.pp"
60
+ end
61
+ end
data/doc/index.html CHANGED
@@ -13,6 +13,8 @@
13
13
  <div id="jump_wrapper">
14
14
  <div id="jump_page">
15
15
  <a class="source" href="index.html">index.rb</a>
16
+ <a class="source" href="lib/recap.html">recap.rb</a>
17
+ <a class="source" href="lib/recap/bootstrap.html">bootstrap.rb</a>
16
18
  <a class="source" href="lib/recap/bundler.html">bundler.rb</a>
17
19
  <a class="source" href="lib/recap/capistrano_extensions.html">capistrano_extensions.rb</a>
18
20
  <a class="source" href="lib/recap/cli.html">cli.rb</a>
@@ -20,6 +22,7 @@
20
22
  <a class="source" href="lib/recap/deploy.html">deploy.rb</a>
21
23
  <a class="source" href="lib/recap/env.html">env.rb</a>
22
24
  <a class="source" href="lib/recap/foreman.html">foreman.rb</a>
25
+ <a class="source" href="lib/recap/namespace.html">namespace.rb</a>
23
26
  <a class="source" href="lib/recap/preflight.html">preflight.rb</a>
24
27
  <a class="source" href="lib/recap/rails.html">rails.rb</a>
25
28
  <a class="source" href="lib/recap/version.html">version.rb</a>
@@ -79,8 +82,8 @@ There&rsquo;s no need for <code>releases</code>, <code>shared</code> or <code>cu
79
82
  <a class="pilcrow" href="#section-4">&#182;</a>
80
83
  </div>
81
84
  <p>Run all commands as the <code>application_user</code>, loading the full user environment. The only
82
- exceptions are <code>git</code> commands (which often rely on SSH agent forwarding for authentication), and anything
83
- that requires <code>sudo</code>.</p>
85
+ exceptions are <code>git</code> commands (which often rely on SSH agent forwarding for authentication), and
86
+ anything that requires <code>sudo</code>.</p>
84
87
  </td>
85
88
  <td class=code>
86
89
  <div class='highlight'><pre></pre></div>
@@ -92,8 +95,8 @@ that requires <code>sudo</code>.</p>
92
95
  <a class="pilcrow" href="#section-5">&#182;</a>
93
96
  </div>
94
97
  <p>Use <code>git</code> to avoid unecessary work. If the <code>Gemfile.lock</code> hasn&rsquo;t changed, there&rsquo;s no need to run
95
- <code>bundle install</code>. Similarly if there are no new migrations, why do <code>rake db:migrate</code>. Faster deploys
96
- mean more frequent deploys, which in our experience leads to better applications.</p>
98
+ <code>bundle install</code>. Similarly if there are no new migrations, why do <code>rake db:migrate</code>? Faster
99
+ deploys mean more frequent deploys.</p>
97
100
  </td>
98
101
  <td class=code>
99
102
  <div class='highlight'><pre></pre></div>
@@ -104,9 +107,9 @@ mean more frequent deploys, which in our experience leads to better applications
104
107
  <div class="pilwrap">
105
108
  <a class="pilcrow" href="#section-6">&#182;</a>
106
109
  </div>
107
- <p>Avoid the use of <code>sudo</code> (other than to change to the <code>application_user</code>). As much as possible, <code>sudo</code>
108
- is only used to <code>su</code> to the <code>application_user</code> before running a command. To avoid typing a password
109
- to perform the majority of deployment tasks, this code can be added to
110
+ <p>Avoid the use of <code>sudo</code> (other than to change to the <code>application_user</code>). As much as possible,
111
+ <code>sudo</code> is only used to <code>su</code> to the <code>application_user</code> before running a command. To avoid having to
112
+ type a password to perform the majority of deployment tasks, these lines can be added to
110
113
  <code>/etc/sudoers.d/application</code> (change <code>application</code> to the name of your app).</p>
111
114
  </td>
112
115
  <td class=code>
@@ -117,25 +120,25 @@ to perform the majority of deployment tasks, this code can be added to
117
120
  <span class="o">%</span><span class="n">application</span> <span class="no">ALL</span><span class="o">=</span><span class="no">NOPASSWD</span><span class="p">:</span><span class="sr"> /bin/su</span> <span class="n">application</span><span class="o">*</span></pre></div>
118
121
  </td>
119
122
  </tr>
120
- <tr id='section-Code_layout'>
123
+ <tr id='section-7'>
121
124
  <td class=docs>
122
125
  <div class="pilwrap">
123
- <a class="pilcrow" href="#section-Code_layout">&#182;</a>
126
+ <a class="pilcrow" href="#section-7">&#182;</a>
124
127
  </div>
125
- <h3>Code layout</h3>
128
+ <p>Use environment variables for configuration. Rather than setting <code>rails_env</code> in the <code>Capfile</code>,
129
+ <code>RAILS_ENV</code> (or <code>RACK_ENV</code>) variables should be set for the <code>application_user</code>. The <code>env:set</code> and
130
+ <code>env:edit</code> tasks help do this.</p>
126
131
  </td>
127
132
  <td class=code>
128
133
  <div class='highlight'><pre></pre></div>
129
134
  </td>
130
135
  </tr>
131
- <tr id='section-8'>
136
+ <tr id='section-Code_layout'>
132
137
  <td class=docs>
133
138
  <div class="pilwrap">
134
- <a class="pilcrow" href="#section-8">&#182;</a>
139
+ <a class="pilcrow" href="#section-Code_layout">&#182;</a>
135
140
  </div>
136
- <p>The main deployment tasks are defined in <a href="lib/recap.html">recap.rb</a>. Automatic
137
- checks to ensure servers are correctly setup are in
138
- <a href="lib/recap/preflight.html">recap/preflight.rb</a>.</p>
141
+ <h3>Code layout</h3>
139
142
  </td>
140
143
  <td class=code>
141
144
  <div class='highlight'><pre></pre></div>
@@ -146,8 +149,10 @@ checks to ensure servers are correctly setup are in
146
149
  <div class="pilwrap">
147
150
  <a class="pilcrow" href="#section-9">&#182;</a>
148
151
  </div>
149
- <p>In addition, there are extensions for <a href="lib/recap/bundler.html">bundler</a> and
150
- <a href="lib/recap/foreman.html">foreman</a>.</p>
152
+ <p>The main deployment tasks are defined in <a href="lib/recap/deploy.html">recap/deploy.rb</a>. Automatic
153
+ checks to ensure servers are correctly setup are in
154
+ <a href="lib/recap/preflight.html">recap/preflight.rb</a>, while tasks for environment variables are in
155
+ <a href="lib/recap/env.html">recap/env.rb</a></p>
151
156
  </td>
152
157
  <td class=code>
153
158
  <div class='highlight'><pre></pre></div>
@@ -158,30 +163,31 @@ checks to ensure servers are correctly setup are in
158
163
  <div class="pilwrap">
159
164
  <a class="pilcrow" href="#section-10">&#182;</a>
160
165
  </div>
161
- <p>For (limited) compatability with other existing recipes, see
162
- <a href="lib/recap/compatibility.html">compatibility</a></p>
166
+ <p>In addition, there are extensions for <a href="lib/recap/bundler.html">bundler</a>,
167
+ <a href="lib/recap/foreman.html">foreman</a> and <a href="lib/recap/rails.html">rails</a></p>
163
168
  </td>
164
169
  <td class=code>
165
170
  <div class='highlight'><pre></pre></div>
166
171
  </td>
167
172
  </tr>
168
- <tr id='section-Deployment_target'>
173
+ <tr id='section-11'>
169
174
  <td class=docs>
170
175
  <div class="pilwrap">
171
- <a class="pilcrow" href="#section-Deployment_target">&#182;</a>
176
+ <a class="pilcrow" href="#section-11">&#182;</a>
172
177
  </div>
173
- <h3>Deployment target</h3>
178
+ <p>For limited compatability with other existing recipes, see
179
+ <a href="lib/recap/compatibility.html">compatibility</a>.</p>
174
180
  </td>
175
181
  <td class=code>
176
182
  <div class='highlight'><pre></pre></div>
177
183
  </td>
178
184
  </tr>
179
- <tr id='section-12'>
185
+ <tr id='section-Deployment_target'>
180
186
  <td class=docs>
181
187
  <div class="pilwrap">
182
- <a class="pilcrow" href="#section-12">&#182;</a>
188
+ <a class="pilcrow" href="#section-Deployment_target">&#182;</a>
183
189
  </div>
184
- <p>These recipes have been run successful against Ubuntu.</p>
190
+ <h3>Deployment target</h3>
185
191
  </td>
186
192
  <td class=code>
187
193
  <div class='highlight'><pre></pre></div>
@@ -192,7 +198,8 @@ checks to ensure servers are correctly setup are in
192
198
  <div class="pilwrap">
193
199
  <a class="pilcrow" href="#section-13">&#182;</a>
194
200
  </div>
195
- <p>The application should be run as the application user; if using Apache and Passenger, you should set the <code>PassengerDefaultUser</code> directive to be the same as the <code>application_user</code>.</p>
201
+ <p>These recipes have been developed and tested using Ubuntu 11.04, though they may work well with
202
+ other flavours of unix.</p>
196
203
  </td>
197
204
  <td class=code>
198
205
  <div class='highlight'><pre></pre></div>
@@ -203,6 +210,18 @@ checks to ensure servers are correctly setup are in
203
210
  <div class="pilwrap">
204
211
  <a class="pilcrow" href="#section-14">&#182;</a>
205
212
  </div>
213
+ <p>The application should be run as the application user; if using Apache and Passenger, you should
214
+ set the <code>PassengerDefaultUser</code> directive to be the same as the <code>application_user</code>.</p>
215
+ </td>
216
+ <td class=code>
217
+ <div class='highlight'><pre></pre></div>
218
+ </td>
219
+ </tr>
220
+ <tr id='section-15'>
221
+ <td class=docs>
222
+ <div class="pilwrap">
223
+ <a class="pilcrow" href="#section-15">&#182;</a>
224
+ </div>
206
225
  <p>The code is available <a href="http://github.com/freerange/recap">on github</a> and released under the
207
226
  <a href="https://github.com/freerange/recap/blob/master/LICENSE">MIT License</a></p>
208
227
 
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>bootstrap.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../index.html">index.rb</a>
16
+ <a class="source" href="../recap.html">recap.rb</a>
17
+ <a class="source" href="bootstrap.html">bootstrap.rb</a>
18
+ <a class="source" href="bundler.html">bundler.rb</a>
19
+ <a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
20
+ <a class="source" href="cli.html">cli.rb</a>
21
+ <a class="source" href="compatibility.html">compatibility.rb</a>
22
+ <a class="source" href="deploy.html">deploy.rb</a>
23
+ <a class="source" href="env.html">env.rb</a>
24
+ <a class="source" href="foreman.html">foreman.rb</a>
25
+ <a class="source" href="namespace.html">namespace.rb</a>
26
+ <a class="source" href="preflight.html">preflight.rb</a>
27
+ <a class="source" href="rails.html">rails.rb</a>
28
+ <a class="source" href="version.html">version.rb</a>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <table cellspacing=0 cellpadding=0>
33
+ <thead>
34
+ <tr>
35
+ <th class=docs><h1>bootstrap.rb</h1></th>
36
+ <th class=code></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ </table>
41
+ </div>
42
+ </body>
@@ -13,6 +13,8 @@
13
13
  <div id="jump_wrapper">
14
14
  <div id="jump_page">
15
15
  <a class="source" href="../../index.html">index.rb</a>
16
+ <a class="source" href="../recap.html">recap.rb</a>
17
+ <a class="source" href="bootstrap.html">bootstrap.rb</a>
16
18
  <a class="source" href="bundler.html">bundler.rb</a>
17
19
  <a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
18
20
  <a class="source" href="cli.html">cli.rb</a>
@@ -20,6 +22,7 @@
20
22
  <a class="source" href="deploy.html">deploy.rb</a>
21
23
  <a class="source" href="env.html">env.rb</a>
22
24
  <a class="source" href="foreman.html">foreman.rb</a>
25
+ <a class="source" href="namespace.html">namespace.rb</a>
23
26
  <a class="source" href="preflight.html">preflight.rb</a>
24
27
  <a class="source" href="rails.html">rails.rb</a>
25
28
  <a class="source" href="version.html">version.rb</a>
@@ -42,7 +45,10 @@
42
45
  <p>The bundler recipe ensures that the application bundle is installed whenever the code is updated.</p>
43
46
  </td>
44
47
  <td class=code>
45
- <div class='highlight'><pre><span class="no">Capistrano</span><span class="o">::</span><span class="no">Configuration</span><span class="o">.</span><span class="n">instance</span><span class="p">(</span><span class="ss">:must_exist</span><span class="p">)</span><span class="o">.</span><span class="n">load</span> <span class="k">do</span></pre></div>
48
+ <div class='highlight'><pre><span class="k">module</span> <span class="nn">Recap::Bundler</span>
49
+ <span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">Namespace</span>
50
+
51
+ <span class="n">namespace</span> <span class="ss">:bundle</span> <span class="k">do</span></pre></div>
46
52
  </td>
47
53
  </tr>
48
54
  <tr id='section-2'>
@@ -53,7 +59,7 @@
53
59
  <p>Each bundle is declared in a <code>Gemfile</code>, by default in the root of the application directory</p>
54
60
  </td>
55
61
  <td class=code>
56
- <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_gemfile</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">/Gemfile&quot;</span> <span class="p">}</span></pre></div>
62
+ <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_gemfile</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">/Gemfile&quot;</span> <span class="p">}</span></pre></div>
57
63
  </td>
58
64
  </tr>
59
65
  <tr id='section-3'>
@@ -64,7 +70,7 @@
64
70
  <p>As well as a <code>Gemfile</code>, application repositories should also contain a <code>Gemfile.lock</code>.</p>
65
71
  </td>
66
72
  <td class=code>
67
- <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_gemfile_lock</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">bundle_gemfile</span><span class="si">}</span><span class="s2">.lock&quot;</span> <span class="p">}</span></pre></div>
73
+ <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_gemfile_lock</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">bundle_gemfile</span><span class="si">}</span><span class="s2">.lock&quot;</span> <span class="p">}</span></pre></div>
68
74
  </td>
69
75
  </tr>
70
76
  <tr id='section-4'>
@@ -73,10 +79,10 @@
73
79
  <a class="pilcrow" href="#section-4">&#182;</a>
74
80
  </div>
75
81
  <p>An application&rsquo;s gems are installed within the application directory. By default they are
76
- places under <code>.bundle/gems</code>.</p>
82
+ placed under <code>vendor/gems</code>.</p>
77
83
  </td>
78
84
  <td class=code>
79
- <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_dir</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">/.bundle/gems&quot;</span> <span class="p">}</span></pre></div>
85
+ <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_path</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">/vendor/gems&quot;</span> <span class="p">}</span></pre></div>
80
86
  </td>
81
87
  </tr>
82
88
  <tr id='section-5'>
@@ -88,10 +94,7 @@ places under <code>.bundle/gems</code>.</p>
88
94
  <code>assets</code> groups are skipped.</p>
89
95
  </td>
90
96
  <td class=code>
91
- <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_without</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;development test assets&quot;</span> <span class="p">}</span>
92
-
93
- <span class="n">namespace</span> <span class="ss">:bundle</span> <span class="k">do</span>
94
- <span class="n">namespace</span> <span class="ss">:install</span> <span class="k">do</span></pre></div>
97
+ <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_without</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;development test assets&quot;</span> <span class="p">}</span></pre></div>
95
98
  </td>
96
99
  </tr>
97
100
  <tr id='section-6'>
@@ -99,6 +102,20 @@ places under <code>.bundle/gems</code>.</p>
99
102
  <div class="pilwrap">
100
103
  <a class="pilcrow" href="#section-6">&#182;</a>
101
104
  </div>
105
+ <p>The main bundle install command uses all the settings above, together with the <code>&mdash;deployment</code>,
106
+ <code>&mdash;binstubs</code> and <code>&mdash;quiet</code> flags</p>
107
+ </td>
108
+ <td class=code>
109
+ <div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_install_command</span><span class="p">)</span> <span class="p">{</span> <span class="s2">&quot;bundle install --gemfile </span><span class="si">#{</span><span class="n">bundle_gemfile</span><span class="si">}</span><span class="s2"> --path </span><span class="si">#{</span><span class="n">bundle_path</span><span class="si">}</span><span class="s2"> --deployment --quiet --binstubs --without </span><span class="si">#{</span><span class="n">bundle_without</span><span class="si">}</span><span class="s2">&quot;</span> <span class="p">}</span>
110
+
111
+ <span class="n">namespace</span> <span class="ss">:install</span> <span class="k">do</span></pre></div>
112
+ </td>
113
+ </tr>
114
+ <tr id='section-7'>
115
+ <td class=docs>
116
+ <div class="pilwrap">
117
+ <a class="pilcrow" href="#section-7">&#182;</a>
118
+ </div>
102
119
  <p>After cloning or updating the code, we only install the bundle if the <code>Gemfile</code> has changed.</p>
103
120
  </td>
104
121
  <td class=code>
@@ -110,10 +127,10 @@ places under <code>.bundle/gems</code>.</p>
110
127
  <span class="k">end</span></pre></div>
111
128
  </td>
112
129
  </tr>
113
- <tr id='section-7'>
130
+ <tr id='section-8'>
114
131
  <td class=docs>
115
132
  <div class="pilwrap">
116
- <a class="pilcrow" href="#section-7">&#182;</a>
133
+ <a class="pilcrow" href="#section-8">&#182;</a>
117
134
  </div>
118
135
  <p>Occassionally it&rsquo;s useful to force an install (such as if something has gone wrong in
119
136
  a previous deployment)</p>
@@ -121,28 +138,28 @@ a previous deployment)</p>
121
138
  <td class=code>
122
139
  <div class='highlight'><pre> <span class="n">desc</span> <span class="s2">&quot;Install the latest gem bundle&quot;</span>
123
140
  <span class="n">task</span> <span class="ss">:default</span> <span class="k">do</span>
124
- <span class="k">if</span> <span class="n">deployed_file_exists?</span><span class="p">(</span><span class="n">bundle_gemfile</span><span class="p">)</span>
125
- <span class="n">bundler</span> <span class="s2">&quot;install --gemfile </span><span class="si">#{</span><span class="n">bundle_gemfile</span><span class="si">}</span><span class="s2"> --path </span><span class="si">#{</span><span class="n">bundle_dir</span><span class="si">}</span><span class="s2"> --deployment --quiet --binstubs --without </span><span class="si">#{</span><span class="n">bundle_without</span><span class="si">}</span><span class="s2">&quot;</span>
141
+ <span class="k">if</span> <span class="n">deployed_file_exists?</span><span class="p">(</span><span class="n">bundle_gemfile_lock</span><span class="p">)</span>
142
+ <span class="n">as_app</span> <span class="n">bundle_install_command</span>
126
143
  <span class="k">else</span>
127
144
  <span class="nb">puts</span> <span class="s2">&quot;Skipping bundle:install as no Gemfile found&quot;</span>
128
145
  <span class="k">end</span>
129
146
  <span class="k">end</span>
130
- <span class="k">end</span>
131
- <span class="k">end</span></pre></div>
147
+ <span class="k">end</span></pre></div>
132
148
  </td>
133
149
  </tr>
134
- <tr id='section-8'>
150
+ <tr id='section-9'>
135
151
  <td class=docs>
136
152
  <div class="pilwrap">
137
- <a class="pilcrow" href="#section-8">&#182;</a>
153
+ <a class="pilcrow" href="#section-9">&#182;</a>
138
154
  </div>
139
155
  <p>To install the bundle automatically each time the code is updated or cloned, hooks are added to
140
156
  the <code>deploy:clone_code</code> and <code>deploy:update_code</code> tasks.</p>
141
157
 
142
158
  </td>
143
159
  <td class=code>
144
- <div class='highlight'><pre> <span class="n">after</span> <span class="s1">&#39;deploy:clone_code&#39;</span><span class="p">,</span> <span class="s1">&#39;bundle:install:if_changed&#39;</span>
145
- <span class="n">after</span> <span class="s1">&#39;deploy:update_code&#39;</span><span class="p">,</span> <span class="s1">&#39;bundle:install:if_changed&#39;</span>
160
+ <div class='highlight'><pre> <span class="n">after</span> <span class="s1">&#39;deploy:clone_code&#39;</span><span class="p">,</span> <span class="s1">&#39;bundle:install:if_changed&#39;</span>
161
+ <span class="n">after</span> <span class="s1">&#39;deploy:update_code&#39;</span><span class="p">,</span> <span class="s1">&#39;bundle:install:if_changed&#39;</span>
162
+ <span class="k">end</span>
146
163
  <span class="k">end</span></pre></div>
147
164
  </td>
148
165
  </tr>