Skip to content

Commit 4ff6785

Browse files
authored
Merge pull request #13 from fishbrain/fix-ruby-3-compatibility
Fix Ruby 3 compatibility
2 parents 28fb88f + 8fbf9ea commit 4ff6785

17 files changed

Lines changed: 51 additions & 156 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
name: CI
22

3-
on:
4-
pull_request:
5-
branches: [ master ]
3+
on: [pull_request]
64

75
jobs:
86
ci:
9-
107
runs-on: ubuntu-latest
118
strategy:
129
matrix:
13-
ruby-version: ['2.5', '2.6', '2.7']
14-
10+
ruby: ['2.7', '3.0', '3.1', 'head']
1511
steps:
1612
- uses: actions/checkout@v2
1713
- name: Set up Ruby
18-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
14+
uses: ruby/setup-ruby@v1
1915
with:
20-
ruby-version: ${{ matrix.ruby-version }}
16+
ruby-version: ${{ matrix.ruby }}
2117
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
22-
- name: Run RSpec
23-
run: bundle exec rspec
24-
- name: Run Rubocop
25-
run: bundle exec rubocop
18+
- run: bundle exec rake
19+
- run: bundle exec rubocop

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212

1313
.rake_t_cache
1414
*.gem
15+
16+
Gemfile.lock

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
AllCops:
2-
TargetRubyVersion: 2.6
2+
NewCops: enable
3+
TargetRubyVersion: 2.7
34

45
Layout/LineLength:
56
Max: 120

Gemfile.lock

Lines changed: 0 additions & 102 deletions
This file was deleted.

lib/tarpon/entity/entitlement_list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def active
1717
@entitlements.select(&:active?)
1818
end
1919

20-
def each
21-
@entitlements.each { |e| yield e }
20+
def each(&block)
21+
@entitlements.each(&block)
2222
end
2323
end
2424
end

lib/tarpon/entity/offerings.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class Offerings
1212
def initialize(current_offering_id:, offerings:, **)
1313
@current_offering_id = current_offering_id
1414
@offerings = offerings.each_with_object({}) do |offering, map|
15-
map[offering[:identifier].to_sym] = Tarpon::Entity::Offering.new(offering)
15+
map[offering[:identifier].to_sym] = Tarpon::Entity::Offering.new(**offering)
1616
end
1717
end
1818

19-
def each
20-
@offerings.each { |o| yield o }
19+
def each(&block)
20+
@offerings.each(&block)
2121
end
2222

2323
def [](identifier)

lib/tarpon/request/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def perform(method:, path:, key:, headers: {}, body: nil)
1818
.auth("Bearer #{api_key(key)}")
1919
.headers(headers.merge(DEFAULT_HEADERS))
2020
.send(method, "#{Client.base_uri}#{path}", json: body&.compact)
21-
.yield_self { |http_response| handle_response(http_response) }
21+
.then { |http_response| handle_response(http_response) }
2222
rescue HTTP::TimeoutError => e
2323
raise Tarpon::TimeoutError, e
2424
end

lib/tarpon/request/subscriber.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ module Tarpon
44
module Request
55
class Subscriber < Base
66
def initialize(app_user_id:)
7+
super()
78
@app_user_id = app_user_id
89
end
910

10-
# rubocop:disable Naming/AccessorMethodName
11-
def get_or_create
11+
def get_or_create # rubocop:disable Naming/AccessorMethodName
1212
perform(method: :get, path: path, key: :public)
1313
end
14-
# rubocop:enable Naming/AccessorMethodName
1514

1615
def delete
1716
perform(method: :delete, path: path, key: :secret)

lib/tarpon/request/subscriber/entitlement.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Request
55
class Subscriber
66
class Entitlement < Base
77
def initialize(subscriber_path:, entitlement_identifier:)
8+
super()
89
@subscriber_path = subscriber_path
910
@entitlement_identifier = entitlement_identifier
1011
end

lib/tarpon/request/subscriber/offering.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ module Request
77
class Subscriber
88
class Offering < Base
99
def initialize(subscriber_path:)
10+
super()
1011
@subscriber_path = subscriber_path
1112
end
1213

1314
def list(platform)
1415
response = perform(method: :get, path: path.to_s, headers: { 'x-platform': platform.to_s }, key: :public)
1516
return response unless response.success?
1617

17-
Tarpon::Entity::Offerings.new(response.raw)
18+
Tarpon::Entity::Offerings.new(**response.raw)
1819
end
1920

2021
private

0 commit comments

Comments
 (0)