rating-chgk-v2 1.4.0 → 1.6.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
  SHA256:
3
- metadata.gz: e04c147b75634054c4363396f1d610964a0f5994083d06b3e6644eb001f81db5
4
- data.tar.gz: 996db9eb097c35793c1b17e76f5a9c2aa1390e6abaa462c641793e65e2f7aeee
3
+ metadata.gz: 92553b2ca3c5258a683a08817cdc4ef276878afe738560cb2c553d902b8052b3
4
+ data.tar.gz: 033be3cb040a1833605d621441e07716f223e791a76dca4eeb1d0c3a849d8cc5
5
5
  SHA512:
6
- metadata.gz: 69e18dd4bd3eb3fef7ab30cde3b274af30baab247ee5b447a2d75d7bf4265e1c1a1b3de8835de85eda21bfcf36809cceb1a99e39038dacfcf884dfe563e66ff1
7
- data.tar.gz: 739bf6a49bb794ab5fcc46049178034782c28d9a27812c3106d0514142a84d03d72da4c6f48b699bde4445efc051b3672733490abb0c771bc8cc966dcdcafd3c
6
+ metadata.gz: 3ea47a1823b8e58ec45485a6293092d9c83daa0ba4a5f20bb0965cc9a507f0160ef71ab93c29e95c213ab023a568b1c1d162c1a1444adce390f0ec561ba198a7
7
+ data.tar.gz: 4d24495f1258df963a0e1cfb6643e9f20635b0ee46d8971e6c5caf228dfd6e7b63d03c29aafeada8824f2731d950ca1db17aae40355b6ab750a23372ce571fe4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.0 (21-Nov-23)
4
+
5
+ * Use HTTP PATCH instead of PUT according to the recent API changes
6
+ * Minor code improvements
7
+ * Test with Ruby 3.3
8
+
9
+ ## 1.5.0 (23-Aug-23)
10
+
11
+ * Fixed authorization header sending (thanks, @L-Eugene)
12
+ * Added proper support for compression and fixed processing
13
+
3
14
  ## 1.4.0 (09-Jun-23)
4
15
 
