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
@@ -0,0 +1,22 @@
1
+ RSpec.describe ChgkRating::Models::PlayerRating do
2
+ subject do
3
+ VCR.use_cassette 'rating_player_release' do
4
+ described_class.new 1336, player: 1000
5
+ end
6
+ end
7
+
8
+ let(:rating_h) { subject.to_h }
9
+
10
+ specify('#player') { expect(subject.player.id).to eq '1000' }
11
+ specify('#release_id') { expect(subject.release_id).to eq '1336' }
12
+ specify('#rating') { expect(subject.rating).to eq 7674 }
13
+ specify('#rating_position') { expect(subject.rating_position).to eq 1417 }
14
+ specify('#date') { expect(subject.date).to eq Date.new(2018, 04, 12) }
15
+ specify('#tournaments_in_year') { expect(subject.tournaments_in_year).to eq 15 }
16
+ specify('#tournament_count_total') { expect(subject.tournament_count_total).to eq 284 }
17
+ specify '#to_h' do
18
+ expect(rating_h['idplayer']).to eq '1000'
19
+ expect(rating_h['tournaments_in_year']).to eq '15'
20
+ expect(rating_h['tournament_count_total']).to eq '284'
21
+ end
22
+ end
@@ -32,4 +32,31 @@ RSpec.describe ChgkRating::Models::Player do
32
32
  end
33
33
  expect(lazy_player.name).to eq 'Николай'
34
34
  end
35
+
36
+ describe '#rating' do
37
+ let(:player_rating) do
38
+ VCR.use_cassette 'player_rating_release' do
39
+ subject.rating 1000
40
+ end
41
+ end
42
+ it { expect(player_rating).to be_an_instance_of ChgkRating::Models::PlayerRating }
43
+ end
44
+
45
+ describe '#ratings' do
46
+ let(:player_ratings) do
47
+ VCR.use_cassette 'player_ratings_all_releases' do
48
+ subject.ratings
49
+ end
50
+ end
51
+ it { expect(player_ratings).to be_an_instance_of ChgkRating::Collections::PlayerRatings }
52
+ end
53
+
54
+ describe '#tournaments' do
55
+ let(:player_tournaments) do
56
+ VCR.use_cassette 'player_tournaments2' do
57
+ subject.tournaments
58
+ end
59
+ end
60
+ it { expect(player_tournaments).to be_an_instance_of ChgkRating::Collections::PlayerTournaments }
61
+ end
35
62
  end
@@ -1,4 +1,4 @@
1
- RSpec.describe ChgkRating::Models::Rating do
1
+ RSpec.describe ChgkRating::Models::TeamRating do
2
2
  subject do
3
3
  VCR.use_cassette 'rating_release' do
4
4
  described_class.new 24, team: 1
@@ -48,7 +48,7 @@ RSpec.describe ChgkRating::Models::Team do
48
48
  subject.rating 24
49
49
  end
50
50
  end
51
- it { expect(team_rating).to be_an_instance_of ChgkRating::Models::Rating }
51
+ it { expect(team_rating).to be_an_instance_of ChgkRating::Models::TeamRating }
52
52
  end
53
53
 
54
54
  describe '#recap' do
@@ -84,6 +84,6 @@ RSpec.describe ChgkRating::Models::Team do
84
84
  subject.ratings
85
85
  end
86
86
  end
87
- it { expect(team_ratings).to be_an_instance_of ChgkRating::Collections::Ratings }
87
+ it { expect(team_ratings).to be_an_instance_of ChgkRating::Collections::TeamRatings }
88
88
  end
89
89
  end
@@ -71,11 +71,11 @@ RSpec.describe ChgkRating::Models::Tournament do
71
71
  end
72
72
  end
73
73
 
74
- it { expect(players).to be_an_instance_of ChgkRating::Collections::TournamentPlayers }
74
+ it { expect(players).to be_an_instance_of ChgkRating::Collections::TournamentTeamPlayers }
75
75
  end
76
76
 
77
- describe '#team' do
78
- let(:team) { subject.team 52853 }
77
+ describe '#team_by' do
78
+ let(:team) { subject.team_by 52853 }
79
79
 
80
80
  it { expect(team).to be_an_instance_of ChgkRating::Models::TournamentTeam }
81
81
  end
@@ -1,4 +1,4 @@
1
- RSpec.describe ChgkRating::Models::TournamentPlayer do
1
+ RSpec.describe ChgkRating::Models::TournamentTeamPlayer do
2
2
  subject do
3
3
  VCR.use_cassette 'team_players_at_tournament' do
4
4
  test_client.team_players_at_tournament(3506, 52853)[0]
@@ -21,7 +21,7 @@ RSpec.describe ChgkRating::Models::TournamentTeam do
21
21
  end
22
22
  end
23
23
 
24
- it { expect(players).to be_an_instance_of ChgkRating::Collections::TournamentPlayers }
24
+ it { expect(players).to be_an_instance_of ChgkRating::Collections::TournamentTeamPlayers }
25
25
  end
