espn 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +91 -6
- data/lib/espn.rb +5 -0
- data/lib/espn/arguments.rb +41 -0
- data/lib/espn/client.rb +29 -5
- data/lib/espn/client/athletes.rb +39 -21
- data/lib/espn/client/audio.rb +20 -19
- data/lib/espn/client/headlines.rb +58 -27
- data/lib/espn/client/medals.rb +8 -0
- data/lib/espn/client/notes.rb +31 -21
- data/lib/espn/client/now.rb +11 -8
- data/lib/espn/client/scores.rb +33 -21
- data/lib/espn/client/sports.rb +20 -14
- data/lib/espn/client/standings.rb +20 -16
- data/lib/espn/client/teams.rb +39 -21
- data/lib/espn/client/video.rb +14 -17
- data/lib/espn/configuration.rb +29 -12
- data/lib/espn/error.rb +15 -3
- data/lib/espn/helpers.rb +39 -0
- data/lib/espn/mapper.rb +142 -0
- data/lib/espn/request.rb +86 -7
- data/lib/espn/version.rb +1 -1
- data/lib/faraday/response/raise_espn_error.rb +33 -11
- data/spec/espn/arguments_spec.rb +76 -0
- data/spec/espn/client/athletes_spec.rb +38 -47
- data/spec/espn/client/audio_spec.rb +30 -29
- data/spec/espn/client/headlines_spec.rb +80 -35
- data/spec/espn/client/medals_spec.rb +1 -1
- data/spec/espn/client/notes_spec.rb +39 -45
- data/spec/espn/client/now_spec.rb +1 -2
- data/spec/espn/client/scores_spec.rb +56 -39
- data/spec/espn/client/sports_spec.rb +56 -18
- data/spec/espn/client/standings_spec.rb +42 -19
- data/spec/espn/client/teams_spec.rb +61 -43
- data/spec/espn/client/video_spec.rb +9 -13
- data/spec/espn/helpers_spec.rb +31 -0
- data/spec/espn/mapper_spec.rb +136 -0
- data/spec/espn/request_spec.rb +65 -0
- data/spec/espn_spec.rb +11 -2
- data/spec/faraday/response/raise_espn_error_spec.rb +80 -0
- data/spec/responses/athletes.json +51 -0
- data/spec/responses/audio.json +101 -0
- data/spec/responses/headlines.json +174 -0
- data/spec/responses/medals.json +273 -0
- data/spec/responses/notes.json +100 -0
- data/spec/responses/now.json +44 -0
- data/spec/responses/scores.json +209 -0
- data/spec/responses/sports.json +164 -0
- data/spec/responses/standings.json +2689 -0
- data/spec/responses/teams.json +51 -0
- data/spec/responses/videos.json +28 -0
- data/spec/spec_helper.rb +11 -2
- metadata +37 -3
- data/lib/espn/connection.rb +0 -32
@@ -0,0 +1,51 @@
|
|
1
|
+
{
|
2
|
+
"sports": [{
|
3
|
+
"name": "baseball",
|
4
|
+
"id": 1,
|
5
|
+
"uid": "s:1",
|
6
|
+
"leagues": [{
|
7
|
+
"name": "Major League Baseball",
|
8
|
+
"abbreviation": "mlb",
|
9
|
+
"id": 10,
|
10
|
+
"uid": "s:1~l:10",
|
11
|
+
"groupId": 9,
|
12
|
+
"shortName": "MLB",
|
13
|
+
"teams": [{
|
14
|
+
"id": 22,
|
15
|
+
"uid": "s:1~l:10~t:22",
|
16
|
+
"location": "Philadelphia",
|
17
|
+
"name": "Phillies",
|
18
|
+
"abbreviation": "PHI",
|
19
|
+
"color": "BB003A",
|
20
|
+
"links": {
|
21
|
+
"api": {
|
22
|
+
"teams": {
|
23
|
+
"href": "http://api.espn.com/v1/sports/baseball/mlb/teams/22"
|
24
|
+
},
|
25
|
+
"news": {
|
26
|
+
"href": "http://api.espn.com/v1/sports/baseball/mlb/teams/22/news"
|
27
|
+
},
|
28
|
+
"notes": {
|
29
|
+
"href": "http://api.espn.com/v1/sports/baseball/mlb/teams/22/news/notes"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"web": {
|
33
|
+
"teams": {
|
34
|
+
"href": "http://espn.go.com/mlb/team/_/name/phi/philadelphia-phillies?ex_cid=espnapi_public"
|
35
|
+
}
|
36
|
+
},
|
37
|
+
"mobile": {
|
38
|
+
"teams": {
|
39
|
+
"href": "http://m.espn.go.com/mlb/clubhouse?teamId=22&ex_cid=espnapi_public"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}]
|
44
|
+
}]
|
45
|
+
}],
|
46
|
+
"resultsOffset": 0,
|
47
|
+
"resultsLimit": 50,
|
48
|
+
"resultsCount": 1,
|
49
|
+
"timestamp": "2013-08-27T17:21:37Z",
|
50
|
+
"status": "success"
|
51
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"resultsCount":29,
|
3
|
+
"resultsOffset":0,
|
4
|
+
"resultsLimit":10,
|
5
|
+
"channels":[
|
6
|
+
{
|
7
|
+
"id": 1234567,
|
8
|
+
"name": "This is a video channel.",
|
9
|
+
"description": "This is the description of a video channel.",
|
10
|
+
"videos":[
|
11
|
+
{
|
12
|
+
"id": 920,
|
13
|
+
"headline": "Some video headline.",
|
14
|
+
"shortHeadline": "Some headline.",
|
15
|
+
"description": "Some video description.",
|
16
|
+
"shortDescription": "Some description.",
|
17
|
+
"premium": false,
|
18
|
+
"ad":{
|
19
|
+
"sport": "baseball",
|
20
|
+
"bundle": "1234"
|
21
|
+
},
|
22
|
+
"originalPublishDate": "2013-11-22T14:22:15Z",
|
23
|
+
"lastModified": "2013-11-22T14:22:15Z"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'espn'
|
2
|
+
require 'json'
|
2
3
|
require 'rspec'
|
3
4
|
require 'webmock/rspec'
|
5
|
+
require 'hashie'
|
4
6
|
|
5
|
-
def stub_get(
|
6
|
-
|
7
|
+
def stub_get(file=nil)
|
8
|
+
if file.nil?
|
9
|
+
stub_request(:get, /api.espn.com/)
|
10
|
+
else
|
11
|
+
response = {
|
12
|
+
body: Hashie::Mash.new(JSON.parse(IO.read("spec/responses/#{file}")))
|
13
|
+
}
|
14
|
+
stub_request(:get, /api.espn.com/).to_return(response)
|
15
|
+
end
|
7
16
|
end
|
8
17
|
|
9
18
|
def espn_url(url)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: espn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Thorp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- LICENSE.md
|
120
120
|
- README.md
|
121
121
|
- espn.gemspec
|
122
|
+
- lib/espn/arguments.rb
|
122
123
|
- lib/espn/client/athletes.rb
|
123
124
|
- lib/espn/client/audio.rb
|
124
125
|
- lib/espn/client/headlines.rb
|
@@ -132,12 +133,14 @@ files:
|
|
132
133
|
- lib/espn/client/video.rb
|
133
134
|
- lib/espn/client.rb
|
134
135
|
- lib/espn/configuration.rb
|
135
|
-
- lib/espn/connection.rb
|
136
136
|
- lib/espn/error.rb
|
137
|
+
- lib/espn/helpers.rb
|
138
|
+
- lib/espn/mapper.rb
|
137
139
|
- lib/espn/request.rb
|
138
140
|
- lib/espn/version.rb
|
139
141
|
- lib/espn.rb
|
140
142
|
- lib/faraday/response/raise_espn_error.rb
|
143
|
+
- spec/espn/arguments_spec.rb
|
141
144
|
- spec/espn/client/athletes_spec.rb
|
142
145
|
- spec/espn/client/audio_spec.rb
|
143
146
|
- spec/espn/client/headlines_spec.rb
|
@@ -151,7 +154,22 @@ files:
|
|
151
154
|
- spec/espn/client/video_spec.rb
|
152
155
|
- spec/espn/client_spec.rb
|
153
156
|
- spec/espn/configuration_spec.rb
|
157
|
+
- spec/espn/helpers_spec.rb
|
158
|
+
- spec/espn/mapper_spec.rb
|
159
|
+
- spec/espn/request_spec.rb
|
154
160
|
- spec/espn_spec.rb
|
161
|
+
- spec/faraday/response/raise_espn_error_spec.rb
|
162
|
+
- spec/responses/athletes.json
|
163
|
+
- spec/responses/audio.json
|
164
|
+
- spec/responses/headlines.json
|
165
|
+
- spec/responses/medals.json
|
166
|
+
- spec/responses/notes.json
|
167
|
+
- spec/responses/now.json
|
168
|
+
- spec/responses/scores.json
|
169
|
+
- spec/responses/sports.json
|
170
|
+
- spec/responses/standings.json
|
171
|
+
- spec/responses/teams.json
|
172
|
+
- spec/responses/videos.json
|
155
173
|
- spec/spec_helper.rb
|
156
174
|
homepage: http://github.com/andrewpthorp/espn
|
157
175
|
licenses:
|
@@ -178,6 +196,7 @@ signing_key:
|
|
178
196
|
specification_version: 4
|
179
197
|
summary: Simple wrapper for the ESPN API.
|
180
198
|
test_files:
|
199
|
+
- spec/espn/arguments_spec.rb
|
181
200
|
- spec/espn/client/athletes_spec.rb
|
182
201
|
- spec/espn/client/audio_spec.rb
|
183
202
|
- spec/espn/client/headlines_spec.rb
|
@@ -191,6 +210,21 @@ test_files:
|
|
191
210
|
- spec/espn/client/video_spec.rb
|
192
211
|
- spec/espn/client_spec.rb
|
193
212
|
- spec/espn/configuration_spec.rb
|
213
|
+
- spec/espn/helpers_spec.rb
|
214
|
+
- spec/espn/mapper_spec.rb
|
215
|
+
- spec/espn/request_spec.rb
|
194
216
|
- spec/espn_spec.rb
|
217
|
+
- spec/faraday/response/raise_espn_error_spec.rb
|
218
|
+
- spec/responses/athletes.json
|
219
|
+
- spec/responses/audio.json
|
220
|
+
- spec/responses/headlines.json
|
221
|
+
- spec/responses/medals.json
|
222
|
+
- spec/responses/notes.json
|
223
|
+
- spec/responses/now.json
|
224
|
+
- spec/responses/scores.json
|
225
|
+
- spec/responses/sports.json
|
226
|
+
- spec/responses/standings.json
|
227
|
+
- spec/responses/teams.json
|
228
|
+
- spec/responses/videos.json
|
195
229
|
- spec/spec_helper.rb
|
196
230
|
has_rdoc:
|
data/lib/espn/connection.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'faraday_middleware'
|
2
|
-
require 'faraday/response/raise_espn_error'
|
3
|
-
|
4
|
-
module ESPN
|
5
|
-
# @private
|
6
|
-
module Connection
|
7
|
-
private
|
8
|
-
|
9
|
-
def connection
|
10
|
-
|
11
|
-
options = {
|
12
|
-
proxy: proxy,
|
13
|
-
ssl: { verify: false },
|
14
|
-
url: api_url
|
15
|
-
}
|
16
|
-
|
17
|
-
options.merge!(params: { apikey: api_key }) if authed?
|
18
|
-
|
19
|
-
connection = Faraday.new(options) do |builder|
|
20
|
-
builder.request :url_encoded
|
21
|
-
|
22
|
-
builder.use Faraday::Response::RaiseESPNError
|
23
|
-
builder.use FaradayMiddleware::Mashify
|
24
|
-
builder.use FaradayMiddleware::ParseJson
|
25
|
-
|
26
|
-
builder.adapter adapter
|
27
|
-
end
|
28
|
-
|
29
|
-
connection
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|