chgk_rating 1.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/Gemfile +3 -1
  4. data/LICENSE +1 -1
  5. data/README.md +10 -501
  6. data/Rakefile +4 -2
  7. data/chgk_rating.gemspec +23 -15
  8. data/lib/chgk_rating/attribute_mappings.rb +107 -80
  9. data/lib/chgk_rating/chgk_object.rb +6 -1
  10. data/lib/chgk_rating/client.rb +43 -10
  11. data/lib/chgk_rating/collections/base.rb +20 -15
  12. data/lib/chgk_rating/collections/players.rb +3 -1
  13. data/lib/chgk_rating/collections/ratings/player_ratings.rb +24 -0
  14. data/lib/chgk_rating/collections/{ratings.rb → ratings/team_ratings.rb} +5 -4
  15. data/lib/chgk_rating/collections/recaps.rb +4 -2
  16. data/lib/chgk_rating/collections/teams.rb +3 -1
  17. data/lib/chgk_rating/collections/tournaments/player_tournaments.rb +48 -0
  18. data/lib/chgk_rating/collections/{tournament_players.rb → tournaments/tournament_team_players.rb} +5 -3
  19. data/lib/chgk_rating/collections/{tournament_team_results.rb → tournaments/tournament_team_results.rb} +3 -1
  20. data/lib/chgk_rating/collections/{tournament_teams.rb → tournaments/tournament_teams.rb} +4 -1
  21. data/lib/chgk_rating/collections/{tournaments.rb → tournaments/tournaments.rb} +13 -8
  22. data/lib/chgk_rating/concerns/searching.rb +10 -9
  23. data/lib/chgk_rating/connection.rb +12 -7
  24. data/lib/chgk_rating/error.rb +7 -5
  25. data/lib/chgk_rating/models/base.rb +34 -15
  26. data/lib/chgk_rating/models/player.rb +28 -1
  27. data/lib/chgk_rating/models/rating/player_rating.rb +18 -0
  28. data/lib/chgk_rating/models/{tournament_player.rb → rating/rating.rb} +4 -2
  29. data/lib/chgk_rating/models/{rating.rb → rating/team_rating.rb} +4 -5
  30. data/lib/chgk_rating/models/recap.rb +3 -1
  31. data/lib/chgk_rating/models/team.rb +9 -7
  32. data/lib/chgk_rating/models/tournament/player_tournament.rb +10 -0
  33. data/lib/chgk_rating/models/{tournament.rb → tournament/tournament.rb} +7 -5
  34. data/lib/chgk_rating/models/{tournament_team.rb → tournament/tournament_team.rb} +6 -4
  35. data/lib/chgk_rating/models/tournament/tournament_team_player.rb +10 -0
  36. data/lib/chgk_rating/models/{tournament_team_result.rb → tournament/tournament_team_result.rb} +3 -1
  37. data/lib/chgk_rating/request.rb +10 -9
  38. data/lib/chgk_rating/utils/snakecase.rb +9 -7
  39. data/lib/chgk_rating/utils/transformations.rb +42 -35
  40. data/lib/chgk_rating/version.rb +4 -2
  41. data/lib/chgk_rating.rb +18 -11
  42. data/lib/ext/date.rb +6 -8
  43. data/lib/ext/date_time.rb +4 -2
  44. data/lib/ext/uri.rb +6 -6
  45. metadata +95 -90
  46. data/spec/lib/chgk_rating/client_spec.rb +0 -208
  47. data/spec/lib/chgk_rating/collections/players_spec.rb +0 -45
  48. data/spec/lib/chgk_rating/collections/ratings_spec.rb +0 -25
  49. data/spec/lib/chgk_rating/collections/recaps_spec.rb +0 -21
  50. data/spec/lib/chgk_rating/collections/teams_spec.rb +0 -42
  51. data/spec/lib/chgk_rating/collections/tournament_players_spec.rb +0 -18
  52. data/spec/lib/chgk_rating/collections/tournament_team_results_spec.rb +0 -17
  53. data/spec/lib/chgk_rating/collections/tournament_teams_spec.rb +0 -60
  54. data/spec/lib/chgk_rating/collections/tournaments_spec.rb +0 -62
  55. data/spec/lib/chgk_rating/models/base_spec.rb +0 -34
  56. data/spec/lib/chgk_rating/models/player_spec.rb +0 -35
  57. data/spec/lib/chgk_rating/models/rating_spec.rb +0 -27
  58. data/spec/lib/chgk_rating/models/recap_spec.rb +0 -35
  59. data/spec/lib/chgk_rating/models/team_spec.rb +0 -89
  60. data/spec/lib/chgk_rating/models/tournament_player_spec.rb +0 -21
  61. data/spec/lib/chgk_rating/models/tournament_spec.rb +0 -92
  62. data/spec/lib/chgk_rating/models/tournament_team_result_spec.rb +0 -19
  63. data/spec/lib/chgk_rating/models/tournament_team_spec.rb +0 -36
  64. data/spec/lib/chgk_rating/utils/snakecase_spec.rb +0 -12
  65. data/spec/lib/chgk_rating/utils/transformations_spec.rb +0 -16
  66. data/spec/lib/chgk_rating_spec.rb +0 -5
  67. data/spec/lib/ext/date_spec.rb +0 -7
  68. data/spec/lib/ext/date_time_spec.rb +0 -11
  69. data/spec/lib/ext/uri_spec.rb +0 -7
  70. data/spec/spec_helper.rb +0 -13
  71. data/spec/support/shared_examples.rb +0 -63
  72. data/spec/support/test_client.rb +0 -6
  73. data/spec/support/vcr.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1f40e4500f25b4c4fa174235cdfb13a5d5262800d7128ab412f50e85efcb2e3
