pusher-push-notifications 1.1.0 → 2.0.1

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
- SHA1:
3
- metadata.gz: 8ad9f48448c40362a680daa49622e38fd91270cc
4
- data.tar.gz: 158ea72c621de04521745b568f40f5c6fb8b088d
2
+ SHA256:
3
+ metadata.gz: ab8ec42a2e99aabd1caedcf4440e7afead8424ec23ba28c4700c65b861f26a5e
4
+ data.tar.gz: 6c6811b91de648f49a77cb82ff8d642e5c28f37b8c515e4dd122a867d74970a0
5
5
  SHA512:
6
- metadata.gz: f1da920d75d9a2a07dc36268233395f6df60a253681768386f4a27a223cc08d4c33563ca37a3342b86ef6c0bc8413a1cbee81a750482915989d56090c61a0f26
7
- data.tar.gz: 6d029a5ea9f9b1b385e5e2ef228c613c64bea7fd5bb5fae83a76a0eaa930dc5fd131a871129883a915bf3d1990d5c253b5311f30410682f9872d548d08cf911f
6
+ metadata.gz: 28187b8d79179d64979df36d377218e7dfafb0d0f36918c4b8f416eee6f9614500bed595505b071c937d0a62e2a411908abc190e166fb5df23088f91434a3480
7
+ data.tar.gz: 74b808a2f5f88f75b0fb3024211df2dbf32d770f562a89a62d61c781ac097b137d83987d513af9697cc0278b79835c9b66292c53466fa527c141087f0dad710a
data/.github/stale.yml ADDED
@@ -0,0 +1,26 @@
1
+ # Configuration for probot-stale - https://github.com/probot/stale
2
+
3
+ # Number of days of inactivity before an Issue or Pull Request becomes stale
4
+ daysUntilStale: 90
5
+
6
+ # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7
+ # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8
+ daysUntilClose: 7
9
+
10
+ # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11
+ onlyLabels: []
12
+
13
+ # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14
+ exemptLabels:
15
+ - pinned
16
+ - security
17
+
18
+ # Set to true to ignore issues with an assignee (defaults to false)
19
+ exemptAssignees: true
20
+
21
+ # Comment to post when marking as stale. Set to `false` to disable
22
+ markComment: >
23
+ This issue has been automatically marked as stale because it has not had
24
+ recent activity. It will be closed if no further activity occurs. If you'd
25
+ like this issue to stay open please leave a comment indicating how this issue
26
+ is affecting you. Thank you.
@@ -0,0 +1,35 @@
1
+ name: Github Release
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ jobs:
8
+ create-release:
9
+ name: Create Release
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v2
14
+ - name: Setup git
15
+ run: |
16
+ git config user.email "pusher-ci@pusher.com"
17
+ git config user.name "Pusher CI"
18
+ - name: Prepare description
19
+ run: |
20
+ csplit -s CHANGELOG.md "/##/" {1}
21
+ cat xx01 > CHANGELOG.tmp
22
+ - name: Prepare tag
23
+ run: |
24
+ export TAG=$(head -1 CHANGELOG.tmp | cut -d' ' -f2)
25
+ echo "TAG=$TAG" >> $GITHUB_ENV
26
+ - name: Create Release
27
+ uses: actions/create-release@v1
28
+ env:
29
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30
+ with:
31
+ tag_name: ${{ env.TAG }}
32
+ release_name: ${{ env.TAG }}
33
+ body_path: CHANGELOG.tmp
34
+ draft: false
35
+ prerelease: false
@@ -0,0 +1,17 @@
1
+ name: RubyGems release
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+
14
+ - name: Publish gem
15
+ uses: dawidd6/action-publish-gem@v1
16
+ with:
17
+ api_key: ${{secrets.RUBYGEMS_API_KEY}}
@@ -0,0 +1,74 @@
1
+ name: Release
2
+
3
+ on:
4
+ pull_request:
5
+ types: [ labeled ]
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ prepare-release:
11
+ name: Prepare release
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Set major release
16
+ if: ${{ github.event.label.name == 'release-major' }}
17
+ run: echo "RELEASE=major" >> $GITHUB_ENV
18
+ - name: Set minor release
19
+ if: ${{ github.event.label.name == 'release-minor' }}
20
+ run: echo "RELEASE=minor" >> $GITHUB_ENV
21
+ - name: Set patch release
22
+ if: ${{ github.event.label.name == 'release-patch' }}
23
+ run: echo "RELEASE=patch" >> $GITHUB_ENV
24
+ - name: Check release env
25
+ run: |
26
+ if [[ -z "${{ env.RELEASE }}" ]];
27
+ then
28
+ echo "You need to set a release label on PRs to the main branch"
29
+ exit 1
30
+ else
31
+ exit 0
32
+ fi
33
+ - name: Install semver-tool
34
+ run: |
35
+ export DIR=$(mktemp -d)
36
+ cd $DIR
37
+ curl https://github.com/fsaintjacques/semver-tool/archive/3.2.0.tar.gz -L -o semver.tar.gz
38
+ tar -xvf semver.tar.gz
39
+ sudo cp semver-tool-3.2.0/src/semver /usr/local/bin
40
+ - name: Bump version
41
+ run: |
42
+ export CURRENT=$(gem info pusher-push-notifications --remote --exact | grep -o "pusher-push-notifications ([0-9]*\.[0-9]*\.[0-9]*)" | awk -F '[()]' '{print $2}')
43
+ export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT)
44
+ echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
45
+ - name: Checkout code
46
+ uses: actions/checkout@v2
47
+ - name: Setup git
48
+ run: |
49
+ git config user.email "pusher-ci@pusher.com"
50
+ git config user.name "Pusher CI"
51
+ git fetch
52
+ git checkout ${{ github.event.pull_request.head.ref }}
53
+ - name: Prepare CHANGELOG
54
+ run: |
55
+ echo "${{ github.event.pull_request.body }}" | csplit -s - "/##/"
56
+ echo "# Changelog
57
+
58
+ ## ${{ env.VERSION }}
59
+ " >> CHANGELOG.tmp
60
+ grep "^*" xx01 >> CHANGELOG.tmp
61
+ grep -v "^# " CHANGELOG.md >> CHANGELOG.tmp
62
+ cp CHANGELOG.tmp CHANGELOG.md
63
+ - name: Prepare version.rb
64
+ run: |
65
+ sed -i "s|VERSION = '[^']*'|VERSION = '${{ env.VERSION }}'|" lib/pusher/push_notifications/version.rb
66
+ - name: Prepare Gemfile.lock
67
+ run: |
68
+ sed -i "s|pusher-push-notifications ([^)]*)|pusher-push-notifications (${{ env.VERSION }})|" Gemfile.lock
69
+ - name: Commit changes
70
+ run: |
71
+ git add CHANGELOG.md lib/pusher/push_notifications/version.rb Gemfile.lock
72
+ git commit -m "Bump to version ${{ env.VERSION }}"
73
+ - name: Push
74
+ run: git push
@@ -0,0 +1,31 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.6', '2.7', '3.0']
16
+
17
+ env:
18
+ PUSHER_INSTANCE_ID: 1b880590-6301-4bb5-b34f-45db1c5f5644
19
+ PUSHER_SECRET_KEY: abc
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
28
+ - name: Run tests
29
+ run: bundle exec rake
30
+ - name: Run rubocop
31
+ run: bundle exec rubocop
data/CHANGELOG.md CHANGED
@@ -1,18 +1,31 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ ## 2.0.1
4
4
 
