lorkhan 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +52 -0
- data/.rubocop.yml +40 -8
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/circle.yml +6 -0
- data/lib/lorkhan/connection.rb +2 -0
- data/lib/lorkhan/notification.rb +29 -6
- data/lib/lorkhan/request.rb +1 -0
- data/lib/lorkhan/version.rb +1 -1
- data/lorkhan.gemspec +12 -12
- metadata +39 -39
- data/Gemfile.lock +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58754e7965fd554a049827f95fab030f74b1c6da0214516ece266f004dc0b7bb
|
4
|
+
data.tar.gz: 9a3a23a0223246951dbb8533c9d355a496534e712bc116867ab539637f98407d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eae2fec79cc2c09f1c922d1598477179f6d138a2e92e29417cfc76e3cbe4e37e1cf101cfff4c49a873baa5b8f17e25a04749327ee15bccece932ebd59dc8d8c
|
7
|
+
data.tar.gz: 8645ce2aa8fbd1d7bf96ab13745bd10cf4cf1dd27d618ce66740c607fd06801e4d12e7f8ccd60b142943f9b0ed5c0fa31592e8875ca5473d800f2a26e8a11cc1
|
data/.gitignore
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
/Gemfile.lock
|
data/.rubocop.yml
CHANGED
@@ -1,28 +1,60 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.5
|
3
3
|
Exclude:
|
4
|
-
-
|
4
|
+
- Rakefile
|
5
5
|
|
6
6
|
Metrics/AbcSize:
|
7
7
|
Max: 30
|
8
8
|
|
9
9
|
Metrics/LineLength:
|
10
|
-
Max:
|
10
|
+
Max: 160
|
11
11
|
|
12
12
|
Metrics/MethodLength:
|
13
|
-
|
13
|
+
Enabled: false
|
14
14
|
|
15
|
-
Metrics/
|
15
|
+
Metrics/ParameterLists:
|
16
16
|
Max: 10
|
17
17
|
|
18
|
-
Metrics/
|
18
|
+
Metrics/CyclomaticComplexity:
|
19
19
|
Max: 10
|
20
20
|
|
21
|
-
|
22
|
-
Enabled:
|
21
|
+
Metrics/BlockLength:
|
22
|
+
Enabled: true
|
23
|
+
Exclude:
|
24
|
+
- spec/**/*
|
25
|
+
|
26
|
+
DotPosition:
|
27
|
+
EnforcedStyle: leading
|
28
|
+
|
29
|
+
StringLiterals:
|
30
|
+
EnforcedStyle: single_quotes
|
31
|
+
|
32
|
+
Layout/AlignParameters:
|
33
|
+
EnforcedStyle: with_fixed_indentation
|
34
|
+
|
35
|
+
Layout/MultilineOperationIndentation:
|
36
|
+
EnforcedStyle: indented
|
37
|
+
|
38
|
+
Layout/MultilineMethodCallIndentation:
|
39
|
+
EnforcedStyle: indented
|
40
|
+
|
41
|
+
Style/AndOr:
|
42
|
+
EnforcedStyle: conditionals
|
23
43
|
|
24
44
|
Style/ClassAndModuleChildren:
|
25
45
|
Enabled: false
|
26
46
|
|
47
|
+
Style/ConditionalAssignment:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Style/GuardClause:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/RaiseArgs:
|
54
|
+
Enabled: false
|
55
|
+
|
27
56
|
Style/FrozenStringLiteralComment:
|
28
57
|
Enabled: false
|
58
|
+
|
59
|
+
Style/IfUnlessModifier:
|
60
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## Lorkhan
|
2
2
|
|
3
|
+
[![CircleCI](https://circleci.com/gh/skylarsch/lorkhan/tree/master.svg?style=svg)](https://circleci.com/gh/skylarsch/lorkhan/tree/master) [![Code Climate](https://lima.codeclimate.com/github/skylarsch/lorkhan/badges/gpa.svg)](https://lima.codeclimate.com/github/skylarsch/lorkhan) [![Issue Count](https://lima.codeclimate.com/github/skylarsch/lorkhan/badges/issue_count.svg)](https://lima.codeclimate.com/github/skylarsch/lorkhan)
|
4
|
+
|
3
5
|
Apple Push Notification Services client using the HTTP/2 API and Provider Authentication Tokens
|
4
6
|
|
5
7
|
### Getting Provider Authentication Tokens
|
data/circle.yml
ADDED
data/lib/lorkhan/connection.rb
CHANGED
@@ -59,6 +59,7 @@ module Lorkhan
|
|
59
59
|
headers['authorization'] = "bearer #{auth_token}"
|
60
60
|
raw_response = @client.call(:post, request.path, body: request.body, headers: headers, timeout: 5)
|
61
61
|
raise Errors::TimeoutError if raw_response.nil?
|
62
|
+
|
62
63
|
response = Response.new(raw_response)
|
63
64
|
handle_http_error(response) unless response.ok?
|
64
65
|
response
|
@@ -89,6 +90,7 @@ module Lorkhan
|
|
89
90
|
|
90
91
|
def check_token_should_refresh
|
91
92
|
return if @refresh_token_at.nil?
|
93
|
+
|
92
94
|
refresh_token if Time.now.to_i >= @refresh_token_at
|
93
95
|
end
|
94
96
|
end
|
data/lib/lorkhan/notification.rb
CHANGED
@@ -47,9 +47,9 @@ module Lorkhan
|
|
47
47
|
##
|
48
48
|
PRIORITY_DELIVER_BACKGROUND = 5
|
49
49
|
|
50
|
-
attr_reader :token, :apns_id
|
51
|
-
attr_accessor :custom_payload, :
|
52
|
-
attr_accessor :expiration, :
|
50
|
+
attr_reader :token, :apns_id, :priority, :alert, :content_available
|
51
|
+
attr_accessor :custom_payload, :badge, :sound, :category, :url_args, :mutable_content
|
52
|
+
attr_accessor :expiration, :topic, :collapse_id
|
53
53
|
|
54
54
|
##
|
55
55
|
# Create a new notification
|
@@ -57,16 +57,39 @@ module Lorkhan
|
|
57
57
|
# token: The Device token that the notification will be delivered to
|
58
58
|
##
|
59
59
|
def initialize(token)
|
60
|
-
@token
|
61
|
-
@apns_id
|
60
|
+
@token = token
|
61
|
+
@apns_id = SecureRandom.uuid
|
62
62
|
@expiration = 0
|
63
|
-
@
|
63
|
+
@content_available = false
|
64
|
+
@priority = PRIORITY_DELIVER_IMMEDIATELY
|
64
65
|
end
|
65
66
|
|
66
67
|
def body
|
67
68
|
JSON.dump(to_h).force_encoding(Encoding::BINARY)
|
68
69
|
end
|
69
70
|
|
71
|
+
def push_type
|
72
|
+
return 'background' if content_available == true
|
73
|
+
|
74
|
+
'alert'
|
75
|
+
end
|
76
|
+
|
77
|
+
def alert=(alert)
|
78
|
+
@alert = alert
|
79
|
+
if @alert
|
80
|
+
@content_available = false
|
81
|
+
@priority = PRIORITY_DELIVER_IMMEDIATELY
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def content_available=(content_available)
|
86
|
+
@content_available = content_available
|
87
|
+
if content_available == true
|
88
|
+
@alert = nil
|
89
|
+
@priority = PRIORITY_DELIVER_BACKGROUND
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
70
93
|
def to_h
|
71
94
|
{}.tap do |root|
|
72
95
|
root[:aps] = {}.tap do |aps|
|
data/lib/lorkhan/request.rb
CHANGED
@@ -21,6 +21,7 @@ module Lorkhan
|
|
21
21
|
head['apns-priority'] = notif.priority.to_s if notif.priority
|
22
22
|
head['apns-topic'] = notif.topic if notif.topic
|
23
23
|
head['apns-collapse-id'] = notif.collapse_id if notif.collapse_id
|
24
|
+
head['apns-push-type'] = notif.push_type
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
data/lib/lorkhan/version.rb
CHANGED
data/lorkhan.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'lorkhan/version'
|
5
4
|
|
@@ -7,23 +6,24 @@ Gem::Specification.new do |spec|
|
|
7
6
|
spec.name = 'lorkhan'
|
8
7
|
spec.version = Lorkhan::VERSION
|
9
8
|
spec.licenses = ['MIT']
|
10
|
-
spec.authors = ['
|
11
|
-
spec.email = ['me@
|
9
|
+
spec.authors = ['Maddie Schipper']
|
10
|
+
spec.email = ['me@maddiesch.com']
|
12
11
|
spec.summary = 'APNS HTTP/2 Client'
|
13
|
-
spec.homepage = 'http://github.com/
|
14
|
-
|
12
|
+
spec.homepage = 'http://github.com/maddiesch/lorkhan'
|
13
|
+
|
14
|
+
spec.required_ruby_version = '>= 2.5.0'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.bindir = 'exe'
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = %w
|
19
|
+
spec.require_paths = %w[lib]
|
20
20
|
|
21
|
+
spec.add_dependency 'connection_pool', '>= 2.2'
|
22
|
+
spec.add_dependency 'jwt', '>= 2.2.1'
|
21
23
|
spec.add_dependency 'net-http2', '>= 0.14.1', '< 2'
|
22
|
-
spec.add_dependency 'connection_pool', '>= 2.0'
|
23
|
-
spec.add_dependency 'jwt', '>= 1.5.6'
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
26
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.5'
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
28
26
|
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,134 +1,135 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorkhan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Maddie Schipper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: connection_pool
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '2'
|
19
|
+
version: '2.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2'
|
26
|
+
version: '2.2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: jwt
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
33
|
+
version: 2.2.1
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: 2.2.1
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: net-http2
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: 0.14.1
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2'
|
54
51
|
type: :runtime
|
55
52
|
prerelease: false
|
56
53
|
version_requirements: !ruby/object:Gem::Requirement
|
57
54
|
requirements:
|
58
55
|
- - ">="
|
59
56
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
57
|
+
version: 0.14.1
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: bundler
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '2.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '2.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: pry
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - "
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
90
|
+
name: rake
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '10.0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '10.0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
104
|
+
name: rspec
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - "
|
107
|
+
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '3.5'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - "
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
116
|
+
version: '3.5'
|
117
117
|
description:
|
118
118
|
email:
|
119
|
-
- me@
|
119
|
+
- me@maddiesch.com
|
120
120
|
executables: []
|
121
121
|
extensions: []
|
122
122
|
extra_rdoc_files: []
|
123
123
|
files:
|
124
|
+
- ".gitignore"
|
124
125
|
- ".rspec"
|
125
126
|
- ".rubocop.yml"
|
126
127
|
- CHANGELOG.md
|
127
128
|
- Gemfile
|
128
|
-
- Gemfile.lock
|
129
129
|
- README.md
|
130
130
|
- Rakefile
|
131
131
|
- bin/console
|
132
|
+
- circle.yml
|
132
133
|
- lib/lorkhan.rb
|
133
134
|
- lib/lorkhan/connection.rb
|
134
135
|
- lib/lorkhan/connection_pool.rb
|
@@ -144,7 +145,7 @@ files:
|
|
144
145
|
- lib/lorkhan/response.rb
|
145
146
|
- lib/lorkhan/version.rb
|
146
147
|
- lorkhan.gemspec
|
147
|
-
homepage: http://github.com/
|
148
|
+
homepage: http://github.com/maddiesch/lorkhan
|
148
149
|
licenses:
|
149
150
|
- MIT
|
150
151
|
metadata: {}
|
@@ -156,15 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
157
|
requirements:
|
157
158
|
- - ">="
|
158
159
|
- !ruby/object:Gem::Version
|
159
|
-
version: 2.
|
160
|
+
version: 2.5.0
|
160
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
162
|
requirements:
|
162
163
|
- - ">="
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
|
-
|
167
|
-
rubygems_version: 2.5.2
|
167
|
+
rubygems_version: 3.0.3
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: APNS HTTP/2 Client
|
data/Gemfile.lock
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
lorkhan (1.0.0)
|
5
|
-
connection_pool (>= 2.0)
|
6
|
-
jwt (>= 1.5.6)
|
7
|
-
net-http2 (>= 0.14.1, < 2)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
coderay (1.1.1)
|
13
|
-
connection_pool (2.2.1)
|
14
|
-
diff-lcs (1.3)
|
15
|
-
http-2 (0.8.3)
|
16
|
-
jwt (1.5.6)
|
17
|
-
method_source (0.8.2)
|
18
|
-
net-http2 (0.14.1)
|
19
|
-
http-2 (~> 0.8.2)
|
20
|
-
pry (0.10.4)
|
21
|
-
coderay (~> 1.1.0)
|
22
|
-
method_source (~> 0.8.1)
|
23
|
-
slop (~> 3.4)
|
24
|
-
rake (10.5.0)
|
25
|
-
rspec (3.5.0)
|
26
|
-
rspec-core (~> 3.5.0)
|
27
|
-
rspec-expectations (~> 3.5.0)
|
28
|
-
rspec-mocks (~> 3.5.0)
|
29
|
-
rspec-core (3.5.4)
|
30
|
-
rspec-support (~> 3.5.0)
|
31
|
-
rspec-expectations (3.5.0)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.5.0)
|
34
|
-
rspec-mocks (3.5.0)
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.5.0)
|
37
|
-
rspec-support (3.5.0)
|
38
|
-
slop (3.6.0)
|
39
|
-
|
40
|
-
PLATFORMS
|
41
|
-
ruby
|
42
|
-
|
43
|
-
DEPENDENCIES
|
44
|
-
bundler (~> 1.3)
|
45
|
-
lorkhan!
|
46
|
-
pry
|
47
|
-
rake (~> 10.0)
|
48
|
-
rspec (~> 3.5)
|
49
|
-
|
50
|
-
BUNDLED WITH
|
51
|
-
1.13.6
|