lowdown 0.1.1 → 0.2.0
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/lowdown/response.rb +16 -5
- data/lib/lowdown/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 74b301dd024aaf5cf6933d95639ff6b0f016e26f
         | 
| 4 | 
            +
              data.tar.gz: 13981473dbf0c6a8c117fadd09152e23a93c9073
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dc3bef31593849519775831cc608a34321c5883a12f72b7ad8baabbd9796d70bf5d184dd092b0beaa7b14e85a171f683a58c0a3f6a66623ca5d71fa196298c10
         | 
| 7 | 
            +
              data.tar.gz: 191a7e45a3e6af3e9ac3c8af8ad04733195754d7822c5463ef26939d0171e0bbe02479dd34100255b20443ddfea8b618f429e810b7549cfc69424fdbe776ae3f
         | 
    
        data/lib/lowdown/response.rb
    CHANGED
    
    | @@ -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  | 
| 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  | 
| 106 | 
            +
                #         in case of an inactive token, the time at which the service last verified it.
         | 
| 96 107 | 
             
                #
         | 
| 97 | 
            -
                def  | 
| 98 | 
            -
                  Time.at(body["timestamp"].to_i) if  | 
| 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 #{ | 
| 118 | 
            +
                  s << " last checked at #{activity_last_checked_at}" if inactive_token?
         | 
| 108 119 | 
             
                  s
         | 
| 109 120 | 
             
                end
         | 
| 110 121 |  | 
    
        data/lib/lowdown/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 11 | 
            +
            date: 2016-01-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: http-2
         |