capistrano-rpush 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2512698119bd62e82bba9b27cb145550fd488b5
4
- data.tar.gz: 8c57ad338e07c4cbb42dcd84aacab8ac38161d9c
3
+ metadata.gz: d04fd1717ead14deadc0785a44c576e7dd7ad1eb
4
+ data.tar.gz: 9d842e6e773a94c1b9930377bdd86fa6798cd5b8
5
5
  SHA512:
6
- metadata.gz: 44d4f31f00454cf44b2388cd65ae54e263fad600830fec69183961ce09c9e7b954fbd15296ee3f4a225a1310ba0dcab0117acf69b4993c0fa1873881072e7c9e
7
- data.tar.gz: 6b331ba06d76f38daceb265cc47f6750479679a3c8dac76b8695d56e39c510aff75452d6f08c63ccc7e9b45ad6ccad671dba63f0182f75fa0311794c1b52b09c
6
+ metadata.gz: 48a73bfbc2ea5edaa8a26fdba3b3c04831c4a59a572cf30cd131edf4b0ff3ee6ec499ab3ee652a66538696e5a3a7ec2c5568187adb6b1fa3dc45ed59500f271a
7
+ data.tar.gz: 6346b5858b88508adcc93b653016f7d7b537f2723e82c124cf1d4cd281e22d2cb31090c91c3adb465ce39769bf0c95dd6f5e59e3da85be9db8f4d8a556da9837
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ capistrano-rpush
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.2
data/README.md CHANGED
@@ -2,13 +2,18 @@
2
2
 
3
3
  # Capistrano::Rpush
4
4
 
