sports_data_api 0.15.1 → 0.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/sports_data_api/golf/course.rb +1 -1
- data/lib/sports_data_api/golf/pairing.rb +1 -1
- data/lib/sports_data_api/golf/season.rb +1 -1
- data/lib/sports_data_api/golf.rb +4 -4
- data/lib/sports_data_api/mlb/division.rb +1 -1
- data/lib/sports_data_api/mlb/league.rb +1 -1
- data/lib/sports_data_api/nba/games.rb +1 -1
- data/lib/sports_data_api/nba/season.rb +1 -1
- data/lib/sports_data_api/nba/teams.rb +1 -1
- data/lib/sports_data_api/nfl/season.rb +1 -1
- data/lib/sports_data_api/nfl/teams.rb +1 -1
- data/lib/sports_data_api/nfl/week.rb +1 -1
- data/lib/sports_data_api/nhl/games.rb +1 -1
- data/lib/sports_data_api/nhl/season.rb +1 -1
- data/lib/sports_data_api/nhl/teams.rb +1 -1
- data/lib/sports_data_api/version.rb +1 -1
- data/spec/cassettes/sports_data_api_nhl_season.yml +79 -8
- data/spec/lib/sports_data_api/nhl/season_spec.rb +28 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90a618d57290eff4689456381867315bce98c10c38800ab90b501834ba2e96a0
|
4
|
+
data.tar.gz: d30d9f0126b1986744d5593097c262c2bbc3a11a3cfc9b3f250699872329345b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963da55d3d2a1fb7133f1cd10e85efc087dadf5dfee5fc2362800b58c3be7d7186f28948fc2277ffff741fa17f1bf8f78470ff380117f229c4150ef92cbd27a8
|
7
|
+
data.tar.gz: 614bf62757c001d026fae6c892cf2470f71b56f7c763d27ff22f2d426ecfcd6a950c9d507bfd3fd6e4773f2044ebd1c0beeb61d62b8e03c689d63c0fca335517
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v0.15.2
|
4
|
+
* [#94](https://github.com/RLovelett/sports_data_api/pull/94) [FIX] Safe map of json responses
|
5
|
+
|
3
6
|
## v0.15.1
|
4
7
|
* [#92](https://github.com/RLovelett/sports_data_api/pull/92) [FIX] NFL extra points stats
|
5
8
|
* [#93](https://github.com/RLovelett/sports_data_api/pull/93) [Feature] Stats have #fetch like hash
|
@@ -8,7 +8,7 @@ module SportsDataApi
|
|
8
8
|
def initialize(season_hash)
|
9
9
|
@year = season_hash['season']['year']
|
10
10
|
@tour = season_hash['tour']['alias'].downcase.to_sym
|
11
|
-
@tournaments = season_hash
|
11
|
+
@tournaments = season_hash.fetch('tournaments', []).map do |tournament_hash|
|
12
12
|
Tournament.new(tour, year, tournament_hash)
|
13
13
|
end
|
14
14
|
end
|
data/lib/sports_data_api/golf.rb
CHANGED
@@ -38,7 +38,7 @@ module SportsDataApi
|
|
38
38
|
def players(tour, year)
|
39
39
|
response = response_json UrlPaths::PLAYERS % { tour: tour, year: year }
|
40
40
|
|
41
|
-
response
|
41
|
+
response.fetch('players', []).map do |json|
|
42
42
|
Player.new(json)
|
43
43
|
end
|
44
44
|
end
|
@@ -57,7 +57,7 @@ module SportsDataApi
|
|
57
57
|
{ tour: tour, year: year, tournament_id: tournament_id, round: round }
|
58
58
|
|
59
59
|
|
60
|
-
response
|
60
|
+
(response.dig('round', 'courses') || []).map do |json|
|
61
61
|
Course.new(json)
|
62
62
|
end
|
63
63
|
end
|
@@ -73,7 +73,7 @@ module SportsDataApi
|
|
73
73
|
status: response['round']['status'],
|
74
74
|
year: year,
|
75
75
|
tour: tour,
|
76
|
-
players: response
|
76
|
+
players: (response.dig('round', 'players') || []).map do |json|
|
77
77
|
Player.new(json)
|
78
78
|
end
|
79
79
|
}
|
@@ -84,7 +84,7 @@ module SportsDataApi
|
|
84
84
|
response = response_json UrlPaths::LEADERBOARDS %
|
85
85
|
{ tour: tour, year: year, tournament_id: tournament_id }
|
86
86
|
|
87
|
-
response
|
87
|
+
response.fetch('leaderboard', []).map do |json|
|
88
88
|
Player.new(json)
|
89
89
|
end
|
90
90
|
end
|
@@ -2,7 +2,7 @@ module SportsDataApi
|
|
2
2
|
module Mlb
|
3
3
|
class Division < JsonData
|
4
4
|
def teams
|
5
|
-
@teams ||= division
|
5
|
+
@teams ||= division.fetch(:teams, []).map do |data|
|
6
6
|
Team.new(data).tap do |t|
|
7
7
|
t.team[:division] = division[:name]
|
8
8
|
t.team[:division_alias] = division[:alias]
|
@@ -8,7 +8,7 @@ module SportsDataApi
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def teams
|
11
|
-
@teams ||= json
|
11
|
+
@teams ||= json.fetch('conferences', []).flat_map do |conference|
|
12
12
|
conference['divisions'].flat_map do |division|
|
13
13
|
division['teams'].map do |json|
|
14
14
|
Team.new(json, conference['alias'], division['alias'])
|
@@ -13,7 +13,7 @@ module SportsDataApi
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def teams
|
16
|
-
@teams ||= json
|
16
|
+
@teams ||= json.fetch('conferences', []).flat_map do |conference_json|
|
17
17
|
conference = conference_json['name']
|
18
18
|
conference_json['divisions'].flat_map do |division_json|
|
19
19
|
division = division_json['name']
|
@@ -8,7 +8,7 @@ module SportsDataApi
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def teams
|
11
|
-
@teams ||= json
|
11
|
+
@teams ||= json.fetch('conferences', []).flat_map do |conference|
|
12
12
|
conference['divisions'].flat_map do |division|
|
13
13
|
division['teams'].map do |team_json|
|
14
14
|
Team.new(team_json, conference['alias'], division['alias'])
|
@@ -1,5 +1,76 @@
|
|
1
1
|
---
|
2
2
|
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.sportradar.us/nhl/trial/v5/en/games/2018/PST/schedule.json?api_key=<API_KEY>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
base64_string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin16.7.0 x86_64) ruby/2.5.1p57
|
16
|
+
Host:
|
17
|
+
- api.sportradar.us
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Accept-Ranges:
|
24
|
+
- bytes
|
25
|
+
Age:
|
26
|
+
- '0'
|
27
|
+
Cache-Control:
|
28
|
+
- public, must-revalidate, max-age=11
|
29
|
+
Content-Language:
|
30
|
+
- en
|
31
|
+
Content-Type:
|
32
|
+
- application/json;charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Fri, 21 Sep 2018 16:30:19 GMT
|
35
|
+
Expires:
|
36
|
+
- Fri, 21 Sep 2018 16:30:30 GMT
|
37
|
+
Server:
|
38
|
+
- nginx
|
39
|
+
Via:
|
40
|
+
- 1.1 varnish-v4
|
41
|
+
- 1.1 varnish-v4
|
42
|
+
X-Be-Cache:
|
43
|
+
- MISS
|
44
|
+
X-Fe-Cache:
|
45
|
+
- MISS
|
46
|
+
X-Mashery-Responder:
|
47
|
+
- prod-j-worker-us-east-1b-50.mashery.com
|
48
|
+
X-Plan-Qps-Allotted:
|
49
|
+
- '25'
|
50
|
+
X-Plan-Qps-Current:
|
51
|
+
- '1'
|
52
|
+
X-Plan-Quota-Allotted:
|
53
|
+
- '15000'
|
54
|
+
X-Plan-Quota-Current:
|
55
|
+
- '4'
|
56
|
+
X-Varnish:
|
57
|
+
- '11247620'
|
58
|
+
- '25454331'
|
59
|
+
X-Via:
|
60
|
+
- Translation-Proxy
|
61
|
+
Content-Length:
|
62
|
+
- '163'
|
63
|
+
Connection:
|
64
|
+
- keep-alive
|
65
|
+
body:
|
66
|
+
encoding: UTF-8
|
67
|
+
base64_string: |
|
68
|
+
eyJsZWFndWUiOnsiaWQiOiJmZDU2MDEwNy1hODViLTQzODgtYWIwZC02NTVh
|
69
|
+
ZDAyMmFmZjciLCJuYW1lIjoiTkhMIiwiYWxpYXMiOiJOSEwifSwic2Vhc29u
|
70
|
+
Ijp7ImlkIjoiNDU1MmM0OWUtMzBlNi00YmNiLThhM2MtYTllM2I3OTUwOWQy
|
71
|
+
IiwieWVhciI6MjAxOCwidHlwZSI6IlBTVCJ9fQ==
|
72
|
+
http_version:
|
73
|
+
recorded_at: Fri, 21 Sep 2018 16:30:19 GMT
|
3
74
|
- request:
|
4
75
|
method: get
|
5
76
|
uri: https://api.sportradar.us/nhl/trial/v5/en/games/2013/REG/schedule.json?api_key=<API_KEY>
|
@@ -12,7 +83,7 @@ http_interactions:
|
|
12
83
|
Accept-Encoding:
|
13
84
|
- gzip, deflate
|
14
85
|
User-Agent:
|
15
|
-
- rest-client/2.0.2 (darwin16.7.0 x86_64) ruby/2.
|
86
|
+
- rest-client/2.0.2 (darwin16.7.0 x86_64) ruby/2.5.1p57
|
16
87
|
Host:
|
17
88
|
- api.sportradar.us
|
18
89
|
response:
|
@@ -31,9 +102,9 @@ http_interactions:
|
|
31
102
|
Content-Type:
|
32
103
|
- application/json;charset=utf-8
|
33
104
|
Date:
|
34
|
-
-
|
105
|
+
- Fri, 21 Sep 2018 16:30:24 GMT
|
35
106
|
Expires:
|
36
|
-
-
|
107
|
+
- Fri, 21 Sep 2018 16:30:35 GMT
|
37
108
|
Server:
|
38
109
|
- nginx
|
39
110
|
Via:
|
@@ -44,7 +115,7 @@ http_interactions:
|
|
44
115
|
X-Fe-Cache:
|
45
116
|
- MISS
|
46
117
|
X-Mashery-Responder:
|
47
|
-
- prod-j-worker-us-east-
|
118
|
+
- prod-j-worker-us-east-1d-58.mashery.com
|
48
119
|
X-Plan-Qps-Allotted:
|
49
120
|
- '25'
|
50
121
|
X-Plan-Qps-Current:
|
@@ -52,10 +123,10 @@ http_interactions:
|
|
52
123
|
X-Plan-Quota-Allotted:
|
53
124
|
- '15000'
|
54
125
|
X-Plan-Quota-Current:
|
55
|
-
- '
|
126
|
+
- '5'
|
56
127
|
X-Varnish:
|
57
|
-
- '
|
58
|
-
- '
|
128
|
+
- '24303725'
|
129
|
+
- '9523988'
|
59
130
|
X-Via:
|
60
131
|
- Translation-Proxy
|
61
132
|
Content-Length:
|
@@ -15712,5 +15783,5 @@ http_interactions:
|
|
15712
15783
|
MThhOTA1NzY3ZTQ0IiwibmFtZSI6IkRhbGxhcyBTdGFycyIsImFsaWFzIjoi
|
15713
15784
|
REFMIn19XX0=
|
15714
15785
|
http_version:
|
15715
|
-
recorded_at:
|
15786
|
+
recorded_at: Fri, 21 Sep 2018 16:30:25 GMT
|
15716
15787
|
recorded_with: VCR 3.0.3
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SportsDataApi::Nhl::Season, vcr: {
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
cassette_name: 'sports_data_api_nhl_season',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
7
|
} do
|
8
8
|
subject { SportsDataApi::Nhl::Season }
|
9
|
+
|
9
10
|
describe '.season?' do
|
10
11
|
context :PRE do
|
11
12
|
it { SportsDataApi::Nhl::Season.valid?(:PRE).should eq(true) }
|
@@ -26,16 +27,30 @@ describe SportsDataApi::Nhl::Season, vcr: {
|
|
26
27
|
it { subject.valid?(:pst).should eq(false) }
|
27
28
|
end
|
28
29
|
end
|
30
|
+
|
29
31
|
context 'results from schedule fetch' do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
let(:season) do
|
33
|
+
SportsDataApi.set_access_level(:nhl, 'trial')
|
34
|
+
SportsDataApi.set_key(:nhl, api_key(:nhl))
|
35
|
+
SportsDataApi::Nhl.schedule(2013, :reg)
|
36
|
+
end
|
37
|
+
subject { season }
|
38
|
+
it { should be_an_instance_of(SportsDataApi::Nhl::Season) }
|
39
|
+
its(:year) { should eq 2013 }
|
40
|
+
its(:type) { should eq :REG }
|
41
|
+
its(:games) { should have(1233).games }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when season has no games' do
|
45
|
+
let(:season) do
|
46
|
+
SportsDataApi.set_access_level(:nhl, 'trial')
|
47
|
+
SportsDataApi.set_key(:nhl, api_key(:nhl))
|
48
|
+
SportsDataApi::Nhl.schedule(2018, :PST)
|
49
|
+
end
|
50
|
+
subject { season }
|
51
|
+
it { should be_an_instance_of(SportsDataApi::Nhl::Season) }
|
52
|
+
its(:year) { should eq 2018 }
|
53
|
+
its(:type) { should eq :PST }
|
54
|
+
its(:games) { should have(0).games }
|
40
55
|
end
|
41
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sports_data_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Lovelett
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|