rating-chgk-v2 1.5.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: ef9700f05e3174c4138a2e4df640e21bf23b23d07f138ee5839867ad083f3f57
4
- data.tar.gz: 4381d5641a0bf6764015b7959f5b1eba2db60d56595a8ef14d546025e2b7e570
3
+ metadata.gz: 92553b2ca3c5258a683a08817cdc4ef276878afe738560cb2c553d902b8052b3
4
+ data.tar.gz: 033be3cb040a1833605d621441e07716f223e791a76dca4eeb1d0c3a849d8cc5
5
5
  SHA512:
6
- metadata.gz: 7f8b3a973ab3700bd3d333a69ae85924c511c424bc089546415950b3f740182652b619c59b1c71b962b3c25c091f0d5bf03bcfa04932d734b547250ffea9a9cf
7
- data.tar.gz: 4d6f49c85cedbd4dd100cef159b86228ae8f51ed78f1e1092a2070f9dedb082c7bdb6c4d26be7c170691d4e1de56b4c14119294696dde2a4dfa6f35a3d689ef0
6
+ metadata.gz: 3ea47a1823b8e58ec45485a6293092d9c83daa0ba4a5f20bb0965cc9a507f0160ef71ab93c29e95c213ab023a568b1c1d162c1a1444adce390f0ec561ba198a7
7
+ data.tar.gz: 4d24495f1258df963a0e1cfb6643e9f20635b0ee46d8971e6c5caf228dfd6e7b63d03c29aafeada8824f2731d950ca1db17aae40355b6ab750a23372ce571fe4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 1.5.0 (23-Aug-23)
4
10
 
5
11
  * Fixed authorization header sending (thanks, @L-Eugene)
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  ![CI](https://github.com/bodrovis/rating-chgk-v2/actions/workflows/ci.yml/badge.svg)
5
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
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)
7
8
 
8
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.
9
10
 
@@ -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.5.0'
4
+ VERSION = '1.6.0'
5
5
  end
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.5.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-08-23 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
@@ -391,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  - !ruby/object:Gem::Version
392
392
  version: '0'
393
393
  requirements: []
394
- rubygems_version: 3.4.18
394
+ rubygems_version: 3.4.22
395
395
  signing_key:
396
396
  specification_version: 4
397
397
  summary: Ruby interface for the new CHGK rating API