5
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
- and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
+ * [CHANGED] Update Gemfile lock on release.
7
6
 
8
- ## [Unreleased](https://github.com/pusher/push-notifications-ruby/compare/v1.1.0...HEAD)
7
+ ## 2.0.0
9
8
 
10
- ## [1.1.0](https://github.com/pusher/push-notifications-ruby/compare/v1.0.0...v1.1.0) - 2019-02-22
9
+ * [ADDED] Support for Ruby 3.0.
10
+ * [REMOVED] Support for Ruby 2.5 and below.
11
+ * [CHANGED] Refactor tests to avoid caze dependency.
11
12
 
12
- Added
13
+ ## 1.3.0
13
14
 
14
- Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
15
+ * [ADDED] Support for multiple instances of Beams clients to exist for more advanced use cases.
15
16
 
16
- ## [1.0.0](https://github.com/pusher/push-notifications-ruby/compare/v0.3.0...v1.0.0) - 2018-07-31
17
+ ## 1.2.1
17
18
 
18
- - General availability (GA) release.
19
+ * [FIXED] Endpoint also allows the scheme to be configured to enable for local development.
20
+
21
+ ## 1.2.0
22
+
23
+ * [ADDED] Support for "endpoint" overrides to allow for internal integration testing.
24
+
25
+ ## 1.1.0
26
+
27
+ * [ADDED] Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
28
+
29
+ ## 1.0.0
30
+
31
+ * [ADDED] General availability (GA) release.
data/Gemfile.lock CHANGED
@@ -1,136 +1,126 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pusher-push-notifications (1.1.0)
5
- caze (~> 0)
4
+ pusher-push-notifications (2.0.1)
6
5
  jwt (~> 2.1, >= 2.1.0)
