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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9adf83a271284f4f0ca44b19897b7c629bf4d31d
4
- data.tar.gz: 442cc5dfb07aaa825da7c06c67fa46a7dfe90b2d
3
+ metadata.gz: d0cf48d1191d9ea076ac76338c26de358d983ef9
4
+ data.tar.gz: 477e962ffc5869f21d3d97f8579c937ad2ef3daa
5
5
  SHA512:
6
- metadata.gz: 51d691f1bf60ba463490702fede28b6c67681e0073da21cc5165f141db8437cc57c612d246b96cd7daa76a6951118613df1121d326afe791c886ce7020f1b980
7
- data.tar.gz: 31b66b45aeef3a5f9700b829cabea23a2bce5cb1161509fb33c2b7dca67d948c3f441111e9c4ab8cb54e2dcc6013e6ecd024d41f70a0f148010ac1e7c908e053
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
- devices.where(device_identifier: device_identifier, platform: platform).
20
- find_or_initialize
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module J7W1
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -2,6 +2,7 @@ require 'yaml'
2
2
 
3
3
  module J7W1
4
4
  autoload :Configuration, 'j7_w1/configuration'
5
+ autoload :Util, 'j7_w1/util'
5
6
 
6
7
  class << self
7
8
  attr_reader :current_strategy
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
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-28 00:00:00.000000000 Z
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