chgk_rating 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/CODE_OF_CONDUCT.md +46 -0
- data/.github/ISSUE_TEMPLATE.md +13 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- data/CHANGELOG.md +17 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +7 -0
- data/LICENSE +22 -0
- data/README.md +557 -0
- data/Rakefile +13 -0
- data/chgk_rating.gemspec +29 -0
- data/lib/chgk_rating.rb +53 -0
- data/lib/chgk_rating/attribute_mappings.rb +138 -0
- data/lib/chgk_rating/chgk_object.rb +13 -0
- data/lib/chgk_rating/client.rb +173 -0
- data/lib/chgk_rating/collections/base.rb +79 -0
- data/lib/chgk_rating/collections/players.rb +17 -0
- data/lib/chgk_rating/collections/ratings.rb +23 -0
- data/lib/chgk_rating/collections/recaps.rb +25 -0
- data/lib/chgk_rating/collections/teams.rb +17 -0
- data/lib/chgk_rating/collections/tournament_players.rb +24 -0
- data/lib/chgk_rating/collections/tournament_team_results.rb +24 -0
- data/lib/chgk_rating/collections/tournament_teams.rb +22 -0
- data/lib/chgk_rating/collections/tournaments.rb +47 -0
- data/lib/chgk_rating/concerns/searching.rb +21 -0
- data/lib/chgk_rating/connection.rb +19 -0
- data/lib/chgk_rating/error.rb +46 -0
- data/lib/chgk_rating/models/base.rb +90 -0
- data/lib/chgk_rating/models/player.rb +11 -0
- data/lib/chgk_rating/models/rating.rb +19 -0
- data/lib/chgk_rating/models/recap.rb +19 -0
- data/lib/chgk_rating/models/team.rb +62 -0
- data/lib/chgk_rating/models/tournament.rb +46 -0
- data/lib/chgk_rating/models/tournament_player.rb +8 -0
- data/lib/chgk_rating/models/tournament_team.rb +29 -0
- data/lib/chgk_rating/models/tournament_team_result.rb +8 -0
- data/lib/chgk_rating/request.rb +32 -0
- data/lib/chgk_rating/utils/snakecase.rb +16 -0
- data/lib/chgk_rating/utils/transformations.rb +83 -0
- data/lib/chgk_rating/version.rb +3 -0
- data/lib/ext/date.rb +11 -0
- data/lib/ext/date_time.rb +5 -0
- data/lib/ext/uri.rb +9 -0
- data/spec/lib/chgk_rating/client_spec.rb +198 -0
- data/spec/lib/chgk_rating/collections/players_spec.rb +45 -0
- data/spec/lib/chgk_rating/collections/ratings_spec.rb +25 -0
- data/spec/lib/chgk_rating/collections/recaps_spec.rb +21 -0
- data/spec/lib/chgk_rating/collections/teams_spec.rb +42 -0
- data/spec/lib/chgk_rating/collections/tournament_players_spec.rb +18 -0
- data/spec/lib/chgk_rating/collections/tournament_team_results_spec.rb +17 -0
- data/spec/lib/chgk_rating/collections/tournament_teams_spec.rb +58 -0
- data/spec/lib/chgk_rating/collections/tournaments_spec.rb +62 -0
- data/spec/lib/chgk_rating/models/base_spec.rb +34 -0
- data/spec/lib/chgk_rating/models/player_spec.rb +35 -0
- data/spec/lib/chgk_rating/models/rating_spec.rb +27 -0
- data/spec/lib/chgk_rating/models/recap_spec.rb +35 -0
- data/spec/lib/chgk_rating/models/team_spec.rb +89 -0
- data/spec/lib/chgk_rating/models/tournament_player_spec.rb +21 -0
- data/spec/lib/chgk_rating/models/tournament_spec.rb +92 -0
- data/spec/lib/chgk_rating/models/tournament_team_result_spec.rb +19 -0
- data/spec/lib/chgk_rating/models/tournament_team_spec.rb +36 -0
- data/spec/lib/chgk_rating/utils/snakecase_spec.rb +12 -0
- data/spec/lib/chgk_rating/utils/transformations_spec.rb +16 -0
- data/spec/lib/chgk_rating_spec.rb +5 -0
- data/spec/lib/ext/date_spec.rb +7 -0
- data/spec/lib/ext/date_time_spec.rb +11 -0
- data/spec/lib/ext/uri_spec.rb +7 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/shared_examples.rb +63 -0
- data/spec/support/test_client.rb +6 -0
- data/spec/support/vcr.rb +10 -0
- metadata +228 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6fcd0eda982c479f893b2916ddd64f4c9012d1a3bee014815286508eff6a8196
|
4
|
+
data.tar.gz: 1258475c6db685a690625af746f070af96169f848352988a548735c4fb11a455
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ddcd9876020c92ae27395757111b3be3b762a4b782c2dfbe233a1f201101e9e8c8e61d3e32dbfe2b7c63087b75f7e70fae42a2f6c141b1b1897b1ae9c51fc11b
|
7
|
+
data.tar.gz: 196d2cf44f13b07690bb52dd5fec7bb95bcd421da25309b649975bb48428414598c83272715c97297a8baf1565758a2849f1e58c296e1ded928bd10270f997ee
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at golosizpru@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: http://contributor-covenant.org
|
46
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
@@ -0,0 +1,11 @@
|
|
1
|
+
### Summary
|
2
|
+
|
3
|
+
Provide a general description of the code changes in your pull
|
4
|
+
request. Were there any bugs you had fixed? If so, mention them. If
|
5
|
+
these bugs have open GitHub issues, be sure to tag them here as well,
|
6
|
+
to keep the conversation linked together.
|
7
|
+
|
8
|
+
### Other Information
|
9
|
+
|
10
|
+
If there's anything else that's important and relevant to your pull
|
11
|
+
request, mention that information here.
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v1.0.0.rc1 (2018-02-22)
|
4
|
+
|
5
|
+
* Collections can be converted to arrays or hashes
|
6
|
+
* Finished with the docs
|
7
|
+
* Other tweaks and updates
|
8
|
+
|
9
|
+
## v1.0.0.pre2 (2018-01-10)
|
10
|
+
|
11
|
+
* Major re-write
|
12
|
+
* New features (like converting models to hashes)
|
13
|
+
|
14
|
+
## v1.0.0.pre1 (2017-10-09)
|
15
|
+
|
16
|
+
* Initial release
|
17
|
+
* Docs are half-finished
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
1. [Fork the repository.][fork]
|
4
|
+
2. [Create a topic branch.][branch]
|
5
|
+
3. Implement your feature or bug fix.
|
6
|
+
4. Don't forget to add specs and make sure they pass
|
7
|
+
5. If necessary, add documentation for your feature or bug fix.
|
8
|
+
6. Commit and push your changes.
|
9
|
+
7. [Submit a pull request.][pr]
|
10
|
+
|
11
|
+
[fork]: http://help.github.com/fork-a-repo/
|
12
|
+
[branch]: http://learn.github.com/p/branching.html
|
13
|
+
[pr]: http://help.github.com/send-pull-requests/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ilya Bodrov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,557 @@
|
|
1
|
+
# ChgkRating
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/bodrovis/ChgkRating.svg?branch=master)](https://travis-ci.org/bodrovis/ChgkRating)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/bodrovis/ChgkRating/badges/gpa.svg)](https://codeclimate.com/github/bodrovis/ChgkRating)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/bodrovis/ChgkRating/badges/coverage.svg)](https://codeclimate.com/github/bodrovis/ChgkRating/coverage)
|
6
|
+
[![Dependency Status](https://gemnasium.com/bodrovis/ChgkRating.svg)](https://gemnasium.com/bodrovis/ChgkRating)
|
7
|
+
|
8
|
+
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.
|
9
|
+
|
10
|
+
[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.
|
11
|
+
|
12
|
+
## Contents
|
13
|
+
|
14
|
+
* [Installation and Requirements](#installation-and-requirements)
|
15
|
+
* [Usage](#usage)
|
16
|
+
+ [A Very Quick Example](#a-very-quick-example)
|
17
|
+
+ [Before You Start](#before-you-start)
|
18
|
+
+ [Initializing the Client](#initializing-the-client)
|
19
|
+
+ [Players](#players)
|
20
|
+
+ [Teams](#teams)
|
21
|
+
+ [Recap (Team's Roster)](#recap-teams-roster)
|
22
|
+
+ [Team Ratings](#team-ratings)
|
23
|
+
+ [Tournaments](#tournaments)
|
24
|
+
+ [Teams at Tournament](#teams-at-tournament)
|
25
|
+
+ [Team Results at Tournament](#team-results-at-tournament)
|
26
|
+
+ [Team Players at Tournament](#team-players-at-tournament)
|
27
|
+
* [Testing](#testing)
|
28
|
+
* [License](#license)
|
29
|
+
|
30
|
+
## Installation and Requirements
|
31
|
+
|
32
|
+
This gem works **only** with Ruby 2.4+ and I have no plans of making it compatible with older versions. Apart from that, it has no special requirements.
|
33
|
+
|
34
|
+
Install it by running:
|
35
|
+
|
36
|
+
$ gem install chgk_rating
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
Remember that ChgkRating API is **read-only**.
|
41
|
+
|
42
|
+
### A Very Quick Example
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
# Instantiate the client:
|
46
|
+
client = ChgkRating.client
|
47
|
+
|
48
|
+
# Get all players:
|
49
|
+
client.players
|
50
|
+
|
51
|
+
# Get a specific team:
|
52
|
+
team = client.team 1
|
53
|
+
|
54
|
+
# Get information about the team at a given tournament:
|
55
|
+
team.at_tournament 1000
|
56
|
+
|
57
|
+
# Get results for the given team as the tournament:
|
58
|
+
team.at_tournament(1000).results
|
59
|
+
|
60
|
+
# The same data can be fetched with:
|
61
|
+
client.team_results_at_tournament 1000, team
|
62
|
+
|
63
|
+
# Or you can even grab the tournament and pass it later:
|
64
|
+
tournament = client.tournament 1000
|
65
|
+
|
66
|
+
team.at_tournament(tournament).results
|
67
|
+
# OR
|
68
|
+
client.team_results_at_tournament tournament, team
|
69
|
+
```
|
70
|
+
|
71
|
+
### Before You Start
|
72
|
+
|
73
|
+
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.
|
74
|
+
|
75
|
+
* [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
|
76
|
+
* [Pagination](https://github.com/bodrovis/ChgkRating/wiki/Pagination)
|
77
|
+
* [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
|
78
|
+
|
79
|
+
### Initializing the Client
|
80
|
+
|
81
|
+
Initialize the client with the following shortcut:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
client = ChgkRating.client
|
85
|
+
```
|
86
|
+
|
87
|
+
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.
|
88
|
+
|
89
|
+
Now you may utilize the `client` local variable to perform various requests described below.
|
90
|
+
|
91
|
+
### Players
|
92
|
+
|
93
|
+
#### Players - Collection
|
94
|
+
|
95
|
+
Returns an array-like `Players` object containing list of `Player` models sorted by their IDs:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
client.players params={} # Input:
|
99
|
+
# (optional) params - Hash
|
100
|
+
## Supported params:
|
101
|
+
## :page - Integer or String. The requested page. Default is 1, and there are 1000 results per page.
|
102
|
+
## :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.
|
103
|
+
## :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.
|
104
|
+
```
|
105
|
+
|
106
|
+
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:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
players = client.players.take(3)
|
110
|
+
players.map! {|p| p.eager_load! true}
|
111
|
+
```
|
112
|
+
|
113
|
+
#### Player - Model
|
114
|
+
|
115
|
+
Returns information about a single `Player`:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
client.player id, lazy=false # Input:
|
119
|
+
# id - Integer or String, player's id
|
120
|
+
# (optional) lazy - Boolean
|
121
|
+
```
|
122
|
+
|
123
|
+
Getter methods:
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
id # String
|
127
|
+
name # String
|
128
|
+
surname # String
|
129
|
+
patronymic # String
|
130
|
+
comment # String
|
131
|
+
db_chgk_info_tag # String
|
132
|
+
```
|
133
|
+
|
134
|
+
Special notes:
|
135
|
+
|
136
|
+
* Can be lazily-loaded and eager-loaded.
|
137
|
+
|
138
|
+
#### Players - Search
|
139
|
+
|
140
|
+
Search for players by a given criteria:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
client.search_players params # Input:
|
144
|
+
# params - Hash
|
145
|
+
## Supported search params:
|
146
|
+
## :name - String
|
147
|
+
## :surname - String
|
148
|
+
## :patronymic - String
|
149
|
+
## :page - String or Integer. Default is 1, and there are 1000 results per page.
|
150
|
+
```
|
151
|
+
|
152
|
+
Returns an array-like `Players::Search` collection consisting of `Player` models.
|
153
|
+
|
154
|
+
### Teams
|
155
|
+
|
156
|
+
#### Teams - Collection
|
157
|
+
|
158
|
+
Get a list of all teams sorted by their IDs:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
client.teams params={} # Input:
|
162
|
+
# (optional) params - Hash
|
163
|
+
## Supported params:
|
164
|
+
## :page - Integer or String. The requested page. Default is 1, and there are 1000 results per page.
|
165
|
+
## :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.
|
166
|
+
## :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.
|
167
|
+
```
|
168
|
+
|
169
|
+
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`.
|
170
|
+
|
171
|
+
#### Team - Model
|
172
|
+
|
173
|
+
Get full information about a single `Team`:
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
client.team id, lazy=false # Input:
|
177
|
+
# id - Integer or String. Team's id
|
178
|
+
# (optional) lazy - Boolean
|
179
|
+
```
|
180
|
+
|
181
|
+
Getter methods:
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
id # String
|
185
|
+
name # String
|
186
|
+
town # String
|
187
|
+
comment # String
|
188
|
+
```
|
189
|
+
|
190
|
+
Special notes:
|
191
|
+
|
192
|
+
* Can be lazily-loaded and eager-loaded.
|
193
|
+
|
194
|
+
##### Interface Methods
|
195
|
+
|
196
|
+
`Team` model respond to the following convenience methods:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
team.recap(season_id) # Returns a single Recap for the current Team at a given season. Input:
|
200
|
+
# season_id - Integer or String
|
201
|
+
|
202
|
+
team.at_tournament(tournament_or_id) # Returns TournamentTeam model that contains information about the
|
203
|
+
# team's results at the given tournament. Input:
|
204
|
+
# tournament_or_id - String, Integer or Tournament
|
205
|
+
|
206
|
+
team.rating(release_id) # Returns Rating for the current Team in a given release. Input:
|
207
|
+
# release_id - String or Integer
|
208
|
+
|
209
|
+
team.ratings # Returns an array-like Ratings collection for the current team.
|
210
|
+
|
211
|
+
team.recaps # Returns an hash-like Recaps collection for the current team, grouped by seasons. Seasons act
|
212
|
+
# as keys, whereas Recap models - as values.
|
213
|
+
|
214
|
+
team.tournaments(season_id: nil, params: {}) # Returns a collection of Tournaments that the current team participated at
|
215
|
+
# based on the given criteria. Input:
|
216
|
+
# (optional) season_id - Integer or String
|
217
|
+
# (optional) params - Hash
|
218
|
+
## Supported params:
|
219
|
+
## :page - String or Integer. Default is 1
|
220
|
+
```
|
221
|
+
|
222
|
+
#### Teams - Search
|
223
|
+
|
224
|
+
Search for teams by a given criteria:
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
client.search_teams params # Input:
|
228
|
+
# params - Hash
|
229
|
+
## Supported search params:
|
230
|
+
## :name - String
|
231
|
+
## :town - String
|
232
|
+
## :page - String or Integer. Default is 1, and there are 1000 results per page.
|
233
|
+
```
|
234
|
+
|
235
|
+
Returns `Teams::Search` collection consisting of `Team` models.
|
236
|
+
|
237
|
+
### Recap (Team's Roster)
|
238
|
+
|
239
|
+
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".
|
240
|
+
|
241
|
+
#### Recaps - Collection
|
242
|
+
|
243
|
+
Get recaps grouped by seasons for a single team:
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
client.recaps team_or_id # Input:
|
247
|
+
# team_or_id - String, Integer or Team. Team to load recaps for.
|
248
|
+
```
|
249
|
+
|
250
|
+
Returns a hash-like `Recaps` object with the season numbers as the keys and the `Recap` model as values.
|
251
|
+
If the team has not participated in a season, it is **not** included in the response.
|
252
|
+
|
253
|
+
The `Recaps` collection responds to the following methods:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
team # Team - lazily-loaded Team model
|
257
|
+
```
|
258
|
+
|
259
|
+
#### Recap - Model
|
260
|
+
|
261
|
+
Get information about a team's recap in a given season:
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
client.recap team_id, season_id # Input:
|
265
|
+
# team_or_id - String, Integer or Team
|
266
|
+
# season_id - Integer or String
|
267
|
+
```
|
268
|
+
|
269
|
+
Returns a `Recap` model that has the following getters:
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
team # Team - lazily-loaded model
|
273
|
+
season_id # String
|
274
|
+
players # Players collection consisting of lazily-loaded Player models
|
275
|
+
captain # Player model, lazily-loaded
|
276
|
+
```
|
277
|
+
|
278
|
+
### Team Ratings
|
279
|
+
|
280
|
+
#### Team Ratings - Collection
|
281
|
+
|
282
|
+
Get all ratings for a single team:
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
client.ratings team_or_id # Input:
|
286
|
+
# team_or_id - String, Integer or Team. Team to load ratings for.
|
287
|
+
```
|
288
|
+
|
289
|
+
Returns an array-like `Ratings` collection containing `Rating` models.
|
290
|
+
|
291
|
+
Collection responds to the following methods:
|
292
|
+
|
293
|
+
```ruby
|
294
|
+
team # Team - lazily-loaded model
|
295
|
+
```
|
296
|
+
|
297
|
+
#### Team Rating - Model
|
298
|
+
|
299
|
+
Get `Rating` for a team in a given release:
|
300
|
+
|
301
|
+
```ruby
|
302
|
+
client.rating team_or_id, release_id # Input:
|
303
|
+
# team_or_id - String, Integer or Team
|
304
|
+
# release_id - String or Integer
|
305
|
+
```
|
306
|
+
|
307
|
+
Getters:
|
308
|
+
|
309
|
+
```ruby
|
310
|
+
team # Team - lazily-loaded model
|
311
|
+
release_id # String
|
312
|
+
rating # Integer
|
313
|
+
rating_position # Integer
|
314
|
+
date # Date
|
315
|
+
formula # Symbol - :a or :b
|
316
|
+
```
|
317
|
+
|
318
|
+
### Tournaments
|
319
|
+
|
320
|
+
#### Tournaments - Collection
|
321
|
+
|
322
|
+
```ruby
|
323
|
+
client.tournaments team_or_id: nil, season_id: nil, params: {} # Input (arguments are passed in a hash-like format):
|
324
|
+
# (optional) team_or_id - String, Integer or Team
|
325
|
+
# (optional) season_id - String or Integer
|
326
|
+
# (optional) params - Hash
|
327
|
+
## Supported params:
|
328
|
+
## :page - String or Integer. Default is 1
|
329
|
+
```
|
330
|
+
|
331
|
+
**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:
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
id # String
|
335
|
+
name # String
|
336
|
+
date_start # Date
|
337
|
+
date_end # Date
|
338
|
+
type_name # String
|
339
|
+
```
|
340
|
+
|
341
|
+
**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.
|
342
|
+
|
343
|
+
**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.
|
344
|
+
|
345
|
+
The collection responds to the following methods:
|
346
|
+
|
347
|
+
```ruby
|
348
|
+
team # Nil or lazily-loaded Team
|
349
|
+
season_id # Nil or String
|
350
|
+
```
|
351
|
+
|
352
|
+
#### Tournament - Model
|
353
|
+
|
354
|
+
Get information about a single tournament:
|
355
|
+
|
356
|
+
```ruby
|
357
|
+
client.tournament id, lazy=false # Input:
|
358
|
+
# id - Integer or String
|
359
|
+
# (optional) lazy - Boolean
|
360
|
+
```
|
361
|
+
|
362
|
+
`Tournament` has the following getters:
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
id # String
|
366
|
+
name # String
|
367
|
+
date_start # DateTime
|
368
|
+
date_end # DateTime
|
369
|
+
type_name # String
|
370
|
+
town # String
|
371
|
+
long_name # String
|
372
|
+
tour_count # Integer
|
373
|
+
tour_questions # Integer
|
374
|
+
tour_ques_per_tour # Integer
|
375
|
+
questions_total # Integer
|
376
|
+
type_name # String
|
377
|
+
main_payment_value # Float
|
378
|
+
discounted_payment_value # Float
|
379
|
+
discounted_payment_reason # String
|
380
|
+
date_requests_allowed_to # DateTime
|
381
|
+
comment # String
|
382
|
+
site_url # URI
|
383
|
+
```
|
384
|
+
|
385
|
+
Special notes:
|
386
|
+
|
387
|
+
* Lazy-loading and eager-loading is supported.
|
388
|
+
|
389
|
+
##### Interface Methods
|
390
|
+
|
391
|
+
`Tournament` model respond to the following convenience methods:
|
392
|
+
|
393
|
+
```ruby
|
394
|
+
tournament.team_players(team_or_id) # Returns an array-like TournamentPlayers collection containing roster
|
395
|
+
# for a team at the current tournament. Input:
|
396
|
+
# team_or_id - String, Integer or Team
|
397
|
+
|
398
|
+
tournament.team_results(team_or_id) # Returns an array-like TournamentTeamResults collection with results
|
399
|
+
# for a given team in the current tournament. Input:
|
400
|
+
# team_or_id - String, Integer or Team
|
401
|
+
|
402
|
+
tournament.team_list # Returns an array-like TournamentTeams collection specifying which
|
403
|
+
# teams participated in the current tournament
|
404
|
+
|
405
|
+
tournament.team(team_or_id) # Returns information about a single TournamentTeam in the current tournament
|
406
|
+
# team_or_id - String, Integer or Team
|
407
|
+
```
|
408
|
+
|
409
|
+
### Teams at Tournament
|
410
|
+
|
411
|
+
#### Teams at Tournament - Collection
|
412
|
+
|
413
|
+
Get a list of all teams which participated in a given tournament:
|
414
|
+
|
415
|
+
```ruby
|
416
|
+
client.teams_at_tournament tournament_or_id # Input:
|
417
|
+
# tournament_id - Integer, String or Tournament
|
418
|
+
```
|
419
|
+
|
420
|
+
Returns an array-like `TournamentTeams` collection that responds to the following methods:
|
421
|
+
|
422
|
+
```ruby
|
423
|
+
tournament # Tournament. Lazily-loaded model
|
424
|
+
```
|
425
|
+
|
426
|
+
#### Team at Tournament - Model
|
427
|
+
|
428
|
+
Instantiate a `TournamentTeam` model:
|
429
|
+
|
430
|
+
```ruby
|
431
|
+
client.team_at_tournament tournament_or_id, team_or_id # Input:
|
432
|
+
# tournament_or_id - Integer, String or Tournament
|
433
|
+
# team_or_id - Integer, String or Team
|
434
|
+
```
|
435
|
+
|
436
|
+
Note that this method **always** returns a lazily-loaded model that cannot be eager-loaded later. This is
|
437
|
+
because the API does not allow to fetch information for a single tournament team. Therefore only the following
|
438
|
+
attributes are set:
|
439
|
+
|
440
|
+
```ruby
|
441
|
+
id # String
|
442
|
+
tournament # Tournament. Lazily-loaded model
|
443
|
+
```
|
444
|
+
|
445
|
+
This `TournamentTeam` object, however, can be used to perform interface methods listed below.
|
446
|
+
|
447
|
+
`TournamentTeam` models loaded with the `teams_at_tournament` method (see above) have the following attributes:
|
448
|
+
|
449
|
+
```ruby
|
450
|
+
id # String
|
451
|
+
current_name # String
|
452
|
+
base_name # String
|
453
|
+
position # Float
|
454
|
+
questions_total # Integer
|
455
|
+
Result # Array - contains Boolean values. Each value corresponds to a single question and
|
456
|
+
# marks whether the team answered this question or not. The length of the array equals to the
|
457
|
+
# value returned by the questions_total method
|
458
|
+
bonus_a # Integer
|
459
|
+
bonus_b # Integer
|
460
|
+
tech_rating # Integer
|
461
|
+
predicted_position # Integer
|
462
|
+
real_bonus_b # Integer
|
463
|
+
d_bonus_b # Integer
|
464
|
+
included_in_rating # Boolean
|
465
|
+
```
|
466
|
+
|
467
|
+
##### Interface Methods
|
468
|
+
|
469
|
+
`TournamentTeam` model respond to the following convenience methods:
|
470
|
+
|
471
|
+
```ruby
|
472
|
+
tournament_team.players # Returns an array-like TournamentPlayers collection containing roster for the current TournamentTeam
|
473
|
+
|
474
|
+
tournament_team.results # Returns an array-like TournamentTeamResults collection containing results for the current TournamentTeam
|
475
|
+
```
|
476
|
+
|
477
|
+
### Team Results at Tournament
|
478
|
+
|
479
|
+
#### Team Results at Tournament - Collection
|
480
|
+
|
481
|
+
Get team results at a given tournament:
|
482
|
+
|
483
|
+
```ruby
|
484
|
+
client.team_results_at_tournament tournament_or_id, team_or_id # Input:
|
485
|
+
# tournament_or_id - Integer, String or Tournament
|
486
|
+
# team_or_id - Integer, String or Team
|
487
|
+
```
|
488
|
+
|
489
|
+
Returns an array-like `TournamentTeamResults` collection with `TournamentTeamResult` models. Each model contains results for a single tour.
|
490
|
+
|
491
|
+
The collection responds to the following methods:
|
492
|
+
|
493
|
+
```ruby
|
494
|
+
team # Team. Lazily-loaded model
|
495
|
+
tournament # Tournament. Lazily-loaded model
|
496
|
+
```
|
497
|
+
|
498
|
+
#### Team Result at Tournament - Model
|
499
|
+
|
500
|
+
API does not allow to load team result for a given tour separately, so use the `team_results_at_tournament` method listed above.
|
501
|
+
|
502
|
+
`TournamentTeamResult` model has the following getters:
|
503
|
+
|
504
|
+
```ruby
|
505
|
+
tour # Integer
|
506
|
+
result # Array containing Boolean values. Each value corresponds to a single question and
|
507
|
+
# says whether the team answered the question or not
|
508
|
+
```
|
509
|
+
|
510
|
+
### Team Players at Tournament
|
511
|
+
|
512
|
+
#### Team Players at Tournament - Collection
|
513
|
+
|
514
|
+
Get information about the team's roster at the given tournament:
|
515
|
+
|
516
|
+
```ruby
|
517
|
+
client.team_players_at_tournament tournament_or_id, team_or_id # Input:
|
518
|
+
# tournament_or_id - Integer, String or Tournament
|
519
|
+
# team_or_id - Integer, String or Team
|
520
|
+
```
|
521
|
+
|
522
|
+
Returns an array-like `TournamentPlayers` collection containing `TournamentPlayer` models (each model represents one player).
|
523
|
+
|
524
|
+
The collection responds to the following getters:
|
525
|
+
|
526
|
+
```ruby
|
527
|
+
id # String
|
528
|
+
tournament # Tournament. Lazily-loaded model
|
529
|
+
```
|
530
|
+
|
531
|
+
#### Team Players at Tournament - Model
|
532
|
+
|
533
|
+
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.
|
534
|
+
|
535
|
+
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.
|
536
|
+
|
537
|
+
`TournamentPlayer` has the following getters:
|
538
|
+
|
539
|
+
```ruby
|
540
|
+
id # String
|
541
|
+
is_captain # Boolean
|
542
|
+
is_base # Boolean
|
543
|
+
is_foreign # Boolean
|
544
|
+
```
|
545
|
+
|
546
|
+
## Testing
|
547
|
+
|
548
|
+
Tests run against mock responses so you don't need to perform any special setup. Simply pull the code and run:
|
549
|
+
|
550
|
+
$ bundle install
|
551
|
+
$ rspec .
|
552
|
+
|
553
|
+
## License
|
554
|
+
|
555
|
+
This plugin is licensed under the [MIT License](https://github.com/bodrovis/ChgkRating/blob/master/LICENSE).
|
556
|
+
|
557
|
+
Copyright (c) 2017 [Ilya Bodrov](http://bodrovis.tech)
|