7
6
  rest-client (~> 2.0, >= 2.0.2)
8
7
 
9
8
  GEM
10
9
  remote: https://rubygems.org/
11
10
  specs:
12
- activesupport (5.2.2)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- addressable (2.5.2)
18
- public_suffix (>= 2.0.2, < 4.0)
19
- ast (2.3.0)
20
- byebug (10.0.2)
21
- caze (0.2.2)
22
- activesupport (>= 3)
23
- codecov (0.1.10)
24
- json
25
- simplecov
26
- url
27
- coderay (1.1.2)
28
- concurrent-ruby (1.1.4)
29
- coveralls (0.8.21)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.2)
14
+ byebug (11.1.3)
15
+ codecov (0.5.1)
16
+ simplecov (>= 0.15, < 0.22)
17
+ coderay (1.1.3)
18
+ coveralls (0.8.23)
30
19
  json (>= 1.8, < 3)
31
- simplecov (~> 0.14.1)
20
+ simplecov (~> 0.16.1)
32
21
  term-ansicolor (~> 1.3)
33
- thor (~> 0.19.4)
22
+ thor (>= 0.19.4, < 2.0)
34
23
  tins (~> 1.6)
35
- crack (0.4.3)
36
- safe_yaml (~> 1.0.0)
37
- diff-lcs (1.3)
38
- docile (1.1.5)
39
- domain_name (0.5.20180417)
24
+ crack (0.4.5)
25
+ rexml
26
+ diff-lcs (1.4.4)
27
+ docile (1.3.5)
28
+ domain_name (0.5.20190701)
40
29
  unf (>= 0.0.5, < 1.0.0)
41
- dotenv (2.2.1)
42
- hashdiff (0.3.7)
30
+ dotenv (2.7.6)
31
+ hashdiff (1.0.1)
32
+ http-accept (1.7.0)
43
33
  http-cookie (1.0.3)
44
34
  domain_name (~> 0.5)
45
- i18n (1.5.3)
46
- concurrent-ruby (~> 1.0)
47
- json (2.1.0)
48
- jwt (2.1.0)
49
- method_source (0.9.2)
50
- mime-types (3.2.2)
35
+ json (2.5.1)
36
+ jwt (2.2.2)
37
+ method_source (1.0.0)
38
+ mime-types (3.3.1)
51
39
  mime-types-data (~> 3.2015)
52
- mime-types-data (3.2018.0812)
53
- minitest (5.11.3)
40
+ mime-types-data (3.2021.0225)
54
41
  netrc (0.11.0)
55
- parallel (1.12.1)
56
- parser (2.4.0.2)
57
- ast (~> 2.3)
58
- powerpack (0.1.1)
59
- pry (0.12.2)
60
- coderay (~> 1.1.0)
61
- method_source (~> 0.9.0)
62
- pry-byebug (3.6.0)
63
- byebug (~> 10.0)
64
- pry (~> 0.10)
65
- public_suffix (3.0.1)
42
+ parallel (1.20.1)
43
+ parser (3.0.0.0)
44
+ ast (~> 2.4.1)
45
+ pry (0.13.1)
46
+ coderay (~> 1.1)
47
+ method_source (~> 1.0)
48
+ pry-byebug (3.9.0)
49
+ byebug (~> 11.0)
50
+ pry (~> 0.13.0)
51
+ public_suffix (4.0.6)
66
52
  rainbow (3.0.0)
