espn 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +91 -6
  3. data/lib/espn.rb +5 -0
  4. data/lib/espn/arguments.rb +41 -0
  5. data/lib/espn/client.rb +29 -5
  6. data/lib/espn/client/athletes.rb +39 -21
  7. data/lib/espn/client/audio.rb +20 -19
  8. data/lib/espn/client/headlines.rb +58 -27
  9. data/lib/espn/client/medals.rb +8 -0
  10. data/lib/espn/client/notes.rb +31 -21
  11. data/lib/espn/client/now.rb +11 -8
  12. data/lib/espn/client/scores.rb +33 -21
  13. data/lib/espn/client/sports.rb +20 -14
  14. data/lib/espn/client/standings.rb +20 -16
  15. data/lib/espn/client/teams.rb +39 -21
  16. data/lib/espn/client/video.rb +14 -17
  17. data/lib/espn/configuration.rb +29 -12
  18. data/lib/espn/error.rb +15 -3
  19. data/lib/espn/helpers.rb +39 -0
  20. data/lib/espn/mapper.rb +142 -0
  21. data/lib/espn/request.rb +86 -7
  22. data/lib/espn/version.rb +1 -1
  23. data/lib/faraday/response/raise_espn_error.rb +33 -11
  24. data/spec/espn/arguments_spec.rb +76 -0
  25. data/spec/espn/client/athletes_spec.rb +38 -47
  26. data/spec/espn/client/audio_spec.rb +30 -29
  27. data/spec/espn/client/headlines_spec.rb +80 -35
  28. data/spec/espn/client/medals_spec.rb +1 -1
  29. data/spec/espn/client/notes_spec.rb +39 -45
  30. data/spec/espn/client/now_spec.rb +1 -2
  31. data/spec/espn/client/scores_spec.rb +56 -39
  32. data/spec/espn/client/sports_spec.rb +56 -18
  33. data/spec/espn/client/standings_spec.rb +42 -19
  34. data/spec/espn/client/teams_spec.rb +61 -43
  35. data/spec/espn/client/video_spec.rb +9 -13
  36. data/spec/espn/helpers_spec.rb +31 -0
  37. data/spec/espn/mapper_spec.rb +136 -0
  38. data/spec/espn/request_spec.rb +65 -0
  39. data/spec/espn_spec.rb +11 -2
  40. data/spec/faraday/response/raise_espn_error_spec.rb +80 -0
  41. data/spec/responses/athletes.json +51 -0
  42. data/spec/responses/audio.json +101 -0
  43. data/spec/responses/headlines.json +174 -0
  44. data/spec/responses/medals.json +273 -0
  45. data/spec/responses/notes.json +100 -0
  46. data/spec/responses/now.json +44 -0
  47. data/spec/responses/scores.json +209 -0
  48. data/spec/responses/sports.json +164 -0
  49. data/spec/responses/standings.json +2689 -0
  50. data/spec/responses/teams.json +51 -0
  51. data/spec/responses/videos.json +28 -0
  52. data/spec/spec_helper.rb +11 -2
  53. metadata +37 -3
  54. data/lib/espn/connection.rb +0 -32
