rpush 2.1.0-java → 2.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -1
- data/lib/rpush/cli.rb +68 -27
- data/lib/rpush/configuration.rb +2 -0
- data/lib/rpush/push.rb +1 -0
- data/lib/rpush/version.rb +1 -1
- data/lib/tasks/test.rake +53 -37
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 518f5cf260390bc60e3fc71463ec9f1f774ab77e
|
4
|
+
data.tar.gz: de2def70662a539c00b591cd5107da44d35b60fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3105561c117ba12b9c63d9dfd423db9665eac81282b64792d404f5c49d4bf6a033c0b01c29d46a84915a86ca7dedae5219feffaebfc2dd9dc3672d7406ffa6e
|
7
|
+
data.tar.gz: 7a92076300c1eb790365b3c7049e403b0ea02deab720acf70c84b45e586a01582363ce49446c991e223ee3c4839250b66b2ef127a8f795878b3896d1a79aaefb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -167,11 +167,13 @@ See [Configuration](https://github.com/rpush/rpush/wiki/Configuration) for a lis
|
|
167
167
|
|
168
168
|
### Updating Rpush
|
169
169
|
|
170
|
-
You should run `
|
170
|
+
You should run `rpush init` after upgrading Rpush to check for configuration and migration changes.
|
171
171
|
|
172
172
|
### Wiki
|
173
173
|
|
174
174
|
### General
|
175
|
+
* [Using Redis](https://github.com/rpush/rpush/wiki/Using-Redis)
|
176
|
+
* [Using ActiveRecord](https://github.com/rpush/rpush/wiki/Using-ActiveRecord)
|
175
177
|
* [Configuration](https://github.com/rpush/rpush/wiki/Configuration)
|
176
178
|
* [Moving from Rapns](https://github.com/rpush/rpush/wiki/Moving-from-Rapns-to-Rpush)
|
177
179
|
* [Deploying to Heroku](https://github.com/rpush/rpush/wiki/Heroku)
|
data/lib/rpush/cli.rb
CHANGED
@@ -16,23 +16,16 @@ module Rpush
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class_option :config, type: :string, aliases: '-c', default: default_config_path
|
19
|
-
class_option
|
19
|
+
class_option 'rails-env', type: :string, aliases: '-e', default: 'development'
|
20
20
|
|
21
21
|
option :foreground, type: :boolean, aliases: '-f', default: false
|
22
22
|
option 'pid-file', type: :string, aliases: '-p'
|
23
23
|
desc 'start', 'Start Rpush'
|
24
24
|
def start
|
25
|
+
underscore_option_names
|
25
26
|
check_ruby_version
|
27
|
+
configure_rpush
|
26
28
|
|
27
|
-
if detect_rails? && options[:rails_env]
|
28
|
-
STDOUT.write "* Booting Rails '#{options[:rails_env]}' environment... "
|
29
|
-
STDOUT.flush
|
30
|
-
ENV['RAILS_ENV'] = options[:rails_env]
|
31
|
-
load 'config/environment.rb'
|
32
|
-
puts green('✔')
|
33
|
-
end
|
34
|
-
|
35
|
-
load_config
|
36
29
|
require 'rpush/daemon'
|
37
30
|
Rpush::Daemon.start
|
38
31
|
end
|
@@ -40,9 +33,10 @@ module Rpush
|
|
40
33
|
desc 'stop', 'Stop Rpush'
|
41
34
|
option 'pid-file', type: :string, aliases: '-p'
|
42
35
|
def stop
|
36
|
+
underscore_option_names
|
43
37
|
check_ruby_version
|
44
|
-
|
45
|
-
|
38
|
+
configure_rpush
|
39
|
+
ensure_pid_file_set
|
46
40
|
|
47
41
|
if File.exist?(Rpush.config.pid_file)
|
48
42
|
pid = File.read(Rpush.config.pid_file).strip.to_i
|
@@ -67,8 +61,9 @@ module Rpush
|
|
67
61
|
end
|
68
62
|
|
69
63
|
desc 'init', 'Initialize Rpush into the current directory.'
|
70
|
-
option 'active-record', type: :boolean, desc: 'Install ActiveRecord migrations
|
64
|
+
option 'active-record', type: :boolean, desc: 'Install ActiveRecord migrations'
|
71
65
|
def init
|
66
|
+
underscore_option_names
|
72
67
|
check_ruby_version
|
73
68
|
require 'rails/generators'
|
74
69
|
|
@@ -76,9 +71,9 @@ module Rpush
|
|
76
71
|
$RPUSH_CONFIG_PATH = default_config_path # rubocop:disable Style/GlobalVars
|
77
72
|
Rails::Generators.invoke('rpush_config')
|
78
73
|
|
79
|
-
install_migrations = options['
|
74
|
+
install_migrations = options['active_record']
|
80
75
|
|
81
|
-
unless options.key?('
|
76
|
+
unless options.key?('active_record')
|
82
77
|
has_answer = false
|
83
78
|
until has_answer
|
84
79
|
STDOUT.write "\n* #{green('Install ActiveRecord migrations?')} [y/n]: "
|
@@ -90,7 +85,7 @@ module Rpush
|
|
90
85
|
install_migrations = answer == 'y'
|
91
86
|
end
|
92
87
|
|
93
|
-
Rails::Generators.invoke('rpush_migration') if install_migrations
|
88
|
+
Rails::Generators.invoke('rpush_migration', ['--force']) if install_migrations
|
94
89
|
|
95
90
|
puts "\n* #{green('Next steps:')}"
|
96
91
|
puts " - Run 'db:migrate'." if install_migrations
|
@@ -99,24 +94,38 @@ module Rpush
|
|
99
94
|
puts " - Run 'rpush help' for commands and options."
|
100
95
|
end
|
101
96
|
|
102
|
-
|
97
|
+
desc 'push', 'Deliver all pending notifications and then exit'
|
98
|
+
def push
|
99
|
+
underscore_option_names
|
100
|
+
check_ruby_version
|
101
|
+
configure_rpush
|
102
|
+
Rpush.config.foreground = true
|
103
103
|
|
104
|
-
|
105
|
-
self.class.detect_rails?
|
104
|
+
Rpush.push
|
106
105
|
end
|
107
106
|
|
108
|
-
|
109
|
-
|
107
|
+
private
|
108
|
+
|
109
|
+
def configure_rpush
|
110
|
+
load_rails_environment || load_standalone
|
110
111
|
end
|
111
112
|
|
112
|
-
def
|
113
|
-
|
113
|
+
def load_rails_environment
|
114
|
+
if detect_rails? && options['rails_env']
|
115
|
+
STDOUT.write "* Booting Rails '#{options[:rails_env]}' environment... "
|
116
|
+
STDOUT.flush
|
117
|
+
ENV['RAILS_ENV'] = options['rails_env']
|
118
|
+
load 'config/environment.rb'
|
119
|
+
Rpush.config.update(options)
|
120
|
+
puts green('✔')
|
114
121
|
|
115
|
-
|
116
|
-
|
122
|
+
return true
|
123
|
+
end
|
124
|
+
|
125
|
+
false
|
117
126
|
end
|
118
127
|
|
119
|
-
def
|
128
|
+
def load_standalone
|
120
129
|
if !File.exist?(options[:config])
|
121
130
|
STDERR.puts(red('ERROR: ') + "#{options[:config]} does not exist. Please run 'rpush init' to generate it or specify the --config option.")
|
122
131
|
exit 1
|
@@ -126,8 +135,40 @@ module Rpush
|
|
126
135
|
end
|
127
136
|
end
|
128
137
|
|
138
|
+
def detect_rails?
|
139
|
+
self.class.detect_rails?
|
140
|
+
end
|
141
|
+
|
142
|
+
def default_config_path
|
143
|
+
self.class.default_config_path
|
144
|
+
end
|
145
|
+
|
146
|
+
def ensure_pid_file_set
|
147
|
+
return unless Rpush.config.pid_file.blank?
|
148
|
+
|
149
|
+
STDERR.puts(red('ERROR: ') + 'config.pid_file is not set.')
|
150
|
+
exit 1
|
151
|
+
end
|
152
|
+
|
129
153
|
def check_ruby_version
|
130
|
-
STDERR.puts(yellow('WARNING: ') + "You are using an old and unsupported version of Ruby.") if RUBY_VERSION <= '1.9.3'
|
154
|
+
STDERR.puts(yellow('WARNING: ') + "You are using an old and unsupported version of Ruby.") if RUBY_VERSION <= '1.9.3' && RUBY_ENGINE == 'ruby'
|
155
|
+
end
|
156
|
+
|
157
|
+
def underscore_option_names
|
158
|
+
# Underscore option names so that they map directly to Configuration options.
|
159
|
+
new_options = options.dup
|
160
|
+
|
161
|
+
options.each do |k, v|
|
162
|
+
new_k = k.to_s.tr('-', '_')
|
163
|
+
|
164
|
+
if k != new_k
|
165
|
+
new_options.delete(k)
|
166
|
+
new_options[new_k] = v
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
new_options.freeze
|
171
|
+
self.options = new_options
|
131
172
|
end
|
132
173
|
end
|
133
174
|
end
|
data/lib/rpush/configuration.rb
CHANGED
data/lib/rpush/push.rb
CHANGED
data/lib/rpush/version.rb
CHANGED
data/lib/tasks/test.rake
CHANGED
@@ -1,46 +1,62 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
retval
|
10
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
def cmd(str, clean_env = true)
|
4
|
+
puts "* #{str}"
|
5
|
+
retval = clean_env ? Bundler.with_clean_env { `#{str}` } : `#{str}`
|
6
|
+
puts retval.strip
|
7
|
+
retval
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
task :build_rails do
|
11
|
+
rpush_root = Dir.pwd
|
12
|
+
path = '/tmp/rpush/rails_test'
|
13
|
+
cmd("rm -rf #{path}")
|
14
|
+
FileUtils.mkdir_p(path)
|
15
|
+
pwd = Dir.pwd
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
cmd("bundle exec rails --version", false)
|
18
|
+
cmd("bundle exec rails new #{path} --skip-bundle", false)
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
begin
|
21
|
+
Dir.chdir(path)
|
22
|
+
cmd('echo "gem \'rake\'" >> Gemfile')
|
23
|
+
cmd('echo "gem \'pg\'" >> Gemfile')
|
24
|
+
cmd("echo \"gem 'rpush', :path => '#{rpush_root}'\" >> Gemfile")
|
25
|
+
cmd('bundle install')
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
File.open('config/database.yml', 'w') do |fd|
|
28
|
+
fd.write(<<-YML)
|
30
29
|
development:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
cmd('bundle exec rails g rpush')
|
39
|
-
cmd('bundle exec rake db:migrate')
|
40
|
-
ensure
|
41
|
-
Dir.chdir(pwd)
|
30
|
+
adapter: postgresql
|
31
|
+
database: rpush_rails_test
|
32
|
+
pool: 5
|
33
|
+
timeout: 5000
|
34
|
+
YML
|
42
35
|
end
|
36
|
+
ensure
|
37
|
+
Dir.chdir(pwd)
|
38
|
+
end
|
43
39
|
|
44
|
-
|
40
|
+
puts "Built into #{path}"
|
41
|
+
end
|
42
|
+
|
43
|
+
task :build_standalone do
|
44
|
+
rpush_root = Dir.pwd
|
45
|
+
path = '/tmp/rpush/standalone_test'
|
46
|
+
cmd("rm -rf #{path}")
|
47
|
+
FileUtils.mkdir_p(path)
|
48
|
+
pwd = Dir.pwd
|
49
|
+
|
50
|
+
begin
|
51
|
+
Dir.chdir(path)
|
52
|
+
cmd('echo "source \'https://rubygems.org\'" >> Gemfile')
|
53
|
+
cmd('echo "gem \'rake\'" >> Gemfile')
|
54
|
+
cmd('echo "gem \'rpush-redis\'" >> Gemfile')
|
55
|
+
cmd("echo \"gem 'rpush', :path => '#{rpush_root}'\" >> Gemfile")
|
56
|
+
cmd('bundle install')
|
57
|
+
ensure
|
58
|
+
Dir.chdir(pwd)
|
45
59
|
end
|
60
|
+
|
61
|
+
puts "Built into #{path}"
|
46
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Ian Leitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|