67
- rake (10.5.0)
53
+ rake (13.0.3)
68
54
  rb-readline (0.5.5)
69
- rest-client (2.0.2)
55
+ regexp_parser (2.1.1)
56
+ rest-client (2.1.0)
57
+ http-accept (>= 1.7.0, < 2.0)
70
58
  http-cookie (>= 1.0.2, < 2.0)
71
59
  mime-types (>= 1.16, < 4.0)
72
60
  netrc (~> 0.8)
73
- rspec (3.7.0)
74
- rspec-core (~> 3.7.0)
75
- rspec-expectations (~> 3.7.0)
76
- rspec-mocks (~> 3.7.0)
77
- rspec-core (3.7.0)
78
- rspec-support (~> 3.7.0)
79
- rspec-expectations (3.7.0)
61
+ rexml (3.2.4)
62
+ rspec (3.10.0)
63
+ rspec-core (~> 3.10.0)
64
+ rspec-expectations (~> 3.10.0)
65
+ rspec-mocks (~> 3.10.0)
66
+ rspec-core (3.10.1)
67
+ rspec-support (~> 3.10.0)
68
+ rspec-expectations (3.10.1)
80
69
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.7.0)
82
- rspec-mocks (3.7.0)
70
+ rspec-support (~> 3.10.0)
71
+ rspec-mocks (3.10.2)
83
72
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.7.0)
85
- rspec-support (3.7.0)
86
- rubocop (0.52.0)
73
+ rspec-support (~> 3.10.0)
74
+ rspec-support (3.10.2)
75
+ rubocop (1.11.0)
87
76
  parallel (~> 1.10)
88
- parser (>= 2.4.0.2, < 3.0)
89
- powerpack (~> 0.1)
77
+ parser (>= 3.0.0.0)
90
78
  rainbow (>= 2.2.2, < 4.0)
79
+ regexp_parser (>= 1.8, < 3.0)
80
+ rexml
81
+ rubocop-ast (>= 1.2.0, < 2.0)
91
82
  ruby-progressbar (~> 1.7)
92
- unicode-display_width (~> 1.0, >= 1.0.1)
93
- ruby-progressbar (1.9.0)
94
- safe_yaml (1.0.4)
95
- simplecov (0.14.1)
96
- docile (~> 1.1.0)
83
+ unicode-display_width (>= 1.4.0, < 3.0)
84
+ rubocop-ast (1.4.1)
85
+ parser (>= 2.7.1.5)
86
+ ruby-progressbar (1.11.0)
87
+ simplecov (0.16.1)
88
+ docile (~> 1.1)
97
89
  json (>= 1.8, < 3)
98
90
  simplecov-html (~> 0.10.0)
99
91
  simplecov-html (0.10.2)
100
- term-ansicolor (1.6.0)
92
+ sync (0.5.0)
93
+ term-ansicolor (1.7.1)
101
94
  tins (~> 1.0)
102
- thor (0.19.4)
103
- thread_safe (0.3.6)
104
- tins (1.16.3)
105
- tzinfo (1.2.5)
106
- thread_safe (~> 0.1)
95
+ thor (1.1.0)
96
+ tins (1.28.0)
97
+ sync
107
98
  unf (0.1.4)
108
99
  unf_ext
109
- unf_ext (0.0.7.5)
110
- unicode-display_width (1.3.0)
111
- url (0.3.2)
100
+ unf_ext (0.0.7.7)
101
+ unicode-display_width (2.0.0)
112
102
  vcr (3.0.3)
113
- webmock (3.1.1)
103
+ webmock (3.12.0)
114
104
  addressable (>= 2.3.6)
115
105
  crack (>= 0.3.2)
116
- hashdiff
106
+ hashdiff (>= 0.4.0, < 2.0.0)
117
107
 
118
108
  PLATFORMS
119
109
  ruby
120
110
 
121
111
  DEPENDENCIES
122
- bundler (~> 1.16)
112
+ bundler (~> 2.2)
123
113
  codecov (~> 0)
124
114
  coveralls (~> 0.8.21)
125
115
  dotenv (~> 2.2, >= 2.2.1)