@@ -0,0 +1,174 @@
1
+ {
2
+ "timestamp": "2013-08-27T17:03:09Z",
3
+ "resultsOffset": 0,
4
+ "status": "success",
5
+ "resultsLimit": 10,
6
+ "resultsCount": 2189,
7
+ "headlines": [{
8
+ "headline": "Ronnie Brewer has deal with Rockets",
9
+ "keywords": ["physical", "deal"],
10
+ "lastModified": "2013-08-27T03:22:29Z",
11
+ "audio": [],
12
+ "premium": false,
13
+ "mobileStory": "",
14
+ "links": {
15
+ "api": {
16
+ "news": {
17
+ "href": "http://api.espn.com/v1/sports/news/9603553"
18
+ }
19
+ },
20
+ "web": {
21
+ "href": "http://espn.go.com/nba/story/_/id/9603553/ronnie-brewer-says-2-year-deal-houston-rockets?ex_cid=espnapi_public"
22
+ },
23
+ "mobile": {
24
+ "href": "http://m.espn.go.com/nba/story?storyId=9603553&ex_cid=espnapi_public"
25
+ }
26
+ },
27
+ "type": "HeadlineNews",
28
+ "related": [],
29
+ "id": 9603553,
30
+ "story": "",
31
+ "title": "Ronnie Brewer says he has 2-year deal with Houston Rockets",
32
+ "linkText": "Brewer says he has 2-year deal with Rockets",
33
+ "source": "Associated Press",
34
+ "description": "Forward Ronnie Brewer says he has taken a physical to sign with the Houston Rockets.",
35
+ "images": [],
36
+ "categories": [{
37
+ "description": "NBA",
38
+ "type": "league",
39
+ "sportId": 46,
40
+ "leagueId": 46,
41
+ "league": {
42
+ "id": 46,
43
+ "description": "NBA",
44
+ "links": {
45
+ "api": {
46
+ "leagues": {
47
+ "href": "http://api.espn.com/v1/sports/basketball/nba"
48
+ }
49
+ },
50
+ "web": {
51
+ "leagues": {
52
+ "href": "http://espn.go.com/nba/?ex_cid=espnapi_public"
53
+ }
54
+ },
55
+ "mobile": {
56
+ "leagues": {
57
+ "href": "http://m.espn.go.com/nba/?ex_cid=espnapi_public"
58
+ }
59
+ }
60
+ }
61
+ },
62
+ "uid": "s:40~l:46"
63
+ }, {
64
+ "description": "Ronnie Brewer",
65
+ "type": "athlete",
66
+ "sportId": 46,
67
+ "athleteId": 2991,
68
+ "athlete": {
69
+ "id": 2991,
70
+ "description": "Ronnie Brewer",
71
+ "links": {
72
+ "api": {
73
+ "athletes": {
74
+ "href": "http://api.espn.com/v1/sports/basketball/nba/athletes/2991"
75
+ }
76
+ },
77
+ "web": {
78
+ "athletes": {
79
+ "href": "http://espn.go.com/nba/player/_/id/2991/ronnie-brewer?ex_cid=espnapi_public"
80
+ }
81
+ },
82
+ "mobile": {
83
+ "athletes": {
84
+ "href": "http://m.espn.go.com/nba/playercard?playerId=2991&ex_cid=espnapi_public"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }, {
90
+ "description": "Oklahoma City Thunder",
91
+ "type": "team",
92
+ "sportId": 46,
93
+ "teamId": 25,
94
+ "team": {
95
+ "id": 25,
96
+ "description": "Oklahoma City Thunder",
97
+ "links": {
98
+ "api": {
99
+ "teams": {
100
+ "href": "http://api.espn.com/v1/sports/basketball/nba/teams/25"
101
+ }
102
+ },
103
+ "web": {
104
+ "teams": {
105
+ "href": "http://espn.go.com/nba/team/_/name/okc/oklahoma-city-thunder?ex_cid=espnapi_public"
106
+ }
107
+ },
108
+ "mobile": {
109
+ "teams": {
110
+ "href": "http://m.espn.go.com/nba/clubhouse?teamId=25&ex_cid=espnapi_public"
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "uid": "s:40~l:46~t:25"
116
+ }, {
117
+ "description": "Houston Rockets",
118
+ "type": "team",
119
+ "sportId": 46,
120
+ "teamId": 10,
121
+ "team": {
122
+ "id": 10,
123
+ "description": "Houston Rockets",
124
+ "links": {
125
+ "api": {
126
+ "teams": {
127
+ "href": "http://api.espn.com/v1/sports/basketball/nba/teams/10"
128
+ }
129
+ },
130
+ "web": {
131
+ "teams": {
132
+ "href": "http://espn.go.com/nba/team/_/name/hou/houston-rockets?ex_cid=espnapi_public"
133
+ }
134
+ },
135
+ "mobile": {
136
+ "teams": {
137
+ "href": "http://m.espn.go.com/nba/clubhouse?teamId=10&ex_cid=espnapi_public"
138
+ }
139
+ }
140
+ }
141
+ },
142
+ "uid": "s:40~l:46~t:10"
143
+ }, {
144
+ "description": "New York Knicks",
145
+ "type": "team",
146
+ "sportId": 46,
147
+ "teamId": 18,
148
+ "team": {
149
+ "id": 18,
150
+ "description": "New York Knicks",
151
+ "links": {
152
+ "api": {
153
+ "teams": {
154
+ "href": "http://api.espn.com/v1/sports/basketball/nba/teams/18"
155
+ }
156
+ },
157
+ "web": {
158
+ "teams": {
159
+ "href": "http://espn.go.com/nba/team/_/name/ny/new-york-knicks?ex_cid=espnapi_public"
160
+ }
161
+ },
162
+ "mobile": {
163
+ "teams": {
164
+ "href": "http://m.espn.go.com/nba/clubhouse?teamId=18&ex_cid=espnapi_public"
165
+ }
166
+ }
167
+ }
168
+ },
169
+ "uid": "s:40~l:46~t:18"
170
+ }],
171
+ "published": "2013-08-27T03:19:36Z",
172
+ "video": []
173
+ }]
174
+ }
@@ -0,0 +1,273 @@
1
+ {
2
+ "resultsOffset":0,
3
+ "resultsLimit":50,
4
+ "resultsCount":1,
5
+ "season":{
6
+ "olympicSeasonId":31,
7
+ "year":2008,
8
+ "type":2,
9
+ "description":"regular",
10
+ "startDate":"2008-08-06T07:00:00Z",
11
+ "endDate":"2008-08-25T06:59:59Z"
12
+ },
13
+ "sports":[
14
+ {
15
+ "name":"artistic gymnastics",
16
+ "abbreviation":"artistic-gymnastics",
17
+ "olympicSportId":21
18
+ },
19
+ {
20
+ "name":"shooting",
21
+ "abbreviation":"shooting",
22
+ "olympicSportId":37
23
+ },
24
+ {
25
+ "name":"taekwondo",
26
+ "abbreviation":"taekwondo",
27
+ "olympicSportId":43
28
+ },
29
+ {
30
+ "name":"track and field",
31
+ "abbreviation":"track-and-field",
32
+ "olympicSportId":3
33
+ }
34
+ ],
35
+ "competitors":[
36
+ {
37
+ "type":"country",
38
+ "country":{
39
+ "id":19,
40
+ "abbreviation":"cro"
41
+ },
42
+ "medals":{
43
+ "gold":{
44
+ "total":0,
45
+ "competitions":[
46
+
47
+ ]
48
+ },
49
+ "silver":{
50
+ "total":2,
51
+ "competitions":[
52
+ {
53
+ "olympicSportId":21,
54
+ "name":"Men's Pommel Horse",
55
+ "eventId":166,
56
+ "competitors":[
57
+ {
58
+ "type":"athlete",
59
+ "score":"15.725",
60
+ "worldRecord":false,
61
+ "olympicRecord":false,
62
+ "athlete":{
63
+ "lastName":"Ude",
64
+ "firstName":"Filip",
65
+ "id":24299,
66
+ "country":{
67
+ "id":19,
68
+ "abbreviation":"cro"
69
+ },
70
+ "links":{
71
+ "web":{
72
+ "index":{
73
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008?ex_cid=espnapi_internal"
74
+ }
75
+ },
76
+ "mobile":{
77
+ "index":{
78
+ "href":"http://m.espn.go.com/extra/olympics?ex_cid=espnapi_internal"
79
+ },
80
+ "athletes":{
81
+ "href":"http://m.espn.go.com/extra/olympics/athletes?id=24299&ex_cid=espnapi_internal"
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ ]
88
+ },
89
+ {
90
+ "olympicSportId":3,
91
+ "name":"Women's High Jump",
92
+ "eventId":140,
93
+ "competitors":[
94
+ {
95
+ "type":"athlete",
96
+ "score":"2.05",
97
+ "worldRecord":false,
98
+ "olympicRecord":false,
99
+ "athlete":{
100
+ "lastName":"Vlasic",
101
+ "firstName":"Blanka",
102
+ "id":10289,
103
+ "country":{
104
+ "id":19,
105
+ "abbreviation":"cro"
106
+ },
107
+ "links":{
108
+ "web":{
109
+ "index":{
110
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008?ex_cid=espnapi_internal"
111
+ }
112
+ },
113
+ "mobile":{
114
+ "index":{
115
+ "href":"http://m.espn.go.com/extra/olympics?ex_cid=espnapi_internal"
116
+ },
117
+ "athletes":{
118
+ "href":"http://m.espn.go.com/extra/olympics/athletes?id=10289&ex_cid=espnapi_internal"
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ ]
125
+ }
126
+ ]
127
+ },
128
+ "bronze":{
129
+ "total":3,
130
+ "competitions":[
131
+ {
132
+ "olympicSportId":37,
133
+ "name":"Women's 10m Air Rifle",
134
+ "eventId":737,
135
+ "competitors":[
136
+ {
137
+ "type":"athlete",
138
+ "score":"500.9",
139
+ "worldRecord":false,
140
+ "olympicRecord":false,
141
+ "athlete":{
142
+ "lastName":"Pejcic",
143
+ "firstName":"Snjezana",
144
+ "id":23689,
145
+ "country":{
146
+ "id":19,
147
+ "abbreviation":"cro"
148
+ },
149
+ "links":{
150
+ "web":{
151
+ "index":{
152
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008?ex_cid=espnapi_internal"
153
+ }
154
+ },
155
+ "mobile":{
156
+ "index":{
157
+ "href":"http://m.espn.go.com/extra/olympics?ex_cid=espnapi_internal"
158
+ },
159
+ "athletes":{
160
+ "href":"http://m.espn.go.com/extra/olympics/athletes?id=23689&ex_cid=espnapi_internal"
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "olympicSportId":43,
170
+ "name":"Women's Under 57kg",
171
+ "eventId":91,
172
+ "competitors":[
173
+ {
174
+ "type":"athlete",
175
+ "worldRecord":false,
176
+ "olympicRecord":false,
177
+ "athlete":{
178
+ "lastName":"Zubcic",
179
+ "firstName":"Martina",
180
+ "id":22823,
181
+ "country":{
182
+ "id":19,
183
+ "abbreviation":"cro"
184
+ },
185
+ "links":{
186
+ "web":{
187
+ "index":{
188
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008?ex_cid=espnapi_internal"
189
+ }
190
+ },
191
+ "mobile":{
192
+ "index":{
193
+ "href":"http://m.espn.go.com/extra/olympics?ex_cid=espnapi_internal"
194
+ },
195
+ "athletes":{
196
+ "href":"http://m.espn.go.com/extra/olympics/athletes?id=22823&ex_cid=espnapi_internal"
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ "olympicSportId":43,
206
+ "name":"Women's Under 67kg",
207
+ "eventId":192,
208
+ "competitors":[
209
+ {
210
+ "type":"athlete",
211
+ "worldRecord":false,
212
+ "olympicRecord":false,
213
+ "athlete":{
214
+ "lastName":"Saric",
215
+ "firstName":"Sandra",
216
+ "id":23748,
217
+ "country":{
218
+ "id":19,
219
+ "abbreviation":"cro"
220
+ },
221
+ "links":{
222
+ "web":{
223
+ "index":{
224
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008?ex_cid=espnapi_internal"
225
+ }
226
+ },
227
+ "mobile":{
228
+ "index":{
229
+ "href":"http://m.espn.go.com/extra/olympics?ex_cid=espnapi_internal"
230
+ },
231
+ "athletes":{
232
+ "href":"http://m.espn.go.com/extra/olympics/athletes?id=23748&ex_cid=espnapi_internal"
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+ ]
239
+ }
240
+ ]
241
+ },
242
+ "overall":{
243
+ "total":5
244
+ },
245
+ "links":{
246
+ "api":{
247
+ "medals":{
248
+ "href":"http://api.espn.com/v1/sports/olympics/countries/cro/medals?season=summer&dates=2008"
249
+ }
250
+ },
251
+ "web":{
252
+ "index":{
253
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008?ex_cid=espnapi_internal"
254
+ },
255
+ "medals":{
256
+ "href":"http://espn.go.com/olympics/summer/history/_/year/2008/type/medals?ex_cid=espnapi_internal"
257
+ }
258
+ },
259
+ "mobile":{
260
+ "index":{
261
+ "href":"http://m.espn.go.com/extra/olympics?ex_cid=espnapi_internal"
262
+ },
263
+ "medals":{
264
+ "href":"http://m.espn.go.com/extra/olympics/medals?countryId=19&ex_cid=espnapi_internal"
265
+ }
266
+ }
267
+ }
268
+ }
269
+ }
270
+ ],
271
+ "timestamp":"2012-11-21T16:35:07Z",
272
+ "status":"success"
273
+ }
@@ -0,0 +1,100 @@
1
+ {
2
+ "timestamp":"2012-11-21T16:40:18Z",
3
+ "resultsOffset":0,
4
+ "status":"success",
5
+ "resultsLimit":5,
6
+ "resultsCount":768,
7
+ "notes":[
8
+ {
9
+ "headline":"Cowboys Stink",
10
+ "id":8659824,
11
+ "text":"From Elias: The Cowboys are 3-0 against rookie quarterbacks on Thanksgiving. In 2006, they beat Bruce Gradkowski (TB). In 2004, they beat Craig Krenzel (CHI). And in 1992, they beat Kent Graham (NYG).",
12
+ "source":"ESPN Stats and Information",
13
+ "categories":[
14
+ {
15
+ "description":"NFL",
16
+ "type":"league",
17
+ "sportId":28,
18
+ "leagueId":28,
19
+ "league":{
20
+ "id":28,
21
+ "description":"NFL",
22
+ "links":{
23
+ "api":{
24
+ "leagues":{
25
+ "href":"http://api.espn.com/v1/sports/football/nfl"
26
+ }
27
+ },
28
+ "web":{
29
+ "leagues":{
30
+ "href":"http://espn.go.com/nfl/?ex_cid=espnapi_internal"
31
+ }
32
+ },
33
+ "mobile":{
34
+ "leagues":{
35
+ "href":"http://m.espn.go.com/nfl/?ex_cid=espnapi_internal"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ },
41
+ {
42
+ "description":"Dallas Cowboys",
43
+ "type":"team",
44
+ "sportId":28,
45
+ "teamId":6,
46
+ "team":{
47
+ "id":6,
48
+ "description":"Dallas Cowboys",
49
+ "links":{
50
+ "api":{
51
+ "teams":{
52
+ "href":"http://api.espn.com/v1/sports/football/nfl/teams/6"
53
+ }
54
+ },
55
+ "web":{
56
+ "teams":{
57
+ "href":"http://espn.go.com/nfl/team/_/name/dal/dallas-cowboys?ex_cid=espnapi_internal"
58
+ }
59
+ },
60
+ "mobile":{
61
+ "teams":{
62
+ "href":"http://m.espn.go.com/nfl/clubhouse?teamId=6&ex_cid=espnapi_internal"
63
+ }
64
+ }
65
+ }
66
+ }
67
+ },
68
+ {
69
+ "description":"Robert Griffin III",
70
+ "type":"athlete",
71
+ "sportId":28,
72
+ "athleteId":14875,
73
+ "athlete":{
74
+ "id":14875,
75
+ "description":"Robert Griffin III",
76
+ "links":{
77
+ "api":{
78
+ "athletes":{
79
+ "href":"http://api.espn.com/v1/sports/football/nfl/athletes/14875"
80
+ }
81
+ },
82
+ "web":{
83
+ "athletes":{
84
+ "href":"http://espn.go.com/nfl/player/_/id/14875/robert-griffin-iii?ex_cid=espnapi_internal"
85
+ }
86
+ },
87
+ "mobile":{
88
+ "athletes":{
89
+ "href":"http://m.espn.go.com/nfl/playercard?playerId=14875&ex_cid=espnapi_internal"
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ ],
96
+ "date":"2012-11-21T16:31:59Z",
97
+ "type":"research"
98
+ }
99
+ ]
100
+ }