baldowl-rupostrano 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.rdoc +23 -0
- data/Manifest +10 -0
- data/README.rdoc +26 -0
- data/Rakefile +15 -0
- data/bin/rupostrano +13 -0
- data/lib/rupostrano.rb +395 -0
- data/rupostrano.gemspec +74 -0
- data/templates/Capfile +5 -0
- data/templates/deploy.rb +15 -0
- data/templates/environment.rb +44 -0
- metadata +76 -0
data/LICENSE.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= LICENSE
|
2
|
+
|
3
|
+
(The MIT License)
|
4
|
+
|
5
|
+
Copyright (c) 2009 Emanuele Vicentini
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the 'Software'), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= Ruport + Capistrano = Rupostrano
|
2
|
+
|
3
|
+
Capistrano's recipe tailored to deploy Ruport-base standalone application.
|
4
|
+
|
5
|
+
Everything is based on Capistrano 2.5.5, copyright (c) 2005-2008 Jamis Buck
|
6
|
+
<jamis@37signals.com>
|
7
|
+
|
8
|
+
== Usage
|
9
|
+
|
10
|
+
In your Ruport-base standalone application's root run:
|
11
|
+
|
12
|
+
$ rupostrano
|
13
|
+
|
14
|
+
This will write Capfile, config/deploy.rb and config/environment.rb
|
15
|
+
(overwriting them if they alread exist, but you have VCS in place, don't you?)
|
16
|
+
|
17
|
+
Edit config/deploy.rb to your taste and needs and run
|
18
|
+
|
19
|
+
$ cap -T
|
20
|
+
|
21
|
+
to see the available tasks. Then
|
22
|
+
|
23
|
+
$ cap deploy:setup
|
24
|
+
$ cap deploy
|
25
|
+
|
26
|
+
and enjoy the life.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'echoe'
|
3
|
+
|
4
|
+
Echoe.new('rupostrano', '0.0.1') do |s|
|
5
|
+
s.author = 'Emanuele Vicentini'
|
6
|
+
s.email = 'emanuele.vicentini@gmail.com'
|
7
|
+
s.summary = 'Ruport + Capistrano = Rupostrano :-)'
|
8
|
+
s.runtime_dependencies = ['capistrano >=2.4.0']
|
9
|
+
s.need_tar_gz = false
|
10
|
+
s.project = 'rupostrano'
|
11
|
+
s.gemspec_format = :yaml
|
12
|
+
s.retain_gemspec = true
|
13
|
+
s.rdoc_pattern = /^README|^LICENSE/
|
14
|
+
s.url = 'http://github.com/baldowl/rupostrano'
|
15
|
+
end
|
data/bin/rupostrano
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
FileUtils.cp File.join(File.dirname(__FILE__), '..', 'templates', 'Capfile'),
|
6
|
+
File.join(Dir.pwd, 'Capfile')
|
7
|
+
|
8
|
+
FileUtils.mkdir_p File.join(Dir.pwd, 'config')
|
9
|
+
|
10
|
+
FileUtils.cp File.join(File.dirname(__FILE__), '..', 'templates', 'environment.rb'),
|
11
|
+
File.join(Dir.pwd, 'config', 'environment.rb')
|
12
|
+
FileUtils.cp File.join(File.dirname(__FILE__), '..', 'templates', 'deploy.rb'),
|
13
|
+
File.join(Dir.pwd, 'config', 'deploy.rb')
|
data/lib/rupostrano.rb
ADDED
@@ -0,0 +1,395 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
require 'capistrano/recipes/deploy/scm'
|
3
|
+
require 'capistrano/recipes/deploy/strategy'
|
4
|
+
|
5
|
+
def _cset(name, *args, &block)
|
6
|
+
unless exists?(name)
|
7
|
+
set(name, *args, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# =========================================================================
|
12
|
+
# These variables MUST be set in the client capfiles. If they are not set,
|
13
|
+
# the deploy will fail with an error.
|
14
|
+
# =========================================================================
|
15
|
+
|
16
|
+
_cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
|
17
|
+
_cset(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }
|
18
|
+
|
19
|
+
# =========================================================================
|
20
|
+
# These variables may be set in the client capfile if their default values
|
21
|
+
# are not sufficient.
|
22
|
+
# =========================================================================
|
23
|
+
|
24
|
+
_cset :scm, :subversion
|
25
|
+
_cset :deploy_via, :copy
|
26
|
+
_cset :copy_strategy, :export
|
27
|
+
_cset :copy_compression, :bzip2
|
28
|
+
_cset :user, 'www-data'
|
29
|
+
_cset :group, 'www-data'
|
30
|
+
|
31
|
+
_cset(:deploy_to) { "/u/apps/#{application}" }
|
32
|
+
_cset(:revision) { source.head }
|
33
|
+
|
34
|
+
# =========================================================================
|
35
|
+
# These variables should NOT be changed unless you are very confident in
|
36
|
+
# what you are doing. Make sure you understand all the implications of your
|
37
|
+
# changes if you do decide to muck with these!
|
38
|
+
# =========================================================================
|
39
|
+
|
40
|
+
_cset(:source) { Capistrano::Deploy::SCM.new(scm, self) }
|
41
|
+
_cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } }
|
42
|
+
|
43
|
+
_cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
|
44
|
+
|
45
|
+
_cset(:release_name) { set :deploy_timestamped, true; Time.now.strftime('%Y%m%dT%H%M%S%z') }
|
46
|
+
|
47
|
+
_cset :version_dir, 'releases'
|
48
|
+
_cset :shared_dir, 'shared'
|
49
|
+
_cset :shared_children, %w(system log pids)
|
50
|
+
_cset :current_dir, 'current'
|
51
|
+
|
52
|
+
_cset(:releases_path) { File.join(deploy_to, version_dir) }
|
53
|
+
_cset(:shared_path) { File.join(deploy_to, shared_dir) }
|
54
|
+
_cset(:current_path) { File.join(deploy_to, current_dir) }
|
55
|
+
_cset(:release_path) { File.join(releases_path, release_name) }
|
56
|
+
|
57
|
+
_cset(:releases) { capture("ls -xt #{releases_path}").split.reverse }
|
58
|
+
_cset(:current_release) { File.join(releases_path, releases.last) }
|
59
|
+
_cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }
|
60
|
+
|
61
|
+
_cset(:current_revision) { capture("cat #{current_path}/REVISION").chomp }
|
62
|
+
_cset(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
|
63
|
+
_cset(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }
|
64
|
+
|
65
|
+
_cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
|
66
|
+
|
67
|
+
# some tasks, like symlink, need to always point at the latest release, but
|
68
|
+
# they can also (occassionally) be called standalone. In the standalone case,
|
69
|
+
# the timestamped release_path will be inaccurate, since the directory won't
|
70
|
+
# actually exist. This variable lets tasks like symlink work either in the
|
71
|
+
# standalone case, or during deployment.
|
72
|
+
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
|
73
|
+
|
74
|
+
# =========================================================================
|
75
|
+
# These are helper methods that will be available to your recipes.
|
76
|
+
# =========================================================================
|
77
|
+
|
78
|
+
# Auxiliary helper method for the `deploy:check' task. Lets you set up your
|
79
|
+
# own dependencies.
|
80
|
+
def depend(location, type, *args)
|
81
|
+
deps = fetch(:dependencies, {})
|
82
|
+
deps[location] ||= {}
|
83
|
+
deps[location][type] ||= []
|
84
|
+
deps[location][type] << args
|
85
|
+
set :dependencies, deps
|
86
|
+
end
|
87
|
+
|
88
|
+
# Temporarily sets an environment variable, yields to a block, and restores
|
89
|
+
# the value when it is done.
|
90
|
+
def with_env(name, value)
|
91
|
+
saved, ENV[name] = ENV[name], value
|
92
|
+
yield
|
93
|
+
ensure
|
94
|
+
ENV[name] = saved
|
95
|
+
end
|
96
|
+
|
97
|
+
# logs the command then executes it locally. returns the command output as a
|
98
|
+
# string
|
99
|
+
def run_locally(cmd)
|
100
|
+
logger.trace "executing locally: #{cmd.inspect}" if logger
|
101
|
+
`#{cmd}`
|
102
|
+
end
|
103
|
+
|
104
|
+
# If a command is given, this will try to execute the given command, as
|
105
|
+
# described below. Otherwise, it will return a string for use in embedding in
|
106
|
+
# another command, for executing that command as described below.
|
107
|
+
#
|
108
|
+
# If :run_method is :sudo (or :use_sudo is true), this executes the given
|
109
|
+
# command via +sudo+. Otherwise is uses +run+. If :as is given as a key, it
|
110
|
+
# will be passed as the user to sudo as, if using sudo. If the :as key is not
|
111
|
+
# given, it will default to whatever the value of the :admin_runner variable
|
112
|
+
# is, which (by default) is unset.
|
113
|
+
#
|
114
|
+
# THUS, if you want to try to run something via sudo, and what to use the root
|
115
|
+
# user, you'd just to try_sudo('something'). If you wanted to try_sudo as
|
116
|
+
# someone else, you'd just do try_sudo('something', :as => "bob"). If you
|
117
|
+
# always wanted sudo to run as a particular user, you could do
|
118
|
+
# set(:admin_runner, "bob").
|
119
|
+
def try_sudo(*args)
|
120
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
121
|
+
command = args.shift
|
122
|
+
raise ArgumentError, "too many arguments" if args.any?
|
123
|
+
|
124
|
+
as = options.fetch(:as, fetch(:admin_runner, nil))
|
125
|
+
via = fetch(:run_method, :sudo)
|
126
|
+
if command
|
127
|
+
invoke_command(command, :via => via, :as => as)
|
128
|
+
elsif via == :sudo
|
129
|
+
sudo(:as => as)
|
130
|
+
else
|
131
|
+
""
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Same as sudo, but tries sudo with :as set to the value of the :runner
|
136
|
+
# variable (which defaults to "app").
|
137
|
+
def try_runner(*args)
|
138
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
139
|
+
args << options.merge(:as => fetch(:runner, "app"))
|
140
|
+
try_sudo(*args)
|
141
|
+
end
|
142
|
+
|
143
|
+
# =========================================================================
|
144
|
+
# These are the tasks that are available to help with deploying web apps,
|
145
|
+
# and specifically, Rails applications. You can have cap give you a summary
|
146
|
+
# of them with `cap -T'.
|
147
|
+
# =========================================================================
|
148
|
+
|
149
|
+
namespace :deploy do
|
150
|
+
desc <<-DESC
|
151
|
+
Deploys your project. This calls both `setup' and `update'.
|
152
|
+
DESC
|
153
|
+
task :default do
|
154
|
+
setup
|
155
|
+
update
|
156
|
+
end
|
157
|
+
|
158
|
+
desc <<-DESC
|
159
|
+
Prepares one or more servers for deployment. Before you can use any of \
|
160
|
+
the Capistrano deployment tasks with your project, you will need to make \
|
161
|
+
sure all of your servers have been prepared with `cap deploy:setup'. \
|
162
|
+
When you add a new server to your cluster, you can easily run the setup \
|
163
|
+
task on just that server by specifying the HOSTS environment variable:
|
164
|
+
|
165
|
+
$ cap HOSTS=new.server.com deploy:setup
|
166
|
+
|
167
|
+
It is safe to run this task on servers that have already been set up; it \
|
168
|
+
will not destroy any deployed revisions or data.
|
169
|
+
DESC
|
170
|
+
task :setup, :except => { :no_release => true } do
|
171
|
+
dirs = [deploy_to, releases_path, shared_path]
|
172
|
+
dirs += shared_children.map { |d| File.join(shared_path, d) }
|
173
|
+
run "#{try_sudo} mkdir -p #{dirs.join(' ')}"
|
174
|
+
run "#{try_sudo} chown -R #{user}:#{group} #{deploy_to}" if fetch(:change_ownership, false)
|
175
|
+
end
|
176
|
+
|
177
|
+
desc <<-DESC
|
178
|
+
Copies your project and updates the symlink. It does this in a \
|
179
|
+
transaction, so that if either `update_code' or `symlink' fail, all \
|
180
|
+
changes made to the remote servers will be rolled back, leaving your \
|
181
|
+
system in the same state it was in before `update' was invoked.
|
182
|
+
DESC
|
183
|
+
task :update do
|
184
|
+
transaction do
|
185
|
+
update_code
|
186
|
+
symlink
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
desc <<-DESC
|
191
|
+
Copies your project to the remote servers. This is the first stage of \
|
192
|
+
any deployment; moving your updated code and assets to the deployment \
|
193
|
+
servers. You will rarely call this task directly, however; instead, you \
|
194
|
+
should call the `deploy' task (to do a complete deploy).
|
195
|
+
|
196
|
+
You will need to make sure you set the :scm variable to the source \
|
197
|
+
control software you are using (it defaults to :subversion), and the \
|
198
|
+
:deploy_via variable to the strategy you want to use to deploy (it \
|
199
|
+
defaults to :copy).
|
200
|
+
DESC
|
201
|
+
task :update_code, :except => { :no_release => true } do
|
202
|
+
on_rollback { run "#{try_sudo} rm -rf #{release_path}; true" }
|
203
|
+
strategy.deploy!
|
204
|
+
share_resources
|
205
|
+
finalize_update
|
206
|
+
end
|
207
|
+
|
208
|
+
desc <<-DESC
|
209
|
+
[internal] Set up shared copies of key configuration files. This is \
|
210
|
+
called by update_code after the basic deploy ends. :shared_resources \
|
211
|
+
variable lists those files (paths relative to the application root).
|
212
|
+
DESC
|
213
|
+
task :share_resources, :except => { :no_release => true } do
|
214
|
+
resources = fetch(:shared_resources, [])
|
215
|
+
shared_files = resources.map {|f| File.join(shared_path, f)}
|
216
|
+
resources.map! {|f| File.join(latest_release, f)}
|
217
|
+
shared_files.each_with_index do |f, i|
|
218
|
+
run "if [ ! -f #{f} ]; then #{try_sudo} cp #{resources[i]} #{f}; fi"
|
219
|
+
run "#{try_sudo} rm -f #{resources[i]}; #{try_sudo} ln -s #{f} #{resources[i]}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
desc <<-DESC
|
224
|
+
[internal] This task will make the release group-writable (if the \
|
225
|
+
:group_writable variabile is set to true).
|
226
|
+
DESC
|
227
|
+
task :finalize_update, :except => { :no_release => true } do
|
228
|
+
run "#{try_sudo} chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
|
229
|
+
run "#{try_sudo} chown -R #{user}:#{group} #{latest_release}" if fetch(:change_ownership, true)
|
230
|
+
end
|
231
|
+
|
232
|
+
desc <<-DESC
|
233
|
+
Updates the symlink to the most recently deployed version. Capistrano \
|
234
|
+
works by putting each new release of your application in its own \
|
235
|
+
directory. When you deploy a new version, this task's job is to update \
|
236
|
+
the `current' symlink to point at the new version. You will rarely need \
|
237
|
+
to call this task directly; instead, use the `deploy' task (which \
|
238
|
+
performs a complete deploy) or the 'update' task (which does everything \
|
239
|
+
except `setup').
|
240
|
+
DESC
|
241
|
+
task :symlink, :except => { :no_release => true } do
|
242
|
+
on_rollback do
|
243
|
+
if previous_release
|
244
|
+
run "#{try_sudo} rm -f #{current_path}; #{try_sudo} ln -s #{previous_release} #{current_path}; true"
|
245
|
+
else
|
246
|
+
logger.important "no previous release to rollback to, rollback of symlink skipped"
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
run "#{try_sudo} rm -f #{current_path} && #{try_sudo} ln -s #{latest_release} #{current_path}"
|
251
|
+
end
|
252
|
+
|
253
|
+
desc <<-DESC
|
254
|
+
Copy files to the currently deployed version. This is useful for \
|
255
|
+
updating files piecemeal, such as when you need to quickly deploy only a \
|
256
|
+
single file. Some files, such as updated templates, images, or \
|
257
|
+
stylesheets, might not require a full deploy, and especially in \
|
258
|
+
emergency situations it can be handy to just push the updates to \
|
259
|
+
production, quickly.
|
260
|
+
|
261
|
+
To use this task, specify the files and directories you want to copy as \
|
262
|
+
a comma-delimited list in the FILES environment variable. All \
|
263
|
+
directories will be processed recursively, with all files being pushed \
|
264
|
+
to the deployment servers.
|
265
|
+
|
266
|
+
$ cap deploy:upload FILES=templates,controller.rb
|
267
|
+
|
268
|
+
Dir globs are also supported:
|
269
|
+
|
270
|
+
$ cap deploy:upload FILES='config/apache/*.conf'
|
271
|
+
DESC
|
272
|
+
task :upload, :except => { :no_release => true } do
|
273
|
+
files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten
|
274
|
+
abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?
|
275
|
+
|
276
|
+
files.each { |file| top.upload(file, File.join(current_path, file)) }
|
277
|
+
end
|
278
|
+
|
279
|
+
namespace :rollback do
|
280
|
+
desc <<-DESC
|
281
|
+
[internal] Points the current symlink at the previous revision. This \
|
282
|
+
is called by the rollback sequence, and should rarely (if ever) need \
|
283
|
+
to be called directly.
|
284
|
+
DESC
|
285
|
+
task :revision, :except => { :no_release => true } do
|
286
|
+
if previous_release
|
287
|
+
run "#{try_sudo} rm #{current_path}; #{try_sudo} ln -s #{previous_release} #{current_path}"
|
288
|
+
else
|
289
|
+
abort "could not rollback the code because there is no prior release"
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
desc <<-DESC
|
294
|
+
[internal] Removes the most recently deployed release. This is called \
|
295
|
+
by the rollback sequence, and should rarely (if ever) need to be \
|
296
|
+
called directly.
|
297
|
+
DESC
|
298
|
+
task :cleanup, :except => { :no_release => true } do
|
299
|
+
run "if [ `readlink #{current_path}` != #{current_release} ]; then #{try_sudo} rm -rf #{current_release}; fi"
|
300
|
+
end
|
301
|
+
|
302
|
+
desc <<-DESC
|
303
|
+
Rolls back to the previously deployed version. The `current' symlink \
|
304
|
+
will be updated to point at the previously deployed version, and then \
|
305
|
+
the current release will be removed from the servers.
|
306
|
+
DESC
|
307
|
+
task :default, :except => { :no_release => true } do
|
308
|
+
revision
|
309
|
+
cleanup
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
desc <<-DESC
|
314
|
+
Clean up old releases. By default, the last 5 releases are kept on each \
|
315
|
+
server (though you can change this with the keep_releases variable). All \
|
316
|
+
other deployed revisions are removed from the servers. By default, this \
|
317
|
+
will use sudo to clean up the old releases, but if sudo is not available \
|
318
|
+
for your environment, set the :use_sudo variable to false instead.
|
319
|
+
DESC
|
320
|
+
task :cleanup, :except => { :no_release => true } do
|
321
|
+
count = fetch(:keep_releases, 5).to_i
|
322
|
+
if count >= releases.length
|
323
|
+
logger.important 'no old releases to clean up'
|
324
|
+
else
|
325
|
+
logger.info "keeping #{count} of #{releases.length} deployed releases"
|
326
|
+
|
327
|
+
directories = (releases - releases.last(count)).map { |release|
|
328
|
+
File.join(releases_path, release) }.join(' ')
|
329
|
+
|
330
|
+
run "#{try_sudo} rm -rf #{directories}"
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
desc <<-DESC
|
335
|
+
Test deployment dependencies. Checks things like directory permissions, \
|
336
|
+
necessary utilities, and so forth, reporting on the things that appear \
|
337
|
+
to be incorrect or missing. This is good for making sure a deploy has a \
|
338
|
+
chance of working before you actually run `cap deploy'.
|
339
|
+
|
340
|
+
You can define your own dependencies, as well, using the `depend' \
|
341
|
+
method:
|
342
|
+
|
343
|
+
depend :remote, :gem, 'tzinfo', '>=0.3.3'
|
344
|
+
depend :local, :command, 'svn'
|
345
|
+
depend :remote, :directory, '/u/depot/files'
|
346
|
+
DESC
|
347
|
+
task :check, :except => { :no_release => true } do
|
348
|
+
dependencies = strategy.check!
|
349
|
+
|
350
|
+
other = fetch(:dependencies, {})
|
351
|
+
other.each do |location, types|
|
352
|
+
types.each do |type, calls|
|
353
|
+
if type == :gem
|
354
|
+
dependencies.send(location).command(fetch(:gem_command, 'gem')).or("`gem' command could not be found. Try setting :gem_command")
|
355
|
+
end
|
356
|
+
|
357
|
+
calls.each do |args|
|
358
|
+
dependencies.send(location).send(type, *args)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
if dependencies.pass?
|
364
|
+
puts 'You appear to have all necessary dependencies installed'
|
365
|
+
else
|
366
|
+
puts 'The following dependencies failed. Please check them and try again:'
|
367
|
+
dependencies.reject { |d| d.pass? }.each do |d|
|
368
|
+
puts "--> #{d.message}"
|
369
|
+
end
|
370
|
+
abort
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
namespace :pending do
|
375
|
+
desc <<-DESC
|
376
|
+
Displays the `diff' since your last deploy. This is useful if you want \
|
377
|
+
to examine what changes are about to be deployed. Note that this might \
|
378
|
+
not be supported on all SCM's.
|
379
|
+
DESC
|
380
|
+
task :diff, :except => { :no_release => true } do
|
381
|
+
system(source.local.diff(current_revision))
|
382
|
+
end
|
383
|
+
|
384
|
+
desc <<-DESC
|
385
|
+
Displays the commits since your last deploy. This is good for a \
|
386
|
+
summary of the changes that have occurred since the last deploy. Note \
|
387
|
+
that this might not be supported on all SCM's.
|
388
|
+
DESC
|
389
|
+
task :default, :except => { :no_release => true } do
|
390
|
+
from = source.next_revision(current_revision)
|
391
|
+
system(source.local.log(from))
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
data/rupostrano.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rupostrano
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emanuele Vicentini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
|
11
|
+
date: 2009-04-06 00:00:00 +02:00
|
12
|
+
default_executable:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
type: :runtime
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.4.0
|
23
|
+
version:
|
24
|
+
description: Ruport + Capistrano = Rupostrano :-)
|
25
|
+
email: emanuele.vicentini@gmail.com
|
26
|
+
executables:
|
27
|
+
- rupostrano
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- LICENSE.rdoc
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- bin/rupostrano
|
35
|
+
- lib/rupostrano.rb
|
36
|
+
- LICENSE.rdoc
|
37
|
+
- Manifest
|
38
|
+
- Rakefile
|
39
|
+
- README.rdoc
|
40
|
+
- rupostrano.gemspec
|
41
|
+
- templates/Capfile
|
42
|
+
- templates/deploy.rb
|
43
|
+
- templates/environment.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://github.com/baldowl/rupostrano
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --line-numbers
|
49
|
+
- --inline-source
|
50
|
+
- --title
|
51
|
+
- Rupostrano
|
52
|
+
- --main
|
53
|
+
- README.rdoc
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "1.2"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: rupostrano
|
71
|
+
rubygems_version: 1.3.1
|
72
|
+
specification_version: 2
|
73
|
+
summary: Ruport + Capistrano = Rupostrano :-)
|
74
|
+
test_files: []
|
data/templates/Capfile
ADDED
data/templates/deploy.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
set :application, 'wonderful_application'
|
2
|
+
set :repository, 'svn+ssh://me@example.com/path/to/repository/trunk'
|
3
|
+
set :deploy_to, "/home/me/#{application}"
|
4
|
+
|
5
|
+
set :use_sudo, false
|
6
|
+
set :group_writable, false
|
7
|
+
set :change_ownership, false
|
8
|
+
set :shared_children, %w(config)
|
9
|
+
set :shared_resources, %w(config/environment.rb)
|
10
|
+
|
11
|
+
role :app, 'me@production.example.com'
|
12
|
+
|
13
|
+
depend :remote, :gem, 'ruport', '=1.2.3'
|
14
|
+
depend :remote, :gem, 'ruport-util', '=0.10.0'
|
15
|
+
depend :remote, :gem, 'activerecord', '>1.15.0'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "ruport"
|
2
|
+
|
3
|
+
require "active_record"
|
4
|
+
require "ruport/acts_as_reportable"
|
5
|
+
|
6
|
+
# Capistrano adds a REVISION file into the application's root directory, so
|
7
|
+
# we could think about testing its presence to tell the development and test
|
8
|
+
# environments apart.
|
9
|
+
production = File.exist?('REVISION')
|
10
|
+
|
11
|
+
if !production
|
12
|
+
# Just to have a database in development mode.
|
13
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3',
|
14
|
+
:database => 'test.sqlite3', :timeout => 5000)
|
15
|
+
|
16
|
+
# Sender of the email reports.
|
17
|
+
@sender = 'noreply@example.com'
|
18
|
+
|
19
|
+
# Array with the email addresses to which the email reports will be sent.
|
20
|
+
@receivers = %w(me@localhost root@localhost)
|
21
|
+
else
|
22
|
+
socket = ["/tmp/mysql.sock",
|
23
|
+
"/tmp/mysqld.sock",
|
24
|
+
"/var/lib/mysql/mysqld.sock",
|
25
|
+
"/var/run/mysql/mysql.sock",
|
26
|
+
"/var/run/mysqld/mysqld.sock"].detect{|socket|
|
27
|
+
File.exist?(socket)
|
28
|
+
}
|
29
|
+
|
30
|
+
# Same values seen in Rails.
|
31
|
+
ActiveRecord::Base.establish_connection(:adapter => 'mysql',
|
32
|
+
:database => 'wonderful_application_db',
|
33
|
+
:username => 'wonderful_application_user',
|
34
|
+
:password => 'super_secret', :host => 'localhost', :socket => socket)
|
35
|
+
|
36
|
+
# Sender of the email reports.
|
37
|
+
@sender = 'noreply@example.com'
|
38
|
+
|
39
|
+
# Array with the email addresses to which the email reports will be sent.
|
40
|
+
@receivers = %w(someone@example.com someone.else@example.com)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Time format used to display time information to users.
|
44
|
+
Time::DATE_FORMATS[:italian] = '%d/%m/%Y %H:%M:%S'
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: baldowl-rupostrano
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emanuele Vicentini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
date: 2009-04-05 15:00:00 -07:00
|
12
|
+
default_executable:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
type: :runtime
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.4.0
|
23
|
+
version:
|
24
|
+
description: Ruport + Capistrano = Rupostrano :-)
|
25
|
+
email: emanuele.vicentini@gmail.com
|
26
|
+
executables:
|
27
|
+
- rupostrano
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- LICENSE.rdoc
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- bin/rupostrano
|
35
|
+
- lib/rupostrano.rb
|
36
|
+
- LICENSE.rdoc
|
37
|
+
- Manifest
|
38
|
+
- Rakefile
|
39
|
+
- README.rdoc
|
40
|
+
- rupostrano.gemspec
|
41
|
+
- templates/Capfile
|
42
|
+
- templates/deploy.rb
|
43
|
+
- templates/environment.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://github.com/baldowl/rupostrano
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --line-numbers
|
49
|
+
- --inline-source
|
50
|
+
- --title
|
51
|
+
- Rupostrano
|
52
|
+
- --main
|
53
|
+
- README.rdoc
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "1.2"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: rupostrano
|
71
|
+
rubygems_version: 1.2.0
|
72
|
+
signing_key:
|
73
|
+
specification_version: 2
|
74
|
+
summary: Ruport + Capistrano = Rupostrano :-)
|
75
|
+
test_files: []
|
76
|
+
|