26
26
 
27
27
  describe '#results' do
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start do
3
3
  add_filter "spec/"
4
+ add_filter ".github/"
5
+ add_filter "docs/"
4
6
  end
5
7
 
6
8
  require 'chgk_rating'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chgk_rating
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-23 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,42 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.13'
19
+ version: '1.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.13'
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: multi_json
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.12'
47
+ version: '1.15'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.12'
54
+ version: '1.15'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '12.1'
61
+ version: '13.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '12.1'
68
+ version: '13.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '4.0'
89
+ version: '6.0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '4.0'
96
+ version: '6.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: codeclimate-test-reporter
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -119,25 +133,30 @@ files:
119
133
  - lib/chgk_rating/client.rb
120
134
  - lib/chgk_rating/collections/base.rb
121
135
  - lib/chgk_rating/collections/players.rb
122
- - lib/chgk_rating/collections/ratings.rb
136
+ - lib/chgk_rating/collections/ratings/player_ratings.rb
137
+ - lib/chgk_rating/collections/ratings/team_ratings.rb
123
138
  - lib/chgk_rating/collections/recaps.rb
124
139
  - lib/chgk_rating/collections/teams.rb
125
- - lib/chgk_rating/collections/tournament_players.rb
126
- - lib/chgk_rating/collections/tournament_team_results.rb
127
- - lib/chgk_rating/collections/tournament_teams.rb
128
- - lib/chgk_rating/collections/tournaments.rb
140
+ - lib/chgk_rating/collections/tournaments/player_tournaments.rb
141
+ - lib/chgk_rating/collections/tournaments/tournament_team_players.rb
142
+ - lib/chgk_rating/collections/tournaments/tournament_team_results.rb
143
+ - lib/chgk_rating/collections/tournaments/tournament_teams.rb
144
+ - lib/chgk_rating/collections/tournaments/tournaments.rb
129
145
  - lib/chgk_rating/concerns/searching.rb
130
146
  - lib/chgk_rating/connection.rb
131
147
  - lib/chgk_rating/error.rb
132
148
  - lib/chgk_rating/models/base.rb
133
149
  - lib/chgk_rating/models/player.rb
134
- - lib/chgk_rating/models/rating.rb
150
+ - lib/chgk_rating/models/rating/player_rating.rb
151
+ - lib/chgk_rating/models/rating/rating.rb
152
+ - lib/chgk_rating/models/rating/team_rating.rb
135
153
  - lib/chgk_rating/models/recap.rb
136
154
  - lib/chgk_rating/models/team.rb
137
- - lib/chgk_rating/models/tournament.rb
138
- - lib/chgk_rating/models/tournament_player.rb
139
- - lib/chgk_rating/models/tournament_team.rb
140
- - lib/chgk_rating/models/tournament_team_result.rb
155
+ - lib/chgk_rating/models/tournament/player_tournament.rb
156
+ - lib/chgk_rating/models/tournament/tournament.rb
157
+ - lib/chgk_rating/models/tournament/tournament_team.rb
158
+ - lib/chgk_rating/models/tournament/tournament_team_player.rb
159
+ - lib/chgk_rating/models/tournament/tournament_team_result.rb
141
160
  - lib/chgk_rating/request.rb
142
161
  - lib/chgk_rating/utils/snakecase.rb
143
162
  - lib/chgk_rating/utils/transformations.rb
@@ -146,23 +165,26 @@ files:
146
165
  - lib/ext/date_time.rb
147
166
  - lib/ext/uri.rb
148
167
  - spec/lib/chgk_rating/client_spec.rb
168
+ - spec/lib/chgk_rating/collections/player_ratings_spec.rb
149
169
  - spec/lib/chgk_rating/collections/players_spec.rb
150
- - spec/lib/chgk_rating/collections/ratings_spec.rb
151
170
  - spec/lib/chgk_rating/collections/recaps_spec.rb
171
+ - spec/lib/chgk_rating/collections/team_ratings_spec.rb
152
172
  - spec/lib/chgk_rating/collections/teams_spec.rb
153
- - spec/lib/chgk_rating/collections/tournament_players_spec.rb
154
- - spec/lib/chgk_rating/collections/tournament_team_results_spec.rb
155
- - spec/lib/chgk_rating/collections/tournament_teams_spec.rb
156
- - spec/lib/chgk_rating/collections/tournaments_spec.rb
173
+ - spec/lib/chgk_rating/collections/tournaments/player_tournaments_spec.rb
174
+ - spec/lib/chgk_rating/collections/tournaments/tournament_team_players_spec.rb
175
+ - spec/lib/chgk_rating/collections/tournaments/tournament_team_results_spec.rb
176
+ - spec/lib/chgk_rating/collections/tournaments/tournament_teams_spec.rb
177
+ - spec/lib/chgk_rating/collections/tournaments/tournaments_spec.rb
157
178
  - spec/lib/chgk_rating/models/base_spec.rb
179
+ - spec/lib/chgk_rating/models/player_rating_spec.rb
158
180
  - spec/lib/chgk_rating/models/player_spec.rb