5
16
  * Renamed `narrators` method to `narrator` for `TournamentSynchRequests` (thanks, @L-Eugene)
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ![Gem](https://img.shields.io/gem/v/rating-chgk-v2)
4
4
  ![CI](https://github.com/bodrovis/rating-chgk-v2/actions/workflows/ci.yml/badge.svg)
5
+ [![Coverage Status](https://coveralls.io/repos/github/bodrovis/rating-chgk-v2/badge.svg?branch=master)](https://coveralls.io/github/bodrovis/rating-chgk-v2?branch=master)
6
+ ![Downloads total](https://img.shields.io/gem/dt/rating-chgk-v2)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7f66becb60a968a1ca9f/maintainability)](https://codeclimate.com/github/bodrovis/rating-chgk-v2/maintainability)
5
8
 
6
9
  Ruby client for [competitive "What? Where? When?" (aka "CHGK") API](http://api.rating.chgk.net/). This gem is a replacement for [ChgkRating](https://github.com/bodrovis/ChgkRating) which worked only with the deprecated API version.
7
10
 
@@ -7,6 +7,7 @@ module RatingChgkV2
7
7
  def connection(client)
8
8
  Faraday.new(options(client), request_params_for(client)) do |faraday|
9
9
  faraday.adapter Faraday.default_adapter
10
+ faraday.request :gzip
10
11
  end
11
12
  end
12
13
 
@@ -20,7 +21,7 @@ module RatingChgkV2
20
21
  accept_encoding: 'gzip,deflate,br'
21
22
  }
22
23
 
23
- headers = headers.merge({Authorization: "Bearer #{client.token}"}) if client.token
24
+ headers = headers.merge({Authorization: "Bearer #{client.token}"}) unless client.token.to_s.empty?
24
25
 
25
26
  {headers: headers, url: BASE_URL}
26
27
  end
@@ -7,6 +7,8 @@ module RatingChgkV2
7
7
 
8
8
  attr_reader :params
9
9
 
10
+ HTTP_METHODS = %i[get post put delete patch].freeze
11
+
10
12
  def initialize(client, query_params = [], params = {})
11
13
  @instance_query = base_query.push(*query_params)
12
14
  setup client, @instance_query, params
@@ -19,24 +21,16 @@ module RatingChgkV2
19
21
  self
20
22
  end
21
23
 
22
- private
23
-
24
- HTTP_METHODS_REGEXP = /\Ado_(get|post|put|delete)\z/.freeze
25
-
26
- def respond_to_missing?(method, _include_all)
27
- return true if HTTP_METHODS_REGEXP.match?(method.to_s)
28
-
29
- super
30
- end
31
-
32
- def method_missing(method, *_args)
33
- if method.to_s =~ HTTP_METHODS_REGEXP
34
- send Regexp.last_match(1), @uri, @client, @params
35
- else
36
- super
24
+ # Creates methods like `do_post`, `do_get` that proxy calls to the
25
+ # corresponding methods in the `Request` module
26
+ HTTP_METHODS.each do |method_postfix|
27
+ define_method "do_#{method_postfix}" do
28
+ send method_postfix, @uri, @client, @params
37
29
  end
38
30
  end
39
31
 
32
+ private
33
+
40
34
  def setup(client, query_params = [], params = {})
41
35
  @query_params = query_params
42
36
  @uri = partial_uri(@query_params)
@@ -26,6 +26,13 @@ module RatingChgkV2
26
26
  )
27
27
  end
28
28
 
29
+ def patch(path, client, params = {})
30
+ respond_with(
31
+ connection(client).patch(prepare(path), custom_dump(params)),
32
+ client
33
+ )
34
+ end
35
+
29
36
  def delete(path, client, _params = {})
30
37
  respond_with(
31
38
  connection(client).delete(prepare(path)),
@@ -16,7 +16,7 @@ module RatingChgkV2
16
16
  end
17
17
 
18
18
  def update_country(id, params)
19
- model_load name: 'Country', ep_name: 'Countries', ep_params: [id, params], method: :do_put
19
+ model_load name: 'Country', ep_name: 'Countries', ep_params: [id, params], method: :do_patch
20
20
  end
21
21
 
22
22
  def delete_country(id)
@@ -24,7 +24,7 @@ module RatingChgkV2
24
24
  end
25
25
 
26
26
  def update_player(id, params)
27
- model_load name: 'Player', ep_name: 'Players', ep_params: [id, params], method: :do_put
27
+ model_load name: 'Player', ep_name: 'Players', ep_params: [id, params], method: :do_patch
28
28
  end
29
29
 
30
30
  def delete_player(id)
@@ -16,7 +16,7 @@ module RatingChgkV2
16
16
  end
17
17
 
18
18
  def update_season(id, params)
19
- model_load name: 'Season', ep_name: 'Seasons', ep_params: [id, params], method: :do_put
19
+ model_load name: 'Season', ep_name: 'Seasons', ep_params: [id, params], method: :do_patch
20
20
  end
21
21
 
22
22
  def delete_season(id)
@@ -24,7 +24,7 @@ module RatingChgkV2
24
24
  end
25
25
 
26
26
  def update_team(id, params)
27
- model_load name: 'Team', ep_name: 'Teams', ep_params: [id, params], method: :do_put
27
+ model_load name: 'Team', ep_name: 'Teams', ep_params: [id, params], method: :do_patch
28
28
  end
29
29
 
30
30
  def delete_team(id)
@@ -16,7 +16,7 @@ module RatingChgkV2
16
16
  end
17
17
 
18
18
  def update_venue(id, params)
19
- model_load name: 'Venue', ep_name: 'Venues', ep_params: [id, params], method: :do_put
19
+ model_load name: 'Venue', ep_name: 'Venues', ep_params: [id, params], method: :do_patch
20
20
  end
21
21
 
22
22
  def delete_venue(id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RatingChgkV2
4
- VERSION = '1.4.0'
4
+ VERSION = '1.6.0'
5
5
  end
@@ -3,6 +3,7 @@
3
3
  require 'zeitwerk'
4
4
  require 'yaml'
5
5
  require 'faraday'
6
+ require 'faraday/gzip'
6
7
  require 'addressable/template'
7
8
  require 'forwardable'
8
9
 
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'addressable', '~> 2.5'
25
25
  spec.add_dependency 'faraday', '~> 2'
26
+ spec.add_dependency 'faraday-gzip', '~> 2.0'
26
27
  spec.add_dependency 'json', '~> 2'
27
28
  spec.add_dependency 'zeitwerk', '~> 2.4'
28
29
 
@@ -35,6 +36,7 @@ Gem::Specification.new do |spec|
35
36
  spec.add_development_dependency 'rubocop-rake', '~> 0.6'
36
37
  spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
37
38
  spec.add_development_dependency 'simplecov', '~> 0.22'
39
+ spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
38
40
  spec.add_development_dependency 'vcr', '~> 6.0'
39
41
  spec.add_development_dependency 'webmock', '~> 3.14'
40
42
  spec.metadata = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rating-chgk-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday-gzip
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: json
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,20 @@ dependencies:
192
206
  - - "~>"
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0.22'
209
+ - !ruby/object:Gem::Dependency
210
+ name: simplecov-lcov
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.8'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.8'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: vcr
197
225
  requirement: !ruby/object:Gem::Requirement
@@ -363,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
363
391
  - !ruby/object:Gem::Version
364
392
  version: '0'
365
393
  requirements: []
366
- rubygems_version: 3.4.13
394
+ rubygems_version: 3.4.22
367
395
  signing_key:
368
396
  specification_version: 4
369
397
  summary: Ruby interface for the new CHGK rating API