chgk_rating 1.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +10 -501
- data/Rakefile +4 -2
- data/chgk_rating.gemspec +23 -15
- data/lib/chgk_rating/attribute_mappings.rb +107 -80
- data/lib/chgk_rating/chgk_object.rb +6 -1
- data/lib/chgk_rating/client.rb +43 -10
- data/lib/chgk_rating/collections/base.rb +20 -15
- data/lib/chgk_rating/collections/players.rb +3 -1
- data/lib/chgk_rating/collections/ratings/player_ratings.rb +24 -0
- data/lib/chgk_rating/collections/{ratings.rb → ratings/team_ratings.rb} +5 -4
- data/lib/chgk_rating/collections/recaps.rb +4 -2
- data/lib/chgk_rating/collections/teams.rb +3 -1
- data/lib/chgk_rating/collections/tournaments/player_tournaments.rb +48 -0
- data/lib/chgk_rating/collections/{tournament_players.rb → tournaments/tournament_team_players.rb} +5 -3
- data/lib/chgk_rating/collections/{tournament_team_results.rb → tournaments/tournament_team_results.rb} +3 -1
- data/lib/chgk_rating/collections/{tournament_teams.rb → tournaments/tournament_teams.rb} +4 -1
- data/lib/chgk_rating/collections/{tournaments.rb → tournaments/tournaments.rb} +13 -8
- data/lib/chgk_rating/concerns/searching.rb +10 -9
- data/lib/chgk_rating/connection.rb +12 -7
- data/lib/chgk_rating/error.rb +7 -5
- data/lib/chgk_rating/models/base.rb +34 -15
- data/lib/chgk_rating/models/player.rb +28 -1
- data/lib/chgk_rating/models/rating/player_rating.rb +18 -0
- data/lib/chgk_rating/models/{tournament_player.rb → rating/rating.rb} +4 -2
- data/lib/chgk_rating/models/{rating.rb → rating/team_rating.rb} +4 -5
- data/lib/chgk_rating/models/recap.rb +3 -1
- data/lib/chgk_rating/models/team.rb +9 -7
- data/lib/chgk_rating/models/tournament/player_tournament.rb +10 -0
- data/lib/chgk_rating/models/{tournament.rb → tournament/tournament.rb} +7 -5
- data/lib/chgk_rating/models/{tournament_team.rb → tournament/tournament_team.rb} +6 -4
- data/lib/chgk_rating/models/tournament/tournament_team_player.rb +10 -0
- data/lib/chgk_rating/models/{tournament_team_result.rb → tournament/tournament_team_result.rb} +3 -1
- data/lib/chgk_rating/request.rb +10 -9
- data/lib/chgk_rating/utils/snakecase.rb +9 -7
- data/lib/chgk_rating/utils/transformations.rb +42 -35
- data/lib/chgk_rating/version.rb +4 -2
- data/lib/chgk_rating.rb +18 -11
- data/lib/ext/date.rb +6 -8
- data/lib/ext/date_time.rb +4 -2
- data/lib/ext/uri.rb +6 -6
- metadata +95 -90
- data/spec/lib/chgk_rating/client_spec.rb +0 -208
- data/spec/lib/chgk_rating/collections/players_spec.rb +0 -45
- data/spec/lib/chgk_rating/collections/ratings_spec.rb +0 -25
- data/spec/lib/chgk_rating/collections/recaps_spec.rb +0 -21
- data/spec/lib/chgk_rating/collections/teams_spec.rb +0 -42
- data/spec/lib/chgk_rating/collections/tournament_players_spec.rb +0 -18
- data/spec/lib/chgk_rating/collections/tournament_team_results_spec.rb +0 -17
- data/spec/lib/chgk_rating/collections/tournament_teams_spec.rb +0 -60
- data/spec/lib/chgk_rating/collections/tournaments_spec.rb +0 -62
- data/spec/lib/chgk_rating/models/base_spec.rb +0 -34
- data/spec/lib/chgk_rating/models/player_spec.rb +0 -35
- data/spec/lib/chgk_rating/models/rating_spec.rb +0 -27
- data/spec/lib/chgk_rating/models/recap_spec.rb +0 -35
- data/spec/lib/chgk_rating/models/team_spec.rb +0 -89
- data/spec/lib/chgk_rating/models/tournament_player_spec.rb +0 -21
- data/spec/lib/chgk_rating/models/tournament_spec.rb +0 -92
- data/spec/lib/chgk_rating/models/tournament_team_result_spec.rb +0 -19
- data/spec/lib/chgk_rating/models/tournament_team_spec.rb +0 -36
- data/spec/lib/chgk_rating/utils/snakecase_spec.rb +0 -12
- data/spec/lib/chgk_rating/utils/transformations_spec.rb +0 -16
- data/spec/lib/chgk_rating_spec.rb +0 -5
- data/spec/lib/ext/date_spec.rb +0 -7
- data/spec/lib/ext/date_time_spec.rb +0 -11
- data/spec/lib/ext/uri_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -13
- data/spec/support/shared_examples.rb +0 -63
- data/spec/support/test_client.rb +0 -6
- data/spec/support/vcr.rb +0 -11
@@ -1,11 +0,0 @@
|
|
1
|
-
RSpec.describe DateTime do
|
2
|
-
subject { DateTime.new(2018,01,24,16,58,34) }
|
3
|
-
|
4
|
-
specify '#to_s_chgk' do
|
5
|
-
expect(subject.to_s_chgk).to eq '2018-01-24 16:58:34'
|
6
|
-
end
|
7
|
-
|
8
|
-
specify '.parse_safely' do
|
9
|
-
expect(described_class.parse_safely('2017-09-28 12:00:33').to_s).to eq('2017-09-28T12:00:33+00:00')
|
10
|
-
end
|
11
|
-
end
|
data/spec/lib/ext/uri_spec.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
RSpec.describe URI do
|
2
|
-
specify '.parse_safely' do
|
3
|
-
expect(described_class.parse_safely('http://example.com/test').to_s).to eq('http://example.com/test')
|
4
|
-
expect(described_class.parse_safely('gibberish').to_s).to eq 'gibberish'
|
5
|
-
expect(described_class.parse_safely(nil)).to be_nil
|
6
|
-
end
|
7
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start do
|
3
|
-
add_filter "spec/"
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'chgk_rating'
|
7
|
-
|
8
|
-
# Support files
|
9
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.include TestClient
|
13
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
RSpec.shared_examples_for 'an array' do
|
2
|
-
it { is_expected.to respond_to :to_a }
|
3
|
-
end
|
4
|
-
|
5
|
-
RSpec.shared_examples_for 'not a hash' do
|
6
|
-
it { is_expected.not_to respond_to :to_h }
|
7
|
-
it { expect( -> {subject.to_h} ).to raise_error(ChgkRating::Error::NotHashType).
|
8
|
-
with_message('This is not a hash-like collection, so it cannot be converted to an ordinary hash.')}
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec.shared_examples_for 'not an array' do
|
12
|
-
it { is_expected.not_to respond_to :to_a }
|
13
|
-
it { expect( -> {subject.to_a} ).to raise_error(ChgkRating::Error::NotArrayType).
|
14
|
-
with_message('This is not an array-like collection, so it cannot be converted to an ordinary array.')}
|
15
|
-
end
|
16
|
-
|
17
|
-
RSpec.shared_examples_for 'a hash' do
|
18
|
-
it { is_expected.to respond_to :to_h }
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec.shared_examples_for 'tournament team player' do
|
22
|
-
specify('#id') { expect(player.id).to eq '51249' }
|
23
|
-
specify('#is_captain') { expect(player.is_captain).to eq true }
|
24
|
-
specify('#is_base') { expect(player.is_base).to eq true }
|
25
|
-
specify('#is_foreign') { expect(player.is_foreign).to eq false }
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec.shared_examples_for 'tournament team result' do
|
29
|
-
specify('#result') { expect(team_result.result).to eq [false, false, false, false, true, true,
|
30
|
-
true, false, false, true, false, false] }
|
31
|
-
specify('#tour') { expect(team_result.tour).to eq 1 }
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec.shared_examples_for 'model without eager loading' do
|
35
|
-
it 'should raise an EagerLoadingNotSupported error' do
|
36
|
-
expect( -> { subject.eager_load! }).to raise_error(ChgkRating::Error::EagerLoadingNotSupported).
|
37
|
-
with_message 'Eager loading is not supported for this resource.'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
RSpec.shared_examples_for 'model with eager loading' do
|
42
|
-
it 'should not raise an EagerLoadingNotSupported error' do
|
43
|
-
expect( -> { subject.eager_load! }).not_to raise_error
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
RSpec.shared_examples_for 'model without lazy support' do
|
48
|
-
it { is_expected.not_to respond_to(:lazy) }
|
49
|
-
|
50
|
-
it 'should define NO_LAZY_SUPPORT constant' do
|
51
|
-
expect(subject.class::NO_LAZY_SUPPORT).to eq true
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
RSpec.shared_examples_for 'model with lazy support' do
|
56
|
-
it { is_expected.to respond_to(:lazy) }
|
57
|
-
|
58
|
-
it 'should not define NO_LAZY_SUPPORT constant' do
|
59
|
-
klass = subject.class
|
60
|
-
expect( -> { klass::NO_LAZY_SUPPORT }).to raise_error(NameError).
|
61
|
-
with_message "uninitialized constant #{klass}::NO_LAZY_SUPPORT"
|
62
|
-
end
|
63
|
-
end
|
data/spec/support/test_client.rb
DELETED
data/spec/support/vcr.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'vcr'
|
2
|
-
|
3
|
-
VCR.configure do |c|
|
4
|
-
c.allow_http_connections_when_no_cassette = true
|
5
|
-
c.ignore_hosts 'codeclimate.com'
|
6
|
-
c.hook_into :faraday
|
7
|
-
c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'vcr_cassettes')
|
8
|
-
c.before_record do |i|
|
9
|
-
i.response.body.force_encoding("UTF-8")
|
10
|
-
end
|
11
|
-
end
|