159
- - spec/lib/chgk_rating/models/rating_spec.rb
160
181
  - spec/lib/chgk_rating/models/recap_spec.rb
182
+ - spec/lib/chgk_rating/models/team_rating_spec.rb
161
183
  - spec/lib/chgk_rating/models/team_spec.rb
162
- - spec/lib/chgk_rating/models/tournament_player_spec.rb
163
- - spec/lib/chgk_rating/models/tournament_spec.rb
164
- - spec/lib/chgk_rating/models/tournament_team_result_spec.rb
165
- - spec/lib/chgk_rating/models/tournament_team_spec.rb
184
+ - spec/lib/chgk_rating/models/tournament/tournament_spec.rb
185
+ - spec/lib/chgk_rating/models/tournament/tournament_team_player_spec.rb
186
+ - spec/lib/chgk_rating/models/tournament/tournament_team_result_spec.rb
187
+ - spec/lib/chgk_rating/models/tournament/tournament_team_spec.rb
166
188
  - spec/lib/chgk_rating/utils/snakecase_spec.rb
167
189
  - spec/lib/chgk_rating/utils/transformations_spec.rb
168
190
  - spec/lib/chgk_rating_spec.rb
@@ -173,11 +195,11 @@ files:
173
195
  - spec/support/shared_examples.rb
174
196
  - spec/support/test_client.rb
175
197
  - spec/support/vcr.rb
176
- homepage: https://github.com/bodrovis/ChgkRating
198
+ homepage: http://chgk-rating.bodrovis.tech/
177
199
  licenses:
178
200
  - MIT
179
201
  metadata: {}
180
- post_install_message:
202
+ post_install_message:
181
203
  rdoc_options: []
182
204
  require_paths:
183
205
  - lib
@@ -192,30 +214,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
214
  - !ruby/object:Gem::Version
193
215
  version: '0'
194
216
  requirements: []
195
- rubyforge_project:
196
- rubygems_version: 2.7.6
197
- signing_key:
217
+ rubygems_version: 3.2.33
218
+ signing_key:
198
219
  specification_version: 4
199
220
  summary: Ruby interface to the competitive What? Where? When? rating API
200
221
  test_files:
201
222
  - spec/lib/chgk_rating/client_spec.rb
223
+ - spec/lib/chgk_rating/collections/player_ratings_spec.rb
202
224
  - spec/lib/chgk_rating/collections/players_spec.rb
203
- - spec/lib/chgk_rating/collections/ratings_spec.rb
204
225
  - spec/lib/chgk_rating/collections/recaps_spec.rb
226
+ - spec/lib/chgk_rating/collections/team_ratings_spec.rb
205
227
  - spec/lib/chgk_rating/collections/teams_spec.rb
206
- - spec/lib/chgk_rating/collections/tournaments_spec.rb
207
- - spec/lib/chgk_rating/collections/tournament_players_spec.rb
208
- - spec/lib/chgk_rating/collections/tournament_teams_spec.rb
209
- - spec/lib/chgk_rating/collections/tournament_team_results_spec.rb
228
+ - spec/lib/chgk_rating/collections/tournaments/player_tournaments_spec.rb
229
+ - spec/lib/chgk_rating/collections/tournaments/tournament_team_players_spec.rb
230
+ - spec/lib/chgk_rating/collections/tournaments/tournament_team_results_spec.rb
231
+ - spec/lib/chgk_rating/collections/tournaments/tournament_teams_spec.rb
232
+ - spec/lib/chgk_rating/collections/tournaments/tournaments_spec.rb
210
233
  - spec/lib/chgk_rating/models/base_spec.rb
234
+ - spec/lib/chgk_rating/models/player_rating_spec.rb
211
235
  - spec/lib/chgk_rating/models/player_spec.rb
212
- - spec/lib/chgk_rating/models/rating_spec.rb
213
236
  - spec/lib/chgk_rating/models/recap_spec.rb
237
+ - spec/lib/chgk_rating/models/team_rating_spec.rb
214
238
  - spec/lib/chgk_rating/models/team_spec.rb
215
- - spec/lib/chgk_rating/models/tournament_player_spec.rb
216
- - spec/lib/chgk_rating/models/tournament_spec.rb
217
- - spec/lib/chgk_rating/models/tournament_team_result_spec.rb
218
- - spec/lib/chgk_rating/models/tournament_team_spec.rb
239
+ - spec/lib/chgk_rating/models/tournament/tournament_spec.rb
240
+ - spec/lib/chgk_rating/models/tournament/tournament_team_player_spec.rb
241
+ - spec/lib/chgk_rating/models/tournament/tournament_team_result_spec.rb
242
+ - spec/lib/chgk_rating/models/tournament/tournament_team_spec.rb
219
243
  - spec/lib/chgk_rating/utils/snakecase_spec.rb
220
244
  - spec/lib/chgk_rating/utils/transformations_spec.rb
221
245
  - spec/lib/chgk_rating_spec.rb