126
116
  pry-byebug (~> 3.6, >= 3.6.0)
127
117
  pusher-push-notifications!
128
- rake (~> 10.0)
118
+ rake (~> 13.0)
129
119
  rb-readline (~> 0)
130
120
  rspec (~> 3.0)
131
- rubocop (~> 0)
121
+ rubocop (>= 0.49.0)
132
122
  vcr (~> 3.0, >= 3.0.3)
133
123
  webmock (~> 3.0, >= 3.0.1)
134
124
 
135
125
  BUNDLED WITH
136
- 1.16.2
126
+ 2.2.13
data/README.md CHANGED
@@ -22,13 +22,17 @@ gem 'pusher-push-notifications'
22
22
  This configuration can be done anywhere you want, but if you are using rails the better place to put it is inside an initializer
23
23
 
24
24
  ```ruby
25
+ require 'pusher/push_notifications'
26
+
25
27
  Pusher::PushNotifications.configure do |config|
26
28
   config.instance_id = ENV['PUSHER_INSTANCE_ID'] # or the value directly
27
29
   config.secret_key = ENV['PUSHER_SECRET_KEY']
28
30
  end
29
31
  ```
30
32
 
31
- Where `instance_id` and `secret_key` are the values of the instance you created in the Pusher Beams dashboard
33
+ Where `instance_id` and `secret_key` are the values of the instance you created in the Pusher Beams dashboard.
34
+
35
+ If multiple clients are needed, store the reference that is returned from the `configure` method.
32
36
 
33
37
  ## Usage
34
38
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caze'
4
-
5
3
  require_relative './push_notifications/client'
6
4
  require_relative './push_notifications/use_cases/publish'
7
5
  require_relative './push_notifications/use_cases/publish_to_users'
@@ -13,37 +11,48 @@ require_relative './push_notifications/token'
13
11
 
14
12
  module Pusher
15
13
  module PushNotifications
16
- include Caze
17
-
18
14
  class PushError < RuntimeError; end
19
15
 
20
- has_use_case :publish, UseCases::Publish
21
- has_use_case :publish_to_interests, UseCases::Publish
22
- has_use_case :publish_to_users, UseCases::PublishToUsers
23
- has_use_case :delete_user, UseCases::DeleteUser
24
- has_use_case :generate_token, UseCases::GenerateToken
25
-
26
16
  class << self
17
+ extend Forwardable
18
+
27
19
  attr_reader :instance_id, :secret_key
28
20
 
21
+ def_delegators UseCases::Publish, :publish, :publish_to_interests
22
+ def_delegators UseCases::PublishToUsers, :publish_to_users
23
+ def_delegators UseCases::DeleteUser, :delete_user
24
+ def_delegators UseCases::GenerateToken, :generate_token
25
+
29
26
  def configure
30
27
  yield(self)
31
- self
28
+ # returning a duplicate of `self` to allow multiple clients to be
29
+ # configured without needing to reconfigure the singleton instance
30
+ dup
32
31
  end
33
32
 
34
33
  def instance_id=(instance_id)
35
- if instance_id.nil? || instance_id.delete(' ').empty?
36
- raise PushError, 'Invalid instance id'
37
- end
34
+ raise PushError, 'Invalid instance id' if instance_id.nil? || instance_id.delete(' ').empty?
35
+
38
36
  @instance_id = instance_id
39
37
  end
40
38
 
41
39
  def secret_key=(secret_key)
42
- if secret_key.nil? || secret_key.delete(' ').empty?
43
- raise PushError, 'Invalid secret key'
44
- end
40
+ raise PushError, 'Invalid secret key' if secret_key.nil? || secret_key.delete(' ').empty?
41
+
45
42
  @secret_key = secret_key
46
43
  end
44
+
45
+ def endpoint=(endpoint)
46
+ raise PushError, 'Invalid endpoint override' if !endpoint.nil? && endpoint.delete(' ').empty?
47
+
48
+ @endpoint = endpoint
49
+ end
50
+
51
+ def endpoint
52
+ return @endpoint unless @endpoint.nil?
53
+
54
+ "https://#{@instance_id}.pushnotifications.pusher.com"
55
+ end
47
56
  end
48
57
  end
49
58
  end
