chgk_rating 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +8 -499
  4. data/chgk_rating.gemspec +7 -6
  5. data/lib/chgk_rating/attribute_mappings.rb +20 -4
  6. data/lib/chgk_rating/chgk_object.rb +1 -0
  7. data/lib/chgk_rating/client.rb +40 -9
  8. data/lib/chgk_rating/collections/ratings/player_ratings.rb +22 -0
  9. data/lib/chgk_rating/collections/{ratings.rb → ratings/team_ratings.rb} +2 -3
  10. data/lib/chgk_rating/collections/tournaments/player_tournaments.rb +44 -0
  11. data/lib/chgk_rating/collections/{tournament_players.rb → tournaments/tournament_team_players.rb} +2 -2
  12. data/lib/chgk_rating/collections/{tournament_team_results.rb → tournaments/tournament_team_results.rb} +0 -0
  13. data/lib/chgk_rating/collections/{tournament_teams.rb → tournaments/tournament_teams.rb} +0 -0
  14. data/lib/chgk_rating/collections/{tournaments.rb → tournaments/tournaments.rb} +2 -1
  15. data/lib/chgk_rating/connection.rb +4 -1
  16. data/lib/chgk_rating/models/base.rb +17 -5
  17. data/lib/chgk_rating/models/player.rb +25 -0
  18. data/lib/chgk_rating/models/rating/player_rating.rb +16 -0
  19. data/lib/chgk_rating/models/{tournament_player.rb → rating/rating.rb} +1 -1
  20. data/lib/chgk_rating/models/{rating.rb → rating/team_rating.rb} +1 -4
  21. data/lib/chgk_rating/models/team.rb +6 -6
  22. data/lib/chgk_rating/models/tournament/player_tournament.rb +8 -0
  23. data/lib/chgk_rating/models/{tournament.rb → tournament/tournament.rb} +4 -4
  24. data/lib/chgk_rating/models/{tournament_team.rb → tournament/tournament_team.rb} +3 -3
  25. data/lib/chgk_rating/models/tournament/tournament_team_player.rb +8 -0
  26. data/lib/chgk_rating/models/{tournament_team_result.rb → tournament/tournament_team_result.rb} +0 -0
  27. data/lib/chgk_rating/utils/transformations.rb +1 -0
  28. data/lib/chgk_rating/version.rb +1 -1
  29. data/lib/chgk_rating.rb +15 -10
  30. data/spec/lib/chgk_rating/client_spec.rb +46 -7
  31. data/spec/lib/chgk_rating/collections/player_ratings_spec.rb +15 -0
  32. data/spec/lib/chgk_rating/collections/{ratings_spec.rb → team_ratings_spec.rb} +1 -1
  33. data/spec/lib/chgk_rating/collections/tournaments/player_tournaments_spec.rb +38 -0
  34. data/spec/lib/chgk_rating/collections/{tournament_players_spec.rb → tournaments/tournament_team_players_spec.rb} +1 -1
  35. data/spec/lib/chgk_rating/collections/{tournament_team_results_spec.rb → tournaments/tournament_team_results_spec.rb} +0 -0
  36. data/spec/lib/chgk_rating/collections/{tournament_teams_spec.rb → tournaments/tournament_teams_spec.rb} +0 -0
  37. data/spec/lib/chgk_rating/collections/{tournaments_spec.rb → tournaments/tournaments_spec.rb} +0 -0
  38. data/spec/lib/chgk_rating/models/player_rating_spec.rb +22 -0
  39. data/spec/lib/chgk_rating/models/player_spec.rb +27 -0
  40. data/spec/lib/chgk_rating/models/{rating_spec.rb → team_rating_spec.rb} +1 -1
  41. data/spec/lib/chgk_rating/models/team_spec.rb +2 -2
  42. data/spec/lib/chgk_rating/models/{tournament_spec.rb → tournament/tournament_spec.rb} +3 -3
  43. data/spec/lib/chgk_rating/models/{tournament_player_spec.rb → tournament/tournament_team_player_spec.rb} +1 -1
  44. data/spec/lib/chgk_rating/models/{tournament_team_result_spec.rb → tournament/tournament_team_result_spec.rb} +0 -0
  45. data/spec/lib/chgk_rating/models/{tournament_team_spec.rb → tournament/tournament_team_spec.rb} +1 -1
  46. data/spec/spec_helper.rb +2 -0
  47. metadata +70 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1f40e4500f25b4c4fa174235cdfb13a5d5262800d7128ab412f50e85efcb2e3
4
- data.tar.gz: 65054a1c6ec251becfbc8a5fb73a221aa36ff2841c097d921464eeebc942b11b
3
+ metadata.gz: e4f4ca06ab6d5493cf307d4d0c69a9286d6306e821ee186a1efa5f59ee90e6ac
4
+ data.tar.gz: fe44eff613828362a3bd6e1347d1bffcb3eddaf9ec6b2ab74974271526e3c29e
5
5
  SHA512:
6
- metadata.gz: f045d2354e6f6f35cf1486611bbe3954bf5e400914c71fa7c1a47154542aa197cf9b61a0dba0334840f318b1d02a890dc426f7a09bd444ab1715ab2e9c2f61c8
7
- data.tar.gz: c93f31ee95abe8900dce72730fda98a18f09737fa4b29026df0d6d077d8e1692b60c3302109c06c6d35a33db1c1e17380cc9746a0cf5fa31cafce419b040c888
6
+ metadata.gz: bf3d999776bcf5f32a2f2f763c7d04b47a4ee32738b526da7de9b54c0d8a79ddddc7d499dc0d251c3d7d02be9ce2e87b08afcef61c9e94788f25ac3d498d7012
7
+ data.tar.gz: fef80b06f8457b2ce82a58a5fb8b183d5bab8c88c53e0c6de80462bba6822157ec53b19283f27c8d67f2e2fbabec8f6fcb47567c9e59e375861cdefccdaadaca
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.0.0 (2021-12-28)
4
+
5
+ Breaking changes:
6
+
7
+ * `client.rating` is now `client.team_rating`
8
+ * `client.ratings` is now `client.team_ratings`
9
+ * `tournament.team` is now `tournament.team_by`
10
+
11
+ New features:
12
+
13
+ * Faraday now follows redirects (thanks, @L-Eugene)
14
+ * Added ability to fetch ratings for players using `#player_rating` and `#player_ratings`
15
+ * `Player` now also responds to `#rating`, `#ratings`, `#tournaments` methods
16
+ * Added ability to fetch tournaments for a player. `#tournaments` now also accepts `player_or_id`.
17
+
18
+ Testing:
19
+
20
+ * Tested against more recent Ruby versions
21
+
3
22
  ## v1.0.0 (2018-02-23)
4
23
 
5
24
  * First stable version at last
data/README.md CHANGED
@@ -3,30 +3,18 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/chgk_rating.svg)](https://badge.fury.io/rb/chgk_rating)
4
4
  [![Build Status](https://travis-ci.org/bodrovis/ChgkRating.svg?branch=master)](https://travis-ci.org/bodrovis/ChgkRating)
5
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)
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.**
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 Bodrov](http://bodrovis.tech)
data/chgk_rating.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.email = ['golosizpru@gmail.com']
8
8
  spec.summary = 'Ruby interface to the competitive What? Where? When? rating API'
9
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'
10
+ spec.homepage = 'http://chgk-rating.bodrovis.tech/'
11
11
  spec.license = 'MIT'
12
12
  spec.platform = Gem::Platform::RUBY
13
13
  spec.required_ruby_version = '>= 2.4.0'
@@ -19,11 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.extra_rdoc_files = ['README.md']
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'faraday', '~> 0.13'
23
- spec.add_dependency 'multi_json', '~> 1.12'
22
+ spec.add_dependency 'faraday', '~> 1.8'
23
+ spec.add_dependency 'faraday_middleware', '~> 1.2'
24
+ spec.add_dependency 'multi_json', '~> 1.15'
24
25
 
25
- spec.add_development_dependency 'rake', '~> 12.1'
26
+ spec.add_development_dependency 'rake', '~> 13.0'
26
27
  spec.add_development_dependency 'rspec', '~> 3.6'
27
- spec.add_development_dependency 'vcr', '~> 4.0'
28
+ spec.add_development_dependency 'vcr', '~> 6.0'
28
29
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
29
- end
30
+ end
@@ -4,7 +4,11 @@ module ChgkRating
4
4
 
5
5
  class << self
6
6
  def find(name)
7
- const_get name.snakecase_upcase
7
+ begin
8
+ const_get name.snakecase_upcase
9
+ rescue NameError
10
+ {}
11
+ end
8
12
  end
9
13
 
10
14
  def generate_mappings_for(data)
@@ -66,11 +70,18 @@ module ChgkRating
66
70
  :db_chgk_info_tag
67
71
  ],
68
72
  RATING: {
69
- team: ['idteam', :team_id],
70
73
  release_id: 'idrelease',
71
74
  rating: [],
72
75
  rating_position: [],
73
- date: ['date', :date],
76
+ date: ['date', :date]
77
+ },
78
+ PLAYER_RATING: {
79
+ player: ['idplayer', :player_id],
80
+ tournaments_in_year: [],
81
+ tournament_count_total: []
82
+ },
83
+ TEAM_RATING: {
84
+ team: ['idteam', :team_id],
74
85
  formula: ['formula', :sym]
75
86
  },
76
87
  RECAP: {
@@ -79,6 +90,11 @@ module ChgkRating
79
90
  captain: ['captain', :player_id],
80
91
  players: ['players', :players_ids]
81
92
  },
93
+ PLAYER_TOURNAMENT: [
94
+ tournament: ['idtournament', :tournament_id],
95
+ team: ['idteam', :team_id],
96
+ in_base_team: ['in_base_team', :boolean_binboolean]
97
+ ],
82
98
  TOURNAMENT: [
83
99
  {
84
100
  id: 'idtournament',
@@ -100,7 +116,7 @@ module ChgkRating
100
116
  :discounted_payment_reason,
101
117
  :comment
102
118
  ],
103
- TOURNAMENT_PLAYER: {
119
+ TOURNAMENT_TEAM_PLAYER: {
104
120
  id: 'idplayer',
105
121
  is_captain: ['is_captain', :boolean_binboolean],
106
122
  is_base: ['is_base', :boolean_binboolean],
@@ -6,6 +6,7 @@ module ChgkRating
6
6
  end
7
7
 
8
8
  def extract_id_from(obj, klass = ChgkRating::Models::Team)
9
+ return unless obj
9
10
  return obj unless obj.is_a? klass
10
11
  obj&.id
11
12
  end