actionpusher 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -4
- data/lib/action_pusher/apn_certificate.rb +16 -11
- metadata +2 -2
data/README.md
CHANGED
@@ -9,10 +9,15 @@ To use, require the gem inside your `Gemfile`:
|
|
9
9
|
gem 'actionpusher', require: 'action_pusher'
|
10
10
|
```
|
11
11
|
|
12
|
-
Make sure your `.pem` files are under `config/certificates` with
|
12
|
+
Make sure your `.pem` files are under `config/certificates`. Then create a `config/certificates.yml` file and a setup for each environment. Here's an example with a `development` and `production` configuration:
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
```
|
15
|
+
development:
|
16
|
+
name: 'push-notification-development.pem'
|
17
|
+
|
18
|
+
production:
|
19
|
+
name: 'push-notification-production.pem'
|
20
|
+
```
|
16
21
|
|
17
22
|
Then you can define a push sender. We define our pushers inside of `app/pushers` like so:
|
18
23
|
|
@@ -44,7 +49,7 @@ MyPusher.delay.send_a_push_notification
|
|
44
49
|
## TODO
|
45
50
|
|
46
51
|
* Implement [interceptor pattern](https://github.com/rails/rails/blob/980cdd30dc06e7cdf3490062731bb9f14789daec/actionmailer/lib/action_mailer/base.rb#L463)
|
47
|
-
* YAML based configuration for pem files
|
52
|
+
* <strike>YAML based configuration for pem files</strike>
|
48
53
|
* <strike>Get working with DelayedJob: `MyPusher.delay.send_a_push_notification`</strike>
|
49
54
|
|
50
55
|
## Copyright
|
@@ -1,25 +1,30 @@
|
|
1
1
|
require 'houston'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module ActionPusher
|
4
5
|
class APNCertificate
|
5
6
|
def self.instance
|
6
7
|
apn.tap do |apn|
|
7
|
-
|
8
|
-
apn.certificate = File.read(
|
9
|
-
File.join(::Rails.root, 'config', 'certificates', "push-notification-#{APNCertificate.environment_string}.pem"))
|
8
|
+
apn.certificate = apn_certificate
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
#######
|
14
12
|
private
|
15
|
-
#######
|
16
13
|
|
17
|
-
def self.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
def self.apn_certificate
|
15
|
+
File.read(certificate_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.certificate_path
|
19
|
+
File.join(::Rails.root, 'config', 'certificates', certificate_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.certificate_name
|
23
|
+
config[Rails.env]['name']
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.config
|
27
|
+
YAML.load_file('config/certificates.yml')
|
23
28
|
end
|
24
29
|
|
25
30
|
def self.apn
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionpusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2014-
|
12
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|