4
- data.tar.gz: 65054a1c6ec251becfbc8a5fb73a221aa36ff2841c097d921464eeebc942b11b
3
+ metadata.gz: 61be2615dc148c3adab710b6a3d2fb2e2209ffff2414972101b94d3ba35ebbfe
4
+ data.tar.gz: d26da02ff2a2886e0c253106c6f1096bb1572d2db8a4d5476acb149f70d18653
5
5
  SHA512:
6
- metadata.gz: f045d2354e6f6f35cf1486611bbe3954bf5e400914c71fa7c1a47154542aa197cf9b61a0dba0334840f318b1d02a890dc426f7a09bd444ab1715ab2e9c2f61c8
7
- data.tar.gz: c93f31ee95abe8900dce72730fda98a18f09737fa4b29026df0d6d077d8e1692b60c3302109c06c6d35a33db1c1e17380cc9746a0cf5fa31cafce419b040c888
6
+ metadata.gz: ea945aa9897881ecea27085dc0a224d33a2a0fb029a5624e7069a4831571bae5672effc2800b5d92e53e7d89f8b6856a5e925bf5a075843b1fcbe7e1c5b8532d
7
+ data.tar.gz: 52d3b312ebe06c301836562afa298de73f1a4682bd7d03057043f3883c08d23d2ece2725f2e0174291c69db0df9445c962260af255b64568c8c74c1b321ee418
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.2.0 (2022-07-07)
4
+
5
+ * **Drop support for Ruby 2.4 and 2.5 (EOL)**
6
+ * Switched to Faraday v2 (thanks, @L-Eugene)
7
+ * Fixed various minor issues
8
+ * Switched to GH Actions
9
+ * Use Rubocop
10
+ * Update test matrix
11
+
12
+ ## v2.1.0 (2021-12-29)
13
+
14
+ * Updated API mappings (thanks, @L-Eugene)
15
+
16
+ ## v2.0.0 (2021-12-28)
17
+
18
+ Breaking changes:
19
+
20
+ * `client.rating` is now `client.team_rating`
21
+ * `client.ratings` is now `client.team_ratings`
22
+ * `tournament.team` is now `tournament.team_by`
23
+
24
+ New features:
25
+
26
+ * Faraday now follows redirects (thanks, @L-Eugene)
27
+ * Added ability to fetch ratings for players using `#player_rating` and `#player_ratings`
28
+ * `Player` now also responds to `#rating`, `#ratings`, `#tournaments` methods
29
+ * Added ability to fetch tournaments for a player. `#tournaments` now also accepts `player_or_id`.
30
+
31
+ Testing:
32
+
33
+ * Tested against more recent Ruby versions
34
+
3
35
  ## v1.0.0 (2018-02-23)
