underglow 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -2
- data/lib/underglow/capistrano/deploy.rb +33 -0
- data/lib/underglow/capistrano/helpers.rb +25 -0
- data/lib/underglow/capistrano/rake.rb +20 -0
- data/lib/underglow/capistrano.rb +3 -0
- data/lib/underglow/version.rb +1 -1
- data/lib/underglow.rb +1 -1
- metadata +9 -5
- /data/lib/{tasks → underglow/tasks}/db.rake +0 -0
- /data/lib/{tasks → underglow/tasks}/system.rake +0 -0
- /data/lib/{tasks → underglow/tasks}/thin.rake +0 -0
data/README.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
Underglow
|
2
2
|
=========
|
3
|
-
Provides some luxury methods and extensions. I personally use this on all my projects to make my life easier.
|
3
|
+
Provides some luxury methods and extensions. I personally use this on all my projects to make my life easier. This isn't my car, but it's what I'm hoping to achieve with this gem.
|
4
|
+
|
5
|
+
![Sicc](http://i.imgur.com/RwBtG.jpg)
|
4
6
|
|
5
7
|
Installation
|
6
8
|
============
|
7
|
-
|
9
|
+
|
8
10
|
gem install underglow
|
9
11
|
|
12
|
+
Usage
|
13
|
+
=====
|
14
|
+
Some capistrano tasks are provided. To use them, require them within your `deploy.rb` file.
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'underglow/capistrano'
|
18
|
+
```
|
19
|
+
|
10
20
|
Testing
|
11
21
|
=======
|
12
22
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
# this task gets called last by capistrano when required to restart stuff
|
3
|
+
namespace :deploy do
|
4
|
+
# Custom web enable/disable tasks by simply added active suffix to maintenance page
|
5
|
+
namespace :web do
|
6
|
+
desc "Present a maintenance page to visitors."
|
7
|
+
task :disable do
|
8
|
+
require 'haml'
|
9
|
+
on_rollback { run "rm #{shared_path}/system/maintenance.html" }
|
10
|
+
|
11
|
+
reason = ENV['REASON']
|
12
|
+
deadline = ENV['UNTIL']
|
13
|
+
template = File.read('app/views/layouts/maintenance.html.haml')
|
14
|
+
html = Haml::Engine.new(template).render(binding)
|
15
|
+
|
16
|
+
put html, "#{shared_path}/system/maintenance.html", mode: 0644
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :assets do
|
21
|
+
desc "Precompile assets only if they haven't changed"
|
22
|
+
task :precompile, roles: :web, except: { no_release: true } do
|
23
|
+
# if there's no current revision, then this is the first deploy, then we must precompile regardless
|
24
|
+
# otherwise, only precompile if assets have changed
|
25
|
+
if !remote_file_exists?("#{current_path}/REVISION") or capture("cd #{release_path} && #{source.local.log(source.next_revision(current_revision))} vendor/assets/ app/assets/ | wc -l").to_i > 0
|
26
|
+
run %Q{cd #{release_path} && #{rake_command} RAILS_ENV=#{stage} #{asset_env} assets:precompile}
|
27
|
+
else
|
28
|
+
logger.info "Skipping asset pre-compilation because there were no asset changes"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
# Make sure gem 'capistrano-ext' is installed for this
|
3
|
+
after "multistage:ensure" do
|
4
|
+
set :rails_env, stage
|
5
|
+
end
|
6
|
+
|
7
|
+
# Can't use File.exists? because it'll check the local filesystem, not remote
|
8
|
+
def remote_file_exists?(path)
|
9
|
+
'true' == capture("if [ -e #{path} ]; then echo 'true'; fi").strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def read_remote_file(path)
|
13
|
+
capture("cat #{path}").strip
|
14
|
+
end
|
15
|
+
|
16
|
+
# Sends kill signal if process is running
|
17
|
+
def kill(process, signal)
|
18
|
+
pidfile_path = "#{shared_path}/pids/#{process}.pid"
|
19
|
+
|
20
|
+
if remote_file_exists?(pidfile_path)
|
21
|
+
pid = read_remote_file(pidfile_path).to_i
|
22
|
+
run "kill -#{signal} #{pid} > /dev/null 2>&1" # suppress errors
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
# So we can use rake within commands
|
3
|
+
after "multistage:ensure" do
|
4
|
+
set :rake_command, "RAILS_ENV=#{stage} #{current_path}/bin/rake -f #{current_path}/Rakefile"
|
5
|
+
end
|
6
|
+
|
7
|
+
before "deploy:update_code" do
|
8
|
+
# We are about to update code, so we need to use release path because the current path will be the old code
|
9
|
+
set :rake_command, "RAILS_ENV=#{stage} #{release_path}/bin/rake -f #{release_path}/Rakefile"
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :rake do
|
13
|
+
# Note: do not name this task to "run"
|
14
|
+
desc "Invoke a rake task, ex: cap production rake:invoke TASK=db:migrate TRACE=true"
|
15
|
+
task :invoke do
|
16
|
+
trace = ENV['TRACE'] ? "--trace" : ""
|
17
|
+
run "#{rake_command} #{ENV['TASK']} #{trace}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/underglow/version.rb
CHANGED
data/lib/underglow.rb
CHANGED
@@ -9,7 +9,7 @@ module Underglow
|
|
9
9
|
class Railtie < ::Rails::Railtie
|
10
10
|
rake_tasks do
|
11
11
|
# load all rake tasks, need to load them by full path so they don't get confused with any tasks of the same name in Rails app
|
12
|
-
Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |f| load f }
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'underglow/tasks/*.rake')].each { |f| load f }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: underglow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -55,13 +55,17 @@ files:
|
|
55
55
|
- Gemfile
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
|
-
- lib/tasks/db.rake
|
59
|
-
- lib/tasks/system.rake
|
60
|
-
- lib/tasks/thin.rake
|
61
58
|
- lib/underglow.rb
|
59
|
+
- lib/underglow/capistrano.rb
|
60
|
+
- lib/underglow/capistrano/deploy.rb
|
61
|
+
- lib/underglow/capistrano/helpers.rb
|
62
|
+
- lib/underglow/capistrano/rake.rb
|
62
63
|
- lib/underglow/config.rb
|
63
64
|
- lib/underglow/extensions/string.rb
|
64
65
|
- lib/underglow/extensions/symbol.rb
|
66
|
+
- lib/underglow/tasks/db.rake
|
67
|
+
- lib/underglow/tasks/system.rake
|
68
|
+
- lib/underglow/tasks/thin.rake
|
65
69
|
- lib/underglow/version.rb
|
66
70
|
- spec/extensions/string_spec.rb
|
67
71
|
- spec/extensions/symbol_spec.rb
|
File without changes
|
File without changes
|
File without changes
|