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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39bdc7bf081a339dd09353c0690a9e0cff7b67ac
4
- data.tar.gz: 3dbee5a4f472b95d4ef419f21340a21b30d4a2f0
3
+ metadata.gz: 518f5cf260390bc60e3fc71463ec9f1f774ab77e
4
+ data.tar.gz: de2def70662a539c00b591cd5107da44d35b60fc
5
5
  SHA512:
6
- metadata.gz: 60ccb8ff250b4bfab1da699cbd7f7433aa1ad9cf08087e1545bfc297835ba722a28aa2effeeea982a4823839e633609bf26415b4e549c5392f78e176c7b6ecd4
7
- data.tar.gz: 3d7bb6dcfb36fa128b8d60975219598bce3656b05b70b9289a37135239a3a6fee3532700697cc76b8c0d3eddd02f7ea280a84a47ded27daa4c8af510dbb633e9
6
+ metadata.gz: d3105561c117ba12b9c63d9dfd423db9665eac81282b64792d404f5c49d4bf6a033c0b01c29d46a84915a86ca7dedae5219feffaebfc2dd9dc3672d7406ffa6e
7
+ data.tar.gz: 7a92076300c1eb790365b3c7049e403b0ea02deab720acf70c84b45e586a01582363ce49446c991e223ee3c4839250b66b2ef127a8f795878b3896d1a79aaefb
@@ -1,3 +1,7 @@
1
+ ## 2.2.0 (Oct 7, 2014)
2
+ * Numerous command-line fixes, sorry folks!
3
+ * Add 'rpush push' command-line command for one-off use.
4
+
1
5
  ## 2.1.0 (Oct 4, 2014)
2
6
  * Bump APNs max payload size to 2048 for iOS 8.
3
7
  * Add 'category' for iOS 8.
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 `rails init` after upgrading Rpush to check for configuration and migration changes.
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)
@@ -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 :rails_env, type: :string, aliases: '-e', default: 'development'
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
- load_config
45
- ensure_pid_file
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['active-record']
74
+ install_migrations = options['active_record']
80
75
 
81
- unless options.key?('active-record')
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
- private
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
- def detect_rails?
105
- self.class.detect_rails?
104
+ Rpush.push
106
105
  end
107
106
 
108
- def default_config_path
109
- self.class.default_config_path
107
+ private
108
+
109
+ def configure_rpush
110
+ load_rails_environment || load_standalone
110
111
  end
111
112
 
112
- def ensure_pid_file
113
- return if Rpush.config.pid_file.blank?
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
- STDERR.puts(red('ERROR: ') + 'config.pid_file is not set.')
116
- exit 1
122
+ return true
123
+ end
124
+
125
+ false
117
126
  end
118
127
 
119
- def load_config
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
@@ -1,3 +1,5 @@
1
+ require 'pathname'
2
+
1
3
  module Rpush
2
4
  def self.config
3
5
  @config ||= Rpush::Configuration.new
@@ -10,6 +10,7 @@ module Rpush
10
10
  Rpush::Daemon.initialize_store
11
11
  Rpush::Daemon::Synchronizer.sync
12
12
  Rpush::Daemon::Feeder.start
13
+ # TODO: Wait until there are no more notifications.
13
14
  Rpush::Daemon::AppRunner.stop
14
15
  end
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module Rpush
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -1,46 +1,62 @@
1
- namespace :test do
2
- task :build_rails do
3
- require 'fileutils'
4
-
5
- def cmd(str, clean_env = true)
6
- puts "* #{str}"
7
- retval = clean_env ? Bundler.with_clean_env { `#{str}` } : `#{str}`
8
- puts retval.strip
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
- rpush_root = Dir.pwd
13
- path = '/tmp/rails_test'
14
- cmd("rm -rf #{path}")
15
- FileUtils.mkdir_p(path)
16
- pwd = Dir.pwd
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
- cmd("bundle exec rails --version", false)
19
- cmd("bundle exec rails new #{path} --skip-bundle", false)
17
+ cmd("bundle exec rails --version", false)
18
+ cmd("bundle exec rails new #{path} --skip-bundle", false)
20
19
 
21
- begin
22
- Dir.chdir(path)
23
- cmd('echo "gem \'rake\'" >> Gemfile')
24
- cmd('echo "gem \'pg\'" >> Gemfile')
25
- cmd("echo \"gem 'rpush', :path => '#{rpush_root}'\" >> Gemfile")
26
- cmd('bundle install')
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
- File.open('config/database.yml', 'w') do |fd|
29
- fd.write(<<-YML)
27
+ File.open('config/database.yml', 'w') do |fd|
28
+ fd.write(<<-YML)
30
29
  development:
31
- adapter: postgresql
32
- database: rpush_rails_test
33
- pool: 5
34
- timeout: 5000
35
- YML
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
- puts "Built into #{path}"
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.1.0
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-05 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json