4
36
 
5
37
  * First stable version at last
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
- gemspec
5
+ gemspec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2017 Ilya Bodrov
3
+ Copyright (c) 2022 Ilya Krukowski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,32 +1,20 @@
1
1
  # ChgkRating
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/chgk_rating.svg)](https://badge.fury.io/rb/chgk_rating)
4
- [![Build Status](https://travis-ci.org/bodrovis/ChgkRating.svg?branch=master)](https://travis-ci.org/bodrovis/ChgkRating)
5
- [![Code Climate](https://codeclimate.com/github/bodrovis/ChgkRating/badges/gpa.svg)](https://codeclimate.com/github/bodrovis/ChgkRating)
6
- [![Test Coverage](https://codeclimate.com/github/bodrovis/ChgkRating/badges/coverage.svg)](https://codeclimate.com/github/bodrovis/ChgkRating/coverage)
7
- [![Dependency Status](https://gemnasium.com/bodrovis/ChgkRating.svg)](https://gemnasium.com/bodrovis/ChgkRating)
4
+ ![CI](https://github.com/bodrovis/ChgkRating/actions/workflows/ci.yml/badge.svg)
5
+ [![Test Coverage](https://codecov.io/gh/bodrovis/ChgkRating/graph/badge.svg)](https://codecov.io/gh/bodrovis/ChgkRating)
6
+
7
+ **This gem is in passive maintenance mode. I won't release any new features or introduce any complex enhancements as ChgkRating v1 is deprecated. Please use [rating-chgk-v2 gem](https://github.com/bodrovis/rating-chgk-v2) which works with the new version of the API.**
8
8
 
9
9
  Ruby interface for the [rating.chgk.info](http://rating.chgk.info/index.php/api) WebAPI. This is not just a wrapper, but rather a quite complex opinionated client that allows to easily work with various API resources.
10
10
 
11
11
  [Competitive CHGK (aka "What? Where? When?")](https://en.wikipedia.org/wiki/What%3F_Where%3F_When%3F#Competitive_game) is a popular intellectual game where teams of up to six people are trying to find an answers to various questions.
12
12
 
13
- ## Contents
13
+ The main documentation can be found at the [official website](http://chgk-rating.bodrovis.tech/).
14
+
15
+ Документация на русском языке также доступна на [официальном сайте](http://chgk-rating.bodrovis.tech/index_ru).
14
16
 
15
- * [Installation and Requirements](#installation-and-requirements)
16
- * [Usage](#usage)
17
- + [A Very Quick Example](#a-very-quick-example)
18
- + [Before You Start](#before-you-start)
19
- + [Initializing the Client](#initializing-the-client)
20
- + [Players](#players)
21
- + [Teams](#teams)
22
- + [Recap (Team's Roster)](#recap-teams-roster)
23
- + [Team Ratings](#team-ratings)
24
- + [Tournaments](#tournaments)
25
- + [Teams at Tournament](#teams-at-tournament)
26
- + [Team Results at Tournament](#team-results-at-tournament)
27
- + [Team Players at Tournament](#team-players-at-tournament)
28
- * [Testing](#testing)
29
- * [License](#license)
17
+ Documentation can also be found on [RubyDoc](http://www.rubydoc.info/github/bodrovis/ChgkRating/master).
30
18
 
31
19
  ## Installation and Requirements
32
20
 
@@ -36,11 +24,7 @@ Install it by running:
36
24
 
37
25
  $ gem install chgk_rating
38
26
 
39
- ## Usage
40
-
41
- Remember that ChgkRating API is **read-only**.
42
-
43
- ### A Very Quick Example
27
+ ## A Very Quick Example
44
28
 
45
29
  ```ruby
46
30
  # Instantiate the client:
@@ -69,481 +53,6 @@ team.at_tournament(tournament).results
69
53
  client.team_results_at_tournament tournament, team
70
54
  ```
71
55
 
72
- ### Before You Start
73
-
74
- As long as this gem is not just a wrapper, there are a bunch of things that you might want to know before starting to use it. This information, however, is optional and if you just want to quickly fetch some info about a specific resource, ignore it.
75
-
76
- * [Types of resources](https://github.com/bodrovis/ChgkRating/wiki/Types-of-resources) - explains what are models and collections are in terms of this gem and how to convert resources back to their raw form
77
- * [Pagination](https://github.com/bodrovis/ChgkRating/wiki/Pagination)
78
- * [Lazy and eager loading](https://github.com/bodrovis/ChgkRating/wiki/Lazy-and-eager-loading) - explains why you might not see full information about some resource and how to forcibly load it
79
-
80
- ### Initializing the Client
81
-
82
- Initialize the client with the following shortcut:
83
-
84
- ```ruby
85
- client = ChgkRating.client
86
- ```
87
-
88
- This method does not accept any arguments because the client requires no configuration. You don't need any API keys, access tokens and that stuff - just go ahead and send any queries you like. Seems like the API has no quota limitation as well but of course it does not mean you should abuse it.
89
-
90
- Now you may utilize the `client` local variable to perform various requests described below.
91
-
92
- ### Players
93
-
94
- #### Players - Collection
95
-
96
- Returns an array-like `Players` object containing list of `Player` models sorted by their IDs:
97
-
98
- ```ruby
99
- client.players params={} # Input:
100
- # (optional) params - Hash
101
- ## Supported params:
102
- ## :page - Integer or String. The requested page. Default is 1, and there are 1000 results per page.
103
- ## :lazy - Boolean. Should the Player models be marked as lazily loaded? Note that the models will still contain all the information returned by the API.
104
- ## :collection - Enumerable. An array or collection of Players that will be used to build a new collection. If this option is provided, API request will not be sent. This param is mostly used for internal purposes, but you may take advantage of it as well.
105
- ```
106
-
107
- Note that the information returned for each `Player` is a bit limited: specifically, `db_chgk_info_tag` and `comment` attributes are `nil` (actually, most players have no value for these attributes anyways). However, you are free to forcibly eager load one or more players:
108
-
109
- ```ruby
110
- players = client.players.take(3)
111
- players.map! {|p| p.eager_load! true}
112
- ```
113
-
114
- #### Player - Model
115
-
116
- Returns information about a single `Player`:
117
-
118
- ```ruby
119
- client.player id, lazy=false # Input:
120
- # id - Integer or String, player's id
121
- # (optional) lazy - Boolean
122
- ```
123
-
124
- Getter methods:
125
-
126
- ```ruby
127
- id # String
128
- name # String
129
- surname # String
130
- patronymic # String
131
- comment # String
132
- db_chgk_info_tag # String
133
- ```
134
-
135
- Special notes:
136
-
137
- * Can be lazily-loaded and eager-loaded.
138
-
139
- #### Players - Search
140
-
141
- Search for players by a given criteria:
142
-
143
- ```ruby
144
- client.search_players params # Input:
145
- # params - Hash
146
- ## Supported search params:
147
- ## :name - String
148
- ## :surname - String
149
- ## :patronymic - String
150
- ## :page - String or Integer. Default is 1, and there are 1000 results per page.
151
- ```
152
-
153
- Returns an array-like `Players::Search` collection consisting of `Player` models.
154
-
155
- ### Teams
156
-
157
- #### Teams - Collection
158
-
159
- Get a list of all teams sorted by their IDs:
160
-
161
- ```ruby
162
- client.teams params={} # Input:
163
- # (optional) params - Hash
164
- ## Supported params:
165
- ## :page - Integer or String. The requested page. Default is 1, and there are 1000 results per page.
166
- ## :lazy - Boolean. Should the Team models be marked as lazily loaded? Note that the models will still contain all the information returned by the API.
167
- ## :collection - Enumerable. An array or collection of Teams that will be used to build a new collection. If this option is provided, API request will not be sent. This param is mostly used for internal purposes, but you may take advantage of it as well.
168
- ```
169
-
170
- Returns an array-like `Teams` object. A bit limited set of information is returned for each `Team` model: specifically, a `comment` attribute is set to `nil`.
171
-
172
- #### Team - Model
173
-
174
- Get full information about a single `Team`:
175
-
176
- ```ruby
177
- client.team id, lazy=false # Input:
178
- # id - Integer or String. Team's id
179
- # (optional) lazy - Boolean
180
- ```
181
-
182
- Getter methods:
183
-
184
- ```ruby
185
- id # String
186
- name # String
187
- town # String
188
- comment # String
189
- ```
190
-
191
- Special notes:
192
-
193
- * Can be lazily-loaded and eager-loaded.
194
-
195
- ##### Interface Methods
196
-
197
- `Team` model respond to the following convenience methods:
198
-
199
- ```ruby
200
- team.recap(season_id) # Returns a single Recap for the current Team at a given season. Input:
201
- # season_id - Integer or String
202
-
203
- team.at_tournament(tournament_or_id) # Returns TournamentTeam model that contains information about the
204
- # team's results at the given tournament. Input:
205
- # tournament_or_id - String, Integer or Tournament
206
-
207
- team.rating(release_id) # Returns Rating for the current Team in a given release. Input:
208
- # release_id - String or Integer
209
-
210
- team.ratings # Returns an array-like Ratings collection for the current team.
211
-
212
- team.recaps # Returns an hash-like Recaps collection for the current team, grouped by seasons. Seasons act
213
- # as keys, whereas Recap models - as values.
214
-
215
- team.tournaments(season_id: nil, params: {}) # Returns a collection of Tournaments that the current team participated at
216
- # based on the given criteria. Input:
217
- # (optional) season_id - Integer or String
218
- # (optional) params - Hash
219
- ## Supported params:
220
- ## :page - String or Integer. Default is 1
221
- ```
222
-
223
- #### Teams - Search
224
-
225
- Search for teams by a given criteria:
226
-
227
- ```ruby
228
- client.search_teams params # Input:
229
- # params - Hash
230
- ## Supported search params:
231
- ## :name - String
232
- ## :town - String
233
- ## :page - String or Integer. Default is 1, and there are 1000 results per page.
234
- ```
235
-
236
- Returns `Teams::Search` collection consisting of `Team` models.
237
-
238
- ### Recap (Team's Roster)
239
-
240
- The term "recap" is used by the ChgkRating API but I do not think it is suitable. Basically, it means "team's roster", "team list", or "team's lineup".
241
-
242
- #### Recaps - Collection
243
-
244
- Get recaps grouped by seasons for a single team:
245
-
246
- ```ruby
247
- client.recaps team_or_id # Input:
248
- # team_or_id - String, Integer or Team. Team to load recaps for.
249
- ```
250
-
251
- Returns a hash-like `Recaps` object with the season numbers as the keys and the `Recap` model as values.
252
- If the team has not participated in a season, it is **not** included in the response.
253
-
254
- The `Recaps` collection responds to the following methods:
255
-
256
- ```ruby
257
- team # Team - lazily-loaded Team model
258
- ```
259
-
260
- #### Recap - Model
261
-
262
- Get information about a team's recap in a given season:
263
-
264
- ```ruby
265
- client.recap team_id, season_id # Input:
266
- # team_or_id - String, Integer or Team
267
- # season_id - Integer or String
268
- ```
269
-
270
- Returns a `Recap` model that has the following getters:
271
-
272
- ```ruby
273
- team # Team - lazily-loaded model
274
- season_id # String
275
- players # Players collection consisting of lazily-loaded Player models
276
- captain # Player model, lazily-loaded
277
- ```
278
-
279
- ### Team Ratings
280
-
281
- #### Team Ratings - Collection
282
-
283
- Get all ratings for a single team:
284
-
285
- ```ruby
286
- client.ratings team_or_id # Input:
287
- # team_or_id - String, Integer or Team. Team to load ratings for.
288
- ```
289
-
290
- Returns an array-like `Ratings` collection containing `Rating` models.
291
-
292
- Collection responds to the following methods:
293
-
294
- ```ruby
295
- team # Team - lazily-loaded model
296
- ```
297
-
298
- #### Team Rating - Model
299
-
300
- Get `Rating` for a team in a given release:
301
-
302
- ```ruby
303
- client.rating team_or_id, release_id # Input:
304
- # team_or_id - String, Integer or Team
305
- # release_id - String or Integer
306
- ```
307
-
308
- Getters:
309
-
310
- ```ruby
311
- team # Team - lazily-loaded model
312
- release_id # String
313
- rating # Integer
314
- rating_position # Integer
315
- date # Date
316
- formula # Symbol - :a or :b
317
- ```
318
-
319
- ### Tournaments
320
-
321
- #### Tournaments - Collection
322
-
323
- ```ruby
324
- client.tournaments team_or_id: nil, season_id: nil, params: {} # Input (arguments are passed in a hash-like format):
325
- # (optional) team_or_id - String, Integer or Team
326
- # (optional) season_id - String or Integer
327
- # (optional) params - Hash
328
- ## Supported params:
329
- ## :page - String or Integer. Default is 1
330
- ```
331
-
332
- **When both `team_or_id` and `season_id` are not set**, returns an array-like `Tournaments` collection with all the tournaments. In this case `Tournament` models have only the following attributes set:
333
-
334
- ```ruby
335
- id # String
336
- name # String
337
- date_start # Date
338
- date_end # Date
339
- type_name # String
340
- ```
341
-
342
- **When only `team_or_id` is set**, returns a hash-like `Tournaments` collection. This collection has season numbers as keys and array of `Tournament` models as values. `Tournament` models are lazily-loaded and have only `id` attribute set.
343
-
344
- **When both `team` and `season_id` are set**, returns an array-like `Tournaments` collection with lazily-loaded `Tournament` models that have only `id` attribute set.
345
-
346
- The collection responds to the following methods:
347
-
348
- ```ruby
349
- team # Nil or lazily-loaded Team
350
- season_id # Nil or String
351
- ```
352
-
353
- #### Tournament - Model
354
-
355
- Get information about a single tournament:
356
-
357
- ```ruby
358
- client.tournament id, lazy=false # Input:
359
- # id - Integer or String
360
- # (optional) lazy - Boolean
361
- ```
362
-
363
- `Tournament` has the following getters:
364
-
365
- ```ruby
366
- id # String
367
- name # String
368
- date_start # DateTime
369
- date_end # DateTime
370
- type_name # String
371
- town # String
372
- long_name # String
373
- tour_count # Integer
374
- tour_questions # Integer
375
- tour_ques_per_tour # Integer
376
- questions_total # Integer
377
- type_name # String
378
- main_payment_value # Float
379
- discounted_payment_value # Float
380
- discounted_payment_reason # String
381
- date_requests_allowed_to # DateTime
382
- comment # String
383
- site_url # URI
384
- ```
385
-
386
- Special notes:
387
-
388
- * Lazy-loading and eager-loading is supported.
389
-
390
- ##### Interface Methods
391
-
392
- `Tournament` model respond to the following convenience methods:
393
-
394
- ```ruby
395
- tournament.team_players(team_or_id) # Returns an array-like TournamentPlayers collection containing roster
396
- # for a team at the current tournament. Input:
397
- # team_or_id - String, Integer or Team
398
-
399
- tournament.team_results(team_or_id) # Returns an array-like TournamentTeamResults collection with results
400
- # for a given team in the current tournament. Input:
401
- # team_or_id - String, Integer or Team
402
-
403
- tournament.team_list # Returns an array-like TournamentTeams collection specifying which
404
- # teams participated in the current tournament
405
-
406
- tournament.team(team_or_id) # Returns information about a single TournamentTeam in the current tournament
407
- # team_or_id - String, Integer or Team
408
- ```
409
-
410
- ### Teams at Tournament
411
-
412
- #### Teams at Tournament - Collection
413
-
414
- Get a list of all teams which participated in a given tournament:
415
-
416
- ```ruby
417
- client.teams_at_tournament tournament_or_id # Input:
418
- # tournament_id - Integer, String or Tournament
419
- ```
420
-
421
- Returns an array-like `TournamentTeams` collection that responds to the following methods:
422
-
423
- ```ruby
424
- tournament # Tournament. Lazily-loaded model
425
- ```
426
-
427
- #### Team at Tournament - Model
428
-
429
- Instantiate a `TournamentTeam` model:
430
-
431
- ```ruby
432
- client.team_at_tournament tournament_or_id, team_or_id # Input:
433
- # tournament_or_id - Integer, String or Tournament
434
- # team_or_id - Integer, String or Team
435
- ```
436
-
437
- Note that this method **always** returns a lazily-loaded model that cannot be eager-loaded later. This is
438
- because the API does not allow to fetch information for a single tournament team. Therefore only the following
439
- attributes are set:
440
-
441
- ```ruby
442
- id # String
443
- tournament # Tournament. Lazily-loaded model
444
- ```
445
-
446
- This `TournamentTeam` object, however, can be used to perform interface methods listed below.
447
-
448
- `TournamentTeam` models loaded with the `teams_at_tournament` method (see above) have the following attributes:
449
-
450
- ```ruby
451
- id # String
452
- current_name # String
453
- base_name # String
454
- position # Float
455
- questions_total # Integer
456
- result # Array - contains Boolean values. Each value corresponds to a single question and
457
- # marks whether the team answered this question or not. The length of the array equals to the
458
- # value returned by the questions_total method
459
- bonus_a # Integer
460
- bonus_b # Integer
461
- tech_rating # Integer
462
- predicted_position # Integer
463
- real_bonus_b # Integer
464
- d_bonus_b # Integer
465
- included_in_rating # Boolean
466
- ```
467
-
468
- ##### Interface Methods
469
-
470
- `TournamentTeam` model respond to the following convenience methods:
471
-
472
- ```ruby
473
- tournament_team.players # Returns an array-like TournamentPlayers collection containing roster for the current TournamentTeam
474
-
475
- tournament_team.results # Returns an array-like TournamentTeamResults collection containing results for the current TournamentTeam
476
- ```
477
-
478
- ### Team Results at Tournament
479
-
480
- #### Team Results at Tournament - Collection
481
-
482
- Get team results at a given tournament:
483
-
484
- ```ruby
485
- client.team_results_at_tournament tournament_or_id, team_or_id # Input:
486
- # tournament_or_id - Integer, String or Tournament
487
- # team_or_id - Integer, String or Team
488
- ```
489
-
490
- Returns an array-like `TournamentTeamResults` collection with `TournamentTeamResult` models. Each model contains results for a single tour.
491
-
492
- The collection responds to the following methods:
493
-
494
- ```ruby
495
- team # Team. Lazily-loaded model
496
- tournament # Tournament. Lazily-loaded model
497
- ```
498
-
499
- #### Team Result at Tournament - Model
500
-
501
- API does not allow to load team result for a given tour separately, so use the `team_results_at_tournament` method listed above.
502
-
503
- `TournamentTeamResult` model has the following getters:
504
-
505
- ```ruby
506
- tour # Integer
507
- result # Array containing Boolean values. Each value corresponds to a single question and
508
- # says whether the team answered the question or not
509
- ```
510
-
511
- ### Team Players at Tournament
512
-
513
- #### Team Players at Tournament - Collection
514
-
515
- Get information about the team's roster at the given tournament:
516
-
517
- ```ruby
518
- client.team_players_at_tournament tournament_or_id, team_or_id # Input:
519
- # tournament_or_id - Integer, String or Tournament
520
- # team_or_id - Integer, String or Team
521
- ```
522
-
523
- Returns an array-like `TournamentPlayers` collection containing `TournamentPlayer` models (each model represents one player).
524
-
525
- The collection responds to the following getters:
526
-
527
- ```ruby
528
- id # String
529
- tournament # Tournament. Lazily-loaded model
530
- ```
531
-
532
- #### Team Players at Tournament - Model
533
-
534
- It is not possible to load information about a specific player at the given tournament, so use the `team_players_at_tournament` method listed above.
535
-
536
- Note that `TournamentPlayer` **is a different model** which is not equal to the `Player` model. It has, however, the same id, so you may easily find the corresponding `Player` layer.
537
-
538
- `TournamentPlayer` has the following getters:
539
-
540
- ```ruby
541
- id # String
542
- is_captain # Boolean
543
- is_base # Boolean
544
- is_foreign # Boolean
545
- ```
546
-
547
56
  ## Testing
548
57
 
549
58
  Tests run against mock responses so you don't need to perform any special setup. Simply pull the code and run:
@@ -555,4 +64,4 @@ Tests run against mock responses so you don't need to perform any special setup.
555
64
 
556
65
  This plugin is licensed under the [MIT License](https://github.com/bodrovis/ChgkRating/blob/master/LICENSE).
557
66
 
558
- Copyright (c) 2017 [Ilya Bodrov](http://bodrovis.tech)
67
+ Copyright (c) [Ilya Krukowski](http://bodrovis.tech)
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake'
2
4
 
3
5
  begin
@@ -7,7 +9,7 @@ rescue LoadError
7
9
  puts 'although not required, bundler is recommened for running the tests'
8
10
  end
9
11
 
10
- task :default => :spec
12
+ task default: :spec
11
13
 
12
14
  require 'rspec/core/rake_task'
13
- RSpec::Core::RakeTask.new(:spec)
15
+ RSpec::Core::RakeTask.new(:spec)
data/chgk_rating.gemspec CHANGED
@@ -1,29 +1,37 @@
1
- require File.expand_path('../lib/chgk_rating/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/chgk_rating/version', __dir__)
2
4
 
3
5
  Gem::Specification.new do |spec|
4
6
  spec.name = 'chgk_rating'
5
7
  spec.version = ChgkRating::VERSION
6
- spec.authors = ['Ilya Bodrov']
8
+ spec.authors = ['Ilya Krukowski']
7
9
  spec.email = ['golosizpru@gmail.com']
8
10
  spec.summary = 'Ruby interface to the competitive What? Where? When? rating API'
9
- spec.description = 'Opinionated Ruby client for the competitive What? Where? When? rating WebAPI (rating.chgk.info) that allows to work with data as with Ruby objects'
10
- spec.homepage = 'https://github.com/bodrovis/ChgkRating'
11
+ spec.description = 'Opinionated Ruby client for the competitive What? Where? When? ' \
12
+ 'rating WebAPI (rating.chgk.info) that ' \
13
+ 'allows to work with data as with Ruby objects'
14
+ spec.homepage = 'http://chgk-rating.bodrovis.tech/'
11
15
  spec.license = 'MIT'
12
16
  spec.platform = Gem::Platform::RUBY
13
- spec.required_ruby_version = '>= 2.4.0'
17
+ spec.required_ruby_version = '>= 2.6.0'
14
18
 
15
- spec.files = Dir["README.md", "LICENSE", "CONTRIBUTING.md",
16
- "CHANGELOG.md", "lib/**/*.rb", "chgk_rating.gemspec", ".github/*.md",
17
- "Gemfile", "Rakefile"]
18
- spec.test_files = Dir["spec/**/*.rb"]
19
+ spec.files = Dir['README.md', 'LICENSE', 'CONTRIBUTING.md',
20
+ 'CHANGELOG.md', 'lib/**/*.rb', 'chgk_rating.gemspec', '.github/*.md',
21
+ 'Gemfile', 'Rakefile']
19
22
  spec.extra_rdoc_files = ['README.md']
20
23
  spec.require_paths = ['lib']
21
24
 
22
- spec.add_dependency 'faraday', '~> 0.13'
23
- spec.add_dependency 'multi_json', '~> 1.12'
25
+ spec.add_dependency 'faraday', '~> 2.0'
26
+ spec.add_dependency 'faraday-follow_redirects', '~> 0.3'
27
+ spec.add_dependency 'multi_json', '~> 1.15'
24
28
 
25
- spec.add_development_dependency 'rake', '~> 12.1'
29
+ spec.add_development_dependency 'codecov', '~> 0.1'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
26
31
  spec.add_development_dependency 'rspec', '~> 3.6'
27
- spec.add_development_dependency 'vcr', '~> 4.0'
28
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
29
- end
32
+ spec.add_development_dependency 'rubocop', '~> 1.31'
33
+ spec.add_development_dependency 'rubocop-performance', '~> 1.5'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.11'
35
+ spec.add_development_dependency 'vcr', '~> 6.0'
36
+ spec.metadata['rubygems_mfa_required'] = 'true'
37
+ end