5
- [Capistrano::Rpush](https://github.com/juicyparts/capistrano-rpush) adds [Rpush](https://rubygems.org/gems/rpush) tasks to your Capistrano deployment.
5
+ [Capistrano::Rpush](https://github.com/juicyparts/capistrano-rpush) adds [Rpush](https://rubygems.org/gems/rpush) tasks to your [Capistrano](https://rubygems.org/gems/capistrano) deployment.
6
+
7
+ ## Capistrano 3
8
+
9
+ This gem was developed against version 3.9.1. It uses the experimental ```Capistrano::Plugin```.
6
10
 
7
11
  ## Rpush
8
12
 
9
- This gem was developed against version 2.7.0. Additionally it only provides tasks over a subset of available commands:
13
+ This gem was developed against version 3.0.0. Additionally it only provides tasks over a subset of available commands:
10
14
 
11
15
  $ rpush --help
16
+
12
17
  ```
13
18
  Commands:
14
19
  rpush help [COMMAND] # Describe available commands or one specific command
@@ -47,8 +52,15 @@ Or install it yourself as:
47
52
  ```ruby
48
53
  # In Rails.root/Capfile
49
54
 
55
+ require 'capistrano/rpush'
56
+ install_plugin Capistrano::Rpush
57
+ ```
58
+ Or, to install the plugin without its hooks:
59
+ ```ruby
60
+ # In Rails.root/Capfile
50
61
 
51
62
  require 'capistrano/rpush'
63
+ install_plugin Capistrano::RPush, load_hooks: false
52
64
  ```
53
65
 
54
66
  Now you can use cap -T to list tasks:
@@ -4,30 +4,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'capistrano/rpush/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "capistrano-rpush"
8
- spec.version = Capistrano::Rpush::VERSION
9
- spec.authors = ["Mel Riffe"]
10
- spec.email = ["mel@juicyparts.com"]
7
+ spec.name = 'capistrano-rpush'
8
+ spec.version = Capistrano::RpushPlugin::VERSION
9
+ spec.authors = ['Mel Riffe']
10
+ spec.email = ['mel@juicyparts.com']
11
11
  spec.summary = %q{Capistrano3 plugin with basic 'start', 'stop' commands for rpush.}
12
12
  spec.description = %q{A set of Capistrano3 tasks to controll a deployed Rpush installation. The tasks include: restart, start, status, and stop.}
13
- spec.homepage = "http://juicyparts.com/capistrano-rpush"
14
- spec.license = "MIT"
13
+ spec.homepage = 'http://juicyparts.com/capistrano-rpush'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
17
+ spec.bindir = 'exe'
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.post_install_message = "Thanks for installing!"
21
+ spec.post_install_message = 'Thanks for installing the Capistrano::Rpush plugin!'
22
22
  spec.metadata = {
23
- "source_code" => 'https://github.com/juicyparts/capistrano-rpush',
24
- "issue_tracker" => "https://github.com/juicyparts/capistrano-rpush/issues",
23
+ 'source_code' => 'https://github.com/juicyparts/capistrano-rpush',
24
+ 'issue_tracker' => 'https://github.com/juicyparts/capistrano-rpush/issues',
25
25
  }
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.11"
28
- spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_dependency 'capistrano', '~> 3.9', '>= 3.9.1'
28
+ spec.add_dependency 'rpush', '>= 2.7'
30
29
 
31
- spec.add_dependency 'capistrano', '~> 3.0', '< 4.0'
32
- spec.add_dependency 'rpush', '~> 2.7', '< 3.0'
30
+ spec.add_development_dependency 'bundler', '~> 1.15'
31
+ spec.add_development_dependency 'rake', '~> 12.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.6'
33
33
  end
@@ -1 +1,28 @@
1
- load File.expand_path('../tasks/rpush.cap', __FILE__)
1
+ require 'capistrano/plugin'
2
+ require 'capistrano/rpush/common'
3
+
4
+ class Capistrano::Rpush < Capistrano::Plugin
5
+ include Capistrano::RpushPlugin::Common
6
+
7
+ def define_tasks
8
+ eval_rakefile File.expand_path('../tasks/rpush.rake', __FILE__)
9
+ end
10
+
11
+ def set_defaults
12
+ set_if_empty :rpush_default_hooks, true
13
+ set_if_empty :rpush_role, :app
14
+ set_if_empty :rpush_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
15
+ set_if_empty :rpush_conf, -> { File.join(current_path, 'config', 'initializers', 'rpush.rb') }
16
+ set_if_empty :rpush_log, -> { File.join(shared_path, 'log', 'rpush.log') }
17
+ set_if_empty :rpush_pid, -> { File.join(shared_path, 'tmp', 'pids', 'rpush.pid') }
18
+
19
+ append :rbenv_map_bins, 'rpush'
20
+ append :bundle_bins, 'rpush'
21
+ end
22
+
23
+ def register_hooks
24
+ after 'deploy:check', 'rpush:check'
25
+ after 'deploy:finished', 'rpush:restart'
26
+ end
27
+
28
+ end
@@ -0,0 +1,25 @@
1
+ module Capistrano
2
+ module RpushPlugin
3
+ module Common
4
+
5
+ def rpush_switch_user role, &block
6
+ user = rpush_user role
7
+ if user == role.user
8
+ block.call
9
+ else
10
+ as user do
11
+ block.call
12
+ end
13
+ end
14
+ end
15
+
16
+ def rpush_user role
17
+ properties = role.properties
18
+ properties.fetch(:rpush_user) || # local property for rpush only
19
+ fetch(:rpush_user) ||
20
+ properties.fetch(:run_as) || # global property across multiple capistrano gems
21
+ role.user
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
- module Rpush
3
- VERSION = "0.1.7"
2
+ module RpushPlugin
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,73 @@
1
+ git_plugin = self
2
+
3
+ namespace :rpush do
4
+ desc 'Check if config file exists'
5
+ task :check do
6
+ on roles (fetch(:rpush_role)) do |role|
7
+ unless test "[ -f #{fetch(:rpush_conf)} ]"
8
+ warn 'rpush.rb NOT FOUND!'
9
+ info 'Configure rpush for your project before attempting a deployment.'
10
+ end
11
+ end
12
+ end
13
+
14
+ desc 'Restart rpush'
15
+ task :restart do
16
+ on roles (fetch(:rpush_role)) do |role|
17
+ git_plugin.rpush_switch_user(role) do
18
+ if test "[ -f #{fetch(:rpush_pid)} ]"
19
+ invoke 'rpush:stop'
20
+ end
21
+ invoke 'rpush:start'
22
+ end
23
+ end
24
+ end
25
+
26
+ desc 'Start rpush'
27
+ task :start do
28
+ on roles (fetch(:rpush_role)) do |role|
29
+ git_plugin.rpush_switch_user(role) do
30
+ if test "[ -f #{fetch(:rpush_conf)} ]"
31
+ info "using conf file #{fetch(:rpush_conf)}"
32
+ else
33
+ invoke 'rpush:check'
34
+ end
35
+ within current_path do
36
+ with rack_env: fetch(:rpush_env) do
37
+ execute :rpush, "start -p #{fetch(:rpush_pid)} -c #{fetch(:rpush_conf)} -e #{fetch(:rpush_env)}"
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ desc 'Status rpush'
45
+ task :status do
46
+ on roles (fetch(:rpush_role)) do |role|
47
+ git_plugin.rpush_switch_user(role) do
48
+ if test "[ -f #{fetch(:rpush_conf)} ]"
49
+ within current_path do
50
+ with rack_env: fetch(:rpush_env) do
51
+ execute :rpush, "status -c #{fetch(:rpush_conf)} -e #{fetch(:rpush_env)}"
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ desc 'Stop rpush'
60
+ task :stop do
61
+ on roles (fetch(:rpush_role)) do |role|
62
+ git_plugin.rpush_switch_user(role) do
63
+ if test "[ -f #{fetch(:rpush_pid)} ]"
64
+ within current_path do
65
+ with rack_env: fetch(:rpush_env) do
66
+ execute :rpush, "stop -p #{fetch(:rpush_pid)} -c #{fetch(:rpush_conf)} -e #{fetch(:rpush_env)}"
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,97 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-rpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mel Riffe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-25 00:00:00.000000000 Z
11
+ date: 2017-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: capistrano
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
20
- type: :development
19
+ version: '3.9'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.9.1
23
+ type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '1.11'
29
+ version: '3.9'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.9.1
27
33
  - !ruby/object:Gem::Dependency
28
- name: rake
34
+ name: rpush
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
39
+ version: '2.7'
40
+ type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - "~>"
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '10.0'
46
+ version: '2.7'
41
47
  - !ruby/object:Gem::Dependency
42
- name: rspec
48
+ name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '3.0'
53
+ version: '1.15'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '3.0'
60
+ version: '1.15'
55
61
  - !ruby/object:Gem::Dependency
56
- name: capistrano
62
+ name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '3.0'
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: '4.0'
65
- type: :runtime
67
+ version: '12.0'
68
+ type: :development
66
69
  prerelease: false
67
70
  version_requirements: !ruby/object:Gem::Requirement
68
71
  requirements:
69
72
  - - "~>"
70
73
  - !ruby/object:Gem::Version
71
- version: '3.0'
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: '4.0'
74
+ version: '12.0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: rpush
76
+ name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '2.7'
82
- - - "<"
83
- - !ruby/object:Gem::Version
84
- version: '3.0'
85
- type: :runtime
81
+ version: '3.6'
82
+ type: :development
86
83
  prerelease: false
87
84
  version_requirements: !ruby/object:Gem::Requirement
88
85
  requirements:
89
86
  - - "~>"
90
87
  - !ruby/object:Gem::Version
91
- version: '2.7'
92
- - - "<"
93
- - !ruby/object:Gem::Version
94
- version: '3.0'
88
+ version: '3.6'
95
89
  description: 'A set of Capistrano3 tasks to controll a deployed Rpush installation.
96
90
  The tasks include: restart, start, status, and stop.'
97
91
  email:
@@ -101,7 +95,9 @@ extensions: []
101
95
  extra_rdoc_files: []
102
96
  files:
103
97
  - ".gitignore"
98
+ - ".rbenv-gemsets"
104
99
  - ".rspec"
100
+ - ".ruby-version"
105
101
  - ".travis.yml"
106
102
  - CODE_OF_CONDUCT.md
107
103
  - Gemfile
@@ -111,15 +107,16 @@ files:
111
107
  - capistrano-rpush.gemspec
112
108
  - lib/capistrano-rpush.rb
113
109
  - lib/capistrano/rpush.rb
110
+ - lib/capistrano/rpush/common.rb
114
111
  - lib/capistrano/rpush/version.rb
115
- - lib/capistrano/tasks/rpush.cap
112
+ - lib/capistrano/tasks/rpush.rake
116
113
  homepage: http://juicyparts.com/capistrano-rpush
117
114
  licenses:
118
115
  - MIT
119
116
  metadata:
120
117
  source_code: https://github.com/juicyparts/capistrano-rpush
121
118
  issue_tracker: https://github.com/juicyparts/capistrano-rpush/issues
122
- post_install_message: Thanks for installing!
119
+ post_install_message: Thanks for installing the Capistrano::Rpush plugin!
123
120
  rdoc_options: []
124
121
  require_paths:
125
122
  - lib
@@ -135,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
132
  version: '0'
136
133
  requirements: []
137
134
  rubyforge_project:
138
- rubygems_version: 2.5.1
135
+ rubygems_version: 2.6.13
139
136
  signing_key:
140
137
  specification_version: 4
141
138
  summary: Capistrano3 plugin with basic 'start', 'stop' commands for rpush.
@@ -1,111 +0,0 @@
1
- namespace :load do
2
- set :rpush_default_hooks, -> { true }
3
- set :rpush_role, :app
4
- set :rpush_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
5
- set :rpush_conf, -> { File.join(shared_path, 'config', 'rpush.rb') }
6
- set :rpush_log, -> { File.join(shared_path, 'log', 'rpush.log') }
7
- set :rpush_pid, -> { File.join(shared_path, 'tmp', 'pids', 'rpush.pid') }
8
- end
9
-
10
- namespace :deploy do
11
- before :starting, :check_rpush_hooks do
12
- invoke 'rpush:add_default_hooks' if fetch(:rpush_default_hooks)
13
- end
14
- end
15
-
16
- namespace :rpush do
17
-
18
- task :add_default_hooks do
19
- after 'deploy:check', 'rpush:check'
20
- after 'deploy:finished', 'rpush:restart'
21
- end
22
-
23
- task :check do
24
- on roles (fetch(:rpush_role)) do |role|
25
- unless test "[ -f #{fetch(:rpush_conf)} ]"
26
- warn 'rpush.rb NOT FOUND!'
27
- info 'Configure rpush for your project before attempting a deployment.'
28
- end
29
- end
30
- end
31
-
32
- desc 'Restart rpush'
33
- task :restart do
34
- on roles (fetch(:rpush_role)) do |role|
35
- rpush_switch_user(role) do
36
- if test "[ -f #{fetch(:rpush_pid)} ]"
37
- invoke 'rpush:stop'
38
- end
39
- invoke 'rpush:start'
40
- end
41
- end
42
- end
43
-
44
- desc 'Start rpush'
45
- task :start do
46
- on roles (fetch(:rpush_role)) do |role|
47
- rpush_switch_user(role) do
48
- if test "[ -f #{fetch(:rpush_conf)} ]"
49
- info "using conf file #{fetch(:rpush_conf)}"
50
- else
51
- invoke 'rpush:check'
52
- end
53
- within current_path do
54
- with rack_env: fetch(:rpush_env) do
55
- execute :bundle, :exec, "rpush start -p #{fetch(:rpush_pid)} -c #{fetch(:rpush_conf)} -e #{fetch(:rpush_env)}"
56
- end
57
- end
58
- end
59
- end
60
- end
61
-
62
- desc 'Status rpush'
63
- task :status do
64
- on roles (fetch(:rpush_role)) do |role|
65
- rpush_switch_user(role) do
66
- if test "[ -f #{fetch(:rpush_conf)} ]"
67
- within current_path do
68
- with rack_env: fetch(:rpush_env) do
69
- execute :bundle, :exec, "rpush status -c #{fetch(:rpush_conf)} -e #{fetch(:rpush_env)}"
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
76
-
77
- desc 'Stop rpush'
78
- task :stop do
79
- on roles (fetch(:rpush_role)) do |role|
80
- rpush_switch_user(role) do
81
- if test "[ -f #{fetch(:rpush_pid)} ]"
82
- within current_path do
83
- with rack_env: fetch(:rpush_env) do
84
- execute :bundle, :exec, "rpush stop -p #{fetch(:rpush_pid)} -c #{fetch(:rpush_conf)} -e #{fetch(:rpush_env)}"
85
- end
86
- end
87
- end
88
- end
89
- end
90
- end
91
-
92
- def rpush_switch_user(role, &block)
93
- user = rpush_user(role)
94
- if user == role.user
95
- block.call
96
- else
97
- as user do
98
- block.call
99
- end
100
- end
101
- end
102
-
103
- def rpush_user(role)
104
- properties = role.properties
105
- properties.fetch(:rpush_user) || # local property for rpush only
106
- fetch(:rpush_user) ||
107
- properties.fetch(:run_as) || # global property across multiple capistrano gems
108
- role.user
109
- end
110
-
111
- end