j7w1 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/j7_w1/migration/templates/active_record/migration.rb +3 -0
- data/lib/generators/j7_w1/model/templates/j7_w1_application_device.rb.erb +5 -2
- data/lib/j7_w1/active_record_ext.rb +3 -2
- data/lib/j7_w1/util.rb +16 -0
- data/lib/j7_w1/version.rb +1 -1
- data/lib/j7w1.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0cf48d1191d9ea076ac76338c26de358d983ef9
|
4
|
+
data.tar.gz: 477e962ffc5869f21d3d97f8579c937ad2ef3daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860d85c72a4594c02a7f02bc1248232445c8ea24305dbf45c379c4d83da9b083d08a7c5d1a504c245facc5ff3a156f8f58d23c9e5eb9c7ffd9f39446306fa63c
|
7
|
+
data.tar.gz: ef4f6c8c0df6bbf2dadb76071a2735f1db05e355ad1a4cf9997fcb63865e78edbb79dd9a0d8353276bd765df7b5522c06afd9a4cbcd87fc84c36305467cebb61
|
@@ -6,6 +6,9 @@ class J7W1ApplicationDevices < ActiveRecord::Migration
|
|
6
6
|
t.string :device_identifier, null: false
|
7
7
|
t.string :platform, null: false
|
8
8
|
t.string :device_endpoint_arn, null: true
|
9
|
+
|
10
|
+
t.index [:owner_type, :owner_id]
|
11
|
+
t.index [:device_identifier, :platform], unique: true
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
@@ -11,6 +11,9 @@ class J7W1ApplicationDevice < ActiveRecord::Base
|
|
11
11
|
after_destroy :destroy_device_endpoint
|
12
12
|
<%- end -%>
|
13
13
|
|
14
|
+
scope :identified, -> identifier { where(device_identifier: identifier}
|
15
|
+
scope :on_platform, -> platform { where(platform: J7W1::Util.normalize_platform(platform)) }
|
16
|
+
|
14
17
|
def push!(options = {})
|
15
18
|
J7W1::PushClient.push device_endpoint_arn, platform, *options
|
16
19
|
end
|
@@ -24,9 +27,10 @@ class J7W1ApplicationDevice < ActiveRecord::Base
|
|
24
27
|
def destroy_device_endpoint
|
25
28
|
J7W1::PushClient.destroy_endpoint device_arn
|
26
29
|
end
|
27
|
-
<%- if options['async_engine'] == 'delayed_job' -%>
|
28
30
|
|
29
31
|
private
|
32
|
+
<%- if options['async_engine'] == 'delayed_job' -%>
|
33
|
+
|
30
34
|
def create_device_endpoint_async
|
31
35
|
delay.create_device_endpoint
|
32
36
|
end
|
@@ -36,7 +40,6 @@ class J7W1ApplicationDevice < ActiveRecord::Base
|
|
36
40
|
end
|
37
41
|
<%- elsif options['async_engine'] == 'sidekiq' -%>
|
38
42
|
|
39
|
-
private
|
40
43
|
def create_device_endpoint_async
|
41
44
|
J7W1Worker.perform_async id
|
42
45
|
end
|
@@ -16,9 +16,10 @@ module J7W1
|
|
16
16
|
module InstanceMethods
|
17
17
|
def add_device(device_identifier, platform)
|
18
18
|
device =
|
19
|
-
|
20
|
-
|
19
|
+
J7W1ApplicationDevice.identified(device_identifier).on_platform(J7W1::Util.normalize_platform(platform)).
|
20
|
+
first_or_initialize
|
21
21
|
device.endpoint_arn = nil
|
22
|
+
device.owner = self
|
22
23
|
device.save!
|
23
24
|
end
|
24
25
|
|
data/lib/j7_w1/util.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module J7W1
|
2
|
+
module Util
|
3
|
+
def normalize_platform(platform)
|
4
|
+
platform = platform.to_s.downcase.to_sym unless platform.is_a? Symbol
|
5
|
+
|
6
|
+
case platform
|
7
|
+
when :ios, :'iPhone OS', :'iPad OS'
|
8
|
+
:ios
|
9
|
+
else
|
10
|
+
platform
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
instance_methods(false).each{|m|module_function m}
|
15
|
+
end
|
16
|
+
end
|
data/lib/j7_w1/version.rb
CHANGED
data/lib/j7w1.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: j7w1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- condor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/j7_w1/configuration.rb
|
89
89
|
- lib/j7_w1/mock.rb
|
90
90
|
- lib/j7_w1/push_client.rb
|
91
|
+
- lib/j7_w1/util.rb
|
91
92
|
- lib/j7_w1/version.rb
|
92
93
|
- lib/j7w1.rb
|
93
94
|
- spec/.gitignore
|