@@ -54,16 +54,15 @@ module Pusher
54
54
  private
55
55
 
56
56
  attr_reader :config
57
- def_delegators :@config, :instance_id, :secret_key
57
+
58
+ def_delegators :@config, :instance_id, :secret_key, :endpoint
58
59
 
59
60
  def build_publish_url(resource)
60
- "https://#{instance_id}.pushnotifications.pusher.com/" \
61
- "publish_api/v1/instances/#{instance_id}/#{resource}"
61
+ "#{endpoint}/publish_api/v1/instances/#{instance_id}/#{resource}"
62
62
  end
63
63
 
64
64
  def build_users_url(user)
65
- "https://#{instance_id}.pushnotifications.pusher.com/" \
66
- "customer_api/v1/instances/#{instance_id}/users/#{user}"
65
+ "#{endpoint}/customer_api/v1/instances/#{instance_id}/users/#{user}"
67
66
  end
68
67
 
69
68
  def headers
@@ -20,6 +20,7 @@ module Pusher
20
20
  private
21
21
 
22
22
  attr_reader :config
23
+
23
24
  def_delegators :@config, :instance_id, :secret_key
24
25
  end
25
26
  end
@@ -1,22 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caze'
4
-
5
3
  module Pusher
6
4
  module PushNotifications
7
5
  module UseCases
8
6
  class DeleteUser
9
- include Caze
10
-
11
7
  class UserDeletionError < RuntimeError; end
12
8
 
13
- export :delete_user, as: :delete_user
9
+ class << self
10
+ def delete_user(*args, **kwargs)
11
+ new(*args, **kwargs).delete_user
12
+ end
13
+ end
14
14
 
15
15
  def initialize(user:)
16
16
  @user = user
17
17
  @user_id = Pusher::PushNotifications::UserId.new
18
18
 
19
19
  raise UserDeletionError, 'User Id cannot be empty.' if user.empty?
20
+
20
21
  if user.length > UserId::MAX_USER_ID_LENGTH
21
22
  raise UserDeletionError, 'User id length too long ' \
22
23
  "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
@@ -1,22 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caze'
4
-
5
3
  module Pusher
6
4
  module PushNotifications
7
5
  module UseCases
8
6
  class GenerateToken
9
- include Caze
10
-
11
7
  class GenerateTokenError < RuntimeError; end
12
8
 
13
- export :generate_token, as: :generate_token
9
+ class << self
10
+ def generate_token(*args, **kwargs)
11
+ new(*args, **kwargs).generate_token
12
+ end
13
+ end
14
14
 
15
15
  def initialize(user:)
16
16
  @user = user
17
17
  @user_id = Pusher::PushNotifications::UserId.new
18
18
 
19
19
  raise GenerateTokenError, 'User Id cannot be empty.' if user.empty?
20
+
20
21
  if user.length > UserId::MAX_USER_ID_LENGTH
21
22
  raise GenerateTokenError, 'User id length too long ' \
22
23
  "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
@@ -1,36 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caze'
4
-
5
3
  module Pusher
6
4
  module PushNotifications
7
5
  module UseCases
8
6
  class Publish
9
- include Caze
10
-
11
7
  class PublishError < RuntimeError; end
12
8
 
13
- export :publish, as: :publish
14
- export :publish_to_interests, as: :publish_to_interests
9
+ class << self
10
+ def publish(*args, **kwargs)
11
+ new(*args, **kwargs).publish
12
+ end
13
+
14
+ def publish_to_interests(*args, **kwargs)
15
+ new(*args, **kwargs).publish_to_interests
16
+ end
17
+ end
15
18
 
16
19
  def initialize(interests:, payload: {})
17
20
  @interests = interests
18
21
  @payload = payload
19
22
  @user_id = Pusher::PushNotifications::UserId.new
20
23
 
