kapify 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -41,6 +41,17 @@ All recipes could be customized using variables.
41
41
  Also there are template generators for deep customization.
42
42
  See README for recipes for details.
43
43
 
44
+ Also contains several helpers (some of them are based on Ryan Bate's screencast):
45
+
46
+ ```ruby
47
+ as_user
48
+ close_session
49
+ set_default
50
+ template
51
+
52
+ ```
53
+
54
+ If you want to use these helpers, require `kapify/base` in your `Capfile` or `deploy.rb`
44
55
 
45
56
  ## Contributing
46
57
 
@@ -11,6 +11,7 @@
11
11
  # Description: resque - a Redis-backed Ruby library for creating background jobs, placing those jobs on multiple queues, and processing them later.
12
12
  ### END INIT INFO
13
13
 
14
+ set -u
14
15
  set -e
15
16
 
16
17
  . /lib/lsb/init-functions
@@ -24,8 +25,11 @@ QUEUES="<%= resque_queue %>"
24
25
  COUNT=<%= resque_workers %>
25
26
  TASK="<%= resque_task %>"
26
27
  PIDFILE="$ROOT/tmp/pids/resque_worker.%d.pid"
28
+ RBENV="<%= rbenv_install_path %>"
29
+ PATH="$RBENV/shims:$RBENV/bin:$PATH"
30
+ BUNDLE="$RBENV/shims/bundle"
27
31
 
28
- BUNDLE="<%= resque_bundle %>"
32
+ chdir $ROOT
29
33
 
30
34
  start() {
31
35
  local program
data/lib/kapify/base.rb CHANGED
@@ -3,7 +3,29 @@ Capistrano::Configuration.instance.load do
3
3
  set(name, *args, &block) unless exists?(name)
4
4
  end
5
5
 
6
- set_default(:templates_path, "config/deploy/templates")
6
+ def close_sessions
7
+ sessions.values.each { |session| session.close }
8
+ sessions.clear
9
+ end
10
+
11
+ def as_user(user_name)
12
+ old_user = user
13
+ set :user, user_name
14
+ close_sessions
15
+ begin
16
+ yield
17
+ ensure
18
+ set :user, old_user
19
+ close_sessions
20
+ end
21
+ end
22
+
23
+ set_default(:templates_path, "#{Dir.pwd}/config/deploy/templates")
24
+
25
+ def template(from, to)
26
+ erb = File.read(File.expand_path("#{templates_path}/#{from}", __FILE__))
27
+ put ERB.new(erb).result(binding), to
28
+ end
7
29
 
8
30
  def kapify_template(generator, template_name, target)
9
31
  config_file = "#{templates_path}/#{template_name}"
@@ -60,6 +60,10 @@ you can run any of these tasks to update configuration.
60
60
  You can customize resque configs using capistrano variables:
61
61
 
62
62
  ```ruby
63
+ # path to the bundle command
64
+ # default value: /usr/local/rbenv (for globally installed rbenv)
65
+ set :rbenv_install_path, "~/.rbenv"
66
+
63
67
  # user name to run resque
64
68
  # default value: `user` (user varibale defined in your `deploy.rb`)
65
69
  set :resque_user, "user"
@@ -72,10 +76,6 @@ set :resque_workers, 4
72
76
  # default value: *
73
77
  set :resque_queue, "*"
74
78
 
75
- # path to the bundle command
76
- # default value: /usr/local/rbenv/shims/bundle (for globally installed rbenv)
77
- set :resque_bundle, "/usr/bin/bundle"
78
-
79
79
  # name of rake task to run resque worker
80
80
  # default value: "environment resque:work"
81
81
  set :resque_task, "resque:work"
@@ -5,8 +5,8 @@ Capistrano::Configuration.instance.load do
5
5
  set_default(:resque_user, user)
6
6
  set_default(:resque_workers, 2)
7
7
  set_default(:resque_queue, "*")
8
- set_default(:resque_bundle, "/usr/local/rbenv/shims/bundle")
9
8
  set_default(:resque_task, "environment resque:work")
9
+ set_default(:rbenv_install_path, "/usr/local/rbenv")
10
10
 
11
11
  namespace :kapify do
12
12
  namespace :resque do
@@ -1,3 +1,3 @@
1
1
  module Kapify
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-13 00:00:00.000000000 Z
12
+ date: 2012-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: 2069292793182208774
108
+ hash: 1911853121235537074
109
109
  none: false
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements:
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: 2069292793182208774
117
+ hash: 1911853121235537074
118
118
  none: false
119
119
  requirements: []
120
120
  rubyforge_project: