lowdown 0.1.1 → 0.2.0

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: 044f0dfd72c7b5a984abac1cd844e06b71b1fac1
4
- data.tar.gz: 68eae4bb641cf6d39edaf59681060f6b7ded8089
3
+ metadata.gz: 74b301dd024aaf5cf6933d95639ff6b0f016e26f
4
+ data.tar.gz: 13981473dbf0c6a8c117fadd09152e23a93c9073
5
5
  SHA512:
6
- metadata.gz: 65c0917420183c3408930d60645e00d54ffcf653bb3f28aa61aa00a8a85f623213652fbb7b8eded3c6524caa8025c57e488f8c5a58cd7786333e8b3eba0fed23
7
- data.tar.gz: 2e20f00c914f2a95efff4a0a017f768004c892fdce49549b8aa269d30d2e431575c7b66e83103a4f3beb7af3a1c63dff6144955f6130e46b209677cbbf0df5f2
6
+ metadata.gz: dc3bef31593849519775831cc608a34321c5883a12f72b7ad8baabbd9796d70bf5d184dd092b0beaa7b14e85a171f683a58c0a3f6a66623ca5d71fa196298c10
7
+ data.tar.gz: 191a7e45a3e6af3e9ac3c8af8ad04733195754d7822c5463ef26939d0171e0bbe02479dd34100255b20443ddfea8b618f429e810b7549cfc69424fdbe776ae3f
@@ -25,6 +25,10 @@ module Lowdown
25
25
  503 => "The server is shutting down and unavailable"
26
26
  }
27
27
 
28
+ # The reasons that indicate a device token not being valid besides just being unregistered.
29
+ #
30
+ INVALID_TOKEN_REASONS = %{ Unregistered BadDeviceToken DeviceTokenNotForTopic }.freeze
31
+
28
32
  # @return [String]
29
33
  # either the {Notification#id} or, if none was provided, an ID generated by the service.
30
34
  #
@@ -85,17 +89,24 @@ module Lowdown
85
89
  end
86
90
 
87
91
  # @return [Boolean]
88
- # whether or not the delivery has failed due to a token no longer being valid.
92
+ # whether or not the token is invalid for any of the reasons listed in {INVALID_TOKEN_REASONS}.
89
93
  #
90
94
  def invalid_token?
95
+ !success? && INVALID_TOKEN_REASONS.include?(failure_reason)
96
+ end
97
+
98
+ # @return [Boolean]
99
+ # whether or not the delivery has failed due to a token no longer being active.
100
+ #
101
+ def inactive_token?
91
102
  status == 410
92
103
  end
93
104
 
94
105
  # @return [Time, nil]
95
- # in case of an invalid token, the time at which the service last checked it.
106
+ # in case of an inactive token, the time at which the service last verified it.
96
107
  #
97
- def validity_last_checked_at
98
- Time.at(body["timestamp"].to_i) if invalid_token?
108
+ def activity_last_checked_at
109
+ Time.at(body["timestamp"].to_i) if inactive_token?
99
110
  end
100
111
 
101
112
  # @return [String]
@@ -104,7 +115,7 @@ module Lowdown
104
115
  def to_s
105
116
  s = "#{status} (#{message})"
106
117
  s << ": #{failure_reason}" unless success?
107
- s << " last checked at #{validity_last_checked_at}" if invalid_token?
118
+ s << " last checked at #{activity_last_checked_at}" if inactive_token?
108
119
  s
109
120
  end
110
121
 
@@ -1,3 +1,3 @@
1
1
  module Lowdown
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lowdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Durán
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-18 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2