21
- valid_interest_pattern = /^(_|\-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
24
+ valid_interest_pattern = /^(_|-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
22
25
 
23
26
  interests.each do |interest|
24
27
  next if valid_interest_pattern.match?(interest)
28
+
25
29
  raise PublishError,
26
30
  "Invalid interest name \nMax #{UserId::MAX_USER_ID_LENGTH}" \
27
31
  ' characters and can only contain ASCII upper/lower-case' \
28
32
  ' letters, numbers or one of _-=@,.:'
29
33
  end
30
34
 
31
- if interests.empty?
32
- raise PublishError, 'Must provide at least one interest'
33
- end
35
+ raise PublishError, 'Must provide at least one interest' if interests.empty?
36
+
34
37
  if interests.length > 100
35
38
  raise PublishError, "Number of interests #{interests.length}" \
36
39
  ' exceeds maximum of 100'
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caze'
4
-
5
3
  module Pusher
6
4
  module PushNotifications
7
5
  module UseCases
8
6
  class PublishToUsers
9
- include Caze
10
-
11
7
  class UsersPublishError < RuntimeError; end
12
8
 
13
- export :publish_to_users, as: :publish_to_users
9
+ class << self
10
+ def publish_to_users(*args, **kwargs)
11
+ new(*args, **kwargs).publish_to_users
12
+ end
13
+ end
14
14
 
15
15
  def initialize(users:, payload: {})
16
16
  @users = users
@@ -21,14 +21,14 @@ module Pusher
21
21
  raise UsersPublishError, 'User Id cannot be empty.' if user.empty?
22
22
 
23
23
  next unless user.length > UserId::MAX_USER_ID_LENGTH
24
+
24
25
  raise UsersPublishError, 'User id length too long ' \
25
26
  "(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1}" \
26
27
  ' characters)'
27
28
  end
28
29
 
29
- if users.count < 1
30
- raise UsersPublishError, 'Must supply at least one user id.'
31
- end
30
+ raise UsersPublishError, 'Must supply at least one user id.' if users.count < 1
31
+
32
32
  if users.length > UserId::MAX_NUM_USER_IDS
33
33
  raise UsersPublishError, "Number of user ids #{users.length} "\
34
34
  "exceeds maximum of #{UserId::MAX_NUM_USER_IDS}."
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pusher
4
4
  module PushNotifications
5
- VERSION = '1.1.0'
5
+ VERSION = '2.0.1'
6
6
  end
7
7
  end
@@ -0,0 +1,7 @@
1
+ ## Description
2
+
3
+ Add a short description of the change. If this is related to an issue, please add a reference to the issue.
4
+
5
+ ## CHANGELOG
6
+
7
+ * [CHANGED] Describe your change here. Look at CHANGELOG.md to see the format.
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'pusher/push_notifications/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
+ spec.required_ruby_version = '>= 2.4.2'
8
9
  spec.name = 'pusher-push-notifications'
9
10
  spec.version = Pusher::PushNotifications::VERSION
10
11
  spec.authors = ['Lucas Medeiros', 'Pusher']
@@ -21,19 +22,18 @@ Gem::Specification.new do |spec|
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ['lib']
23
24
 
24
- spec.add_dependency 'caze', '~> 0'
25
25
  spec.add_dependency 'jwt', '~> 2.1', '>= 2.1.0'
26
26
  spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'bundler', '~> 2.2'
29
29
  spec.add_development_dependency 'codecov', '~> 0'
30
30
  spec.add_development_dependency 'coveralls', '~> 0.8.21'
31
31
  spec.add_development_dependency 'dotenv', '~> 2.2', '>= 2.2.1'
32
32
  spec.add_development_dependency 'pry-byebug', '~> 3.6', '>= 3.6.0'
33
- spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
34
  spec.add_development_dependency 'rb-readline', '~> 0'
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
- spec.add_development_dependency 'rubocop', '~> 0'
36
+ spec.add_development_dependency 'rubocop', '>= 0.49.0'
37
37
  spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
38
38
  spec.add_development_dependency 'webmock', '~> 3.0', '>= 3.0.1'
39
39
  end
metadata CHANGED
@@ -1,30 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-push-notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Medeiros
8
8
  - Pusher
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-02-22 00:00:00.000000000 Z
12
+ date: 2021-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: caze
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: jwt
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -71,14 +57,14 @@ dependencies:
71
57
  requirements:
72
58
  - - "~>"
73
59
  - !ruby/object:Gem::Version
74
- version: '1.16'
60
+ version: '2.2'
75
61
  type: :development
76
62
  prerelease: false
77
63
  version_requirements: !ruby/object:Gem::Requirement
78
64
  requirements:
79
65
  - - "~>"
80
66
  - !ruby/object:Gem::Version
81
- version: '1.16'
67
+ version: '2.2'
82
68
  - !ruby/object:Gem::Dependency
83
69
  name: codecov
84
70
  requirement: !ruby/object:Gem::Requirement
@@ -153,14 +139,14 @@ dependencies:
153
139
  requirements:
154
140
  - - "~>"
155
141
  - !ruby/object:Gem::Version
156
- version: '10.0'
142
+ version: '13.0'
157
143
  type: :development
158
144
  prerelease: false
159
145
  version_requirements: !ruby/object:Gem::Requirement
160
146
  requirements:
161
147
  - - "~>"
162
148
  - !ruby/object:Gem::Version
163
- version: '10.0'
149
+ version: '13.0'
164
150
  - !ruby/object:Gem::Dependency
165
151
  name: rb-readline
166
152
  requirement: !ruby/object:Gem::Requirement
@@ -193,16 +179,16 @@ dependencies:
193
179
  name: rubocop
194
180
  requirement: !ruby/object:Gem::Requirement
195
181
  requirements:
196
- - - "~>"
182
+ - - ">="
197
183
  - !ruby/object:Gem::Version
198
- version: '0'
184
+ version: 0.49.0
199
185
  type: :development
200
186
  prerelease: false
201
187
  version_requirements: !ruby/object:Gem::Requirement
202
188
  requirements:
203
- - - "~>"
189
+ - - ">="
204
190
  - !ruby/object:Gem::Version
205
- version: '0'
191
+ version: 0.49.0
206
192
  - !ruby/object:Gem::Dependency
207
193
  name: vcr
208
194
  requirement: !ruby/object:Gem::Requirement
@@ -243,7 +229,7 @@ dependencies:
243
229
  - - ">="
244
230
  - !ruby/object:Gem::Version
245
231
  version: 3.0.1
246
- description:
232
+ description:
247
233
  email:
248
234
  - lucastoc@gmail.com
249
235
  - support@pusher.com
@@ -253,10 +239,14 @@ extra_rdoc_files: []
253
239
  files:
254
240
  - ".coveralls.yml"
255
241
  - ".env.sample"
242
+ - ".github/stale.yml"
243
+ - ".github/workflows/gh-release.yml"
244
+ - ".github/workflows/publish.yml"
245
+ - ".github/workflows/release.yml"
246
+ - ".github/workflows/test.yml"
256
247
  - ".gitignore"
257
248
  - ".rspec"
258
249
  - ".rubocop.yml"
259
- - ".travis.yml"
260
250
  - CHANGELOG.md
261
251
  - Gemfile
262
252
  - Gemfile.lock
@@ -275,12 +265,13 @@ files:
275
265
  - lib/pusher/push_notifications/user_id.rb
276
266
  - lib/pusher/push_notifications/version.rb
277
267
  - lib/pusher_push_notifications.rb
268
+ - pull_request_template.md
278
269
  - pusher-push-notifications.gemspec
279
270
  homepage: https://github.com/pusher/push-notifications-ruby
280
271
  licenses:
281
272
  - MIT
282
273
  metadata: {}
283
- post_install_message:
274
+ post_install_message:
284
275
  rdoc_options: []
285
276
  require_paths:
286
277
  - lib
@@ -288,16 +279,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
279
  requirements:
289
280
  - - ">="
290
281
  - !ruby/object:Gem::Version
291
- version: '0'
282
+ version: 2.4.2
292
283
  required_rubygems_version: !ruby/object:Gem::Requirement
293
284
  requirements:
294
285
  - - ">="
295
286
  - !ruby/object:Gem::Version
296
287
  version: '0'
297
288
  requirements: []
298
- rubyforge_project:
299
- rubygems_version: 2.6.14
300
- signing_key:
289
+ rubygems_version: 3.1.2
290
+ signing_key:
301
291
  specification_version: 4
302
292
  summary: Pusher Push Notifications Ruby server SDK
303
293
  test_files: []
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.2
5
- before_install: gem install bundler -v 1.16.0
6
- script:
7
- - bundle exec rake
8
- - bundle exec rubocop