omdbgateway 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -11
- data/fixtures/vcr_cassettes/omdbapi_com.yml +124 -26
- data/lib/omdbgateway/gateway.rb +13 -9
- data/omdbgateway.gemspec +1 -1
- data/rspec_output.txt +5 -2
- data/spec/omdbgateway/gateway_spec.rb +19 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed6caec8e3f2a8d4af8638612af35c1eb32adcd6
|
4
|
+
data.tar.gz: 10dbbaae953d2581e46ea04a079ee9770f7024f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8d7fca62e9c35f5d91839583b66264094643eb06df03de1cdfe6ce2c762dead9a079b29182c0d4bab4c4550f467e7720b9c7c6c3ae02e2e17973327705be76e
|
7
|
+
data.tar.gz: 95109dbc155421e4649bd8135f06f02c7553b7917ea5c24833a5b02865c6fc43469a85f5f9e7060ce5ddfbde85b48ed1a8ef1e06f13de257643cd638cde52027
|
data/README.md
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
#
|
1
|
+
#omdbgateway
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/omdbgateway.svg)](http://badge.fury.io/rb/omdbgateway)
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/stujo/omdbgateway.svg?branch=master)](https://travis-ci.org/stujo/omdbgateway)
|
6
6
|
|
7
|
-
|
7
|
+
[![Code Climate](https://codeclimate.com/github/stujo/omdbgateway.png)](https://codeclimate.com/github/stujo/omdbgateway)
|
8
|
+
|
9
|
+
#Overview
|
10
|
+
A Service Gateway to the omdb api. Adds support for failure or success detection, query simplification
|
11
|
+
|
12
|
+
For the full format of the Hashes returned by this api please review the source documenation here: [http://www.omdbapi.com/](http://www.omdbapi.com/)
|
8
13
|
|
9
|
-
|
10
|
-
in our class
|
14
|
+
The plan is to support caching via the faraday stack but this is not implemented yet
|
11
15
|
|
12
16
|
|
13
17
|
#Installation
|
@@ -28,16 +32,29 @@ gem "omdbgateway"
|
|
28
32
|
|
29
33
|
#Usage
|
30
34
|
|
35
|
+
|
31
36
|
##Title Search
|
32
37
|
|
33
|
-
Returns a single item (chosen by OMDB) as a Hash
|
38
|
+
Returns a OMDBGateway::ResponseWrapper for a single item (chosen by OMDB) as a Hash
|
34
39
|
|
35
40
|
```
|
41
|
+
# Retrieves a single movie or show based on its title.
|
42
|
+
#
|
43
|
+
# @param title [String] The title of the movie or show.
|
44
|
+
# @param year [String] The year of the movie or show.
|
45
|
+
# @param full_plot [Boolean] Full Plot data (default: false)
|
46
|
+
# @return [OMDBGateway::ResponseWrapper]
|
47
|
+
# @example
|
48
|
+
# title_search('Game of Thrones')
|
49
|
+
def title_search(title, year = nil, full_plot = false, tomatoes = false)
|
36
50
|
|
37
|
-
|
51
|
+
```
|
38
52
|
|
39
|
-
|
40
|
-
|
53
|
+
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
require 'omdbgateway'
|
41
58
|
|
42
59
|
OMDBGateway.gateway.title_search('Star Wars').body
|
43
60
|
=> {"Title"=>"Star Wars", "Year"=>"1983", "Rated"=>"N/A", "Released"=>"01 May 1983", "Runtime"=>"N/A", "Genre"=>"Action, Adventure, Sci-Fi", "Director"=>"N/A", "Writer"=>"N/A", "Actors"=>"Harrison Ford, Alec Guinness, Mark Hamill, James Earl Jones", "Plot"=>"N/A", "Language"=>"English", "Country"=>"USA", "Awards"=>"N/A", "Poster"=>"N/A", "Metascore"=>"N/A", "imdbRating"=>"7.3", "imdbVotes"=>"292", "imdbID"=>"tt0251413", "Type"=>"game", "Response"=>"True"}
|
@@ -50,10 +67,22 @@ OMDBGateway.gateway.title_search('Star Wars').body.class
|
|
50
67
|
|
51
68
|
##Free Text Search
|
52
69
|
|
53
|
-
Returns an array of items (chosen by OMDB) as Hashes
|
70
|
+
Returns a OMDBGateway::ResponseWrapper for an array of items (order chosen by OMDB) based on your search as Hashes
|
54
71
|
|
55
72
|
each with Title, Year, imdbID and Type fields
|
56
73
|
|
74
|
+
```
|
75
|
+
# Retrieves a movie or show based on its title.
|
76
|
+
#
|
77
|
+
# @param q [String] The search string
|
78
|
+
# @return [OMDBGateway::ResponseWrapper]
|
79
|
+
# @example
|
80
|
+
# free_search('Game')
|
81
|
+
def free_search(q)
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
57
86
|
```
|
58
87
|
|
59
88
|
OMDBGateway.gateway.free_search('Jedi')
|
@@ -108,7 +137,20 @@ OMDBGateway.gateway.free_search('Jedi').body
|
|
108
137
|
|
109
138
|
## Find By Id
|
110
139
|
|
111
|
-
Returns a single
|
140
|
+
Returns a OMDBGateway::ResponseWrapper for a single movie as a Hash with all available fields
|
141
|
+
|
142
|
+
```
|
143
|
+
|
144
|
+
# Retrieves a movie or show based on its IMDb ID.
|
145
|
+
#
|
146
|
+
# @param imdb_id [String] The IMDb ID of the movie or show.
|
147
|
+
# @param full_plot [Boolean] Full Plot data (default: false)
|
148
|
+
# @return [OMDBGateway::ResponseWrapper]
|
149
|
+
# @example
|
150
|
+
# find_by_id('tt0944947')
|
151
|
+
def find_by_id(imdb_id, full_plot = false, tomatoes = true)
|
152
|
+
|
153
|
+
```
|
112
154
|
|
113
155
|
|
114
156
|
```
|
@@ -248,4 +290,9 @@ If needed a default value can be specified, used if the key does not exist
|
|
248
290
|
OMDBGateway.gateway.free_search('Jedi').prune_array(1).prune_hash('Axiom', 123).body
|
249
291
|
=> 123
|
250
292
|
|
251
|
-
```
|
293
|
+
```
|
294
|
+
|
295
|
+
#History
|
296
|
+
__Note__ is a faraday rewrite of [Casey Scarborough's omdbapi](https://github.com/caseyscarborough/omdbapi)
|
297
|
+
|
298
|
+
Not that there's anything wrong with what he did, I just wanted to try faraday and we're using OMDB in our class
|
@@ -35,7 +35,7 @@ http_interactions:
|
|
35
35
|
Access-Control-Allow-Origin:
|
36
36
|
- "*"
|
37
37
|
Date:
|
38
|
-
-
|
38
|
+
- Sat, 19 Apr 2014 03:25:11 GMT
|
39
39
|
Content-Length:
|
40
40
|
- '417'
|
41
41
|
body:
|
@@ -44,7 +44,97 @@ http_interactions:
|
|
44
44
|
May 1983\",\"Runtime\":\"N/A\",\"Genre\":\"Action, Adventure, Sci-Fi\",\"Director\":\"N/A\",\"Writer\":\"N/A\",\"Actors\":\"Harrison
|
45
45
|
Ford, Alec Guinness, Mark Hamill, James Earl Jones\",\"Plot\":\"N/A\",\"Language\":\"English\",\"Country\":\"USA\",\"Awards\":\"N/A\",\"Poster\":\"N/A\",\"Metascore\":\"N/A\",\"imdbRating\":\"7.3\",\"imdbVotes\":\"292\",\"imdbID\":\"tt0251413\",\"Type\":\"game\",\"Response\":\"True\"}"
|
46
46
|
http_version:
|
47
|
-
recorded_at:
|
47
|
+
recorded_at: Sat, 19 Apr 2014 03:25:15 GMT
|
48
|
+
- request:
|
49
|
+
method: get
|
50
|
+
uri: http://omdbapi.com/?t=Star%20Wars&tomatoes=true&y=1983
|
51
|
+
body:
|
52
|
+
encoding: US-ASCII
|
53
|
+
string: ''
|
54
|
+
headers:
|
55
|
+
User-Agent:
|
56
|
+
- Faraday v0.8.9
|
57
|
+
Accept-Encoding:
|
58
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
59
|
+
Accept:
|
60
|
+
- "*/*"
|
61
|
+
response:
|
62
|
+
status:
|
63
|
+
code: 200
|
64
|
+
message: OK
|
65
|
+
headers:
|
66
|
+
Cache-Control:
|
67
|
+
- no-cache
|
68
|
+
Pragma:
|
69
|
+
- no-cache
|
70
|
+
Content-Type:
|
71
|
+
- text/html; charset=utf-8
|
72
|
+
Expires:
|
73
|
+
- "-1"
|
74
|
+
Server:
|
75
|
+
- Microsoft-IIS/7.5
|
76
|
+
X-Aspnet-Version:
|
77
|
+
- 4.0.30319
|
78
|
+
X-Powered-By:
|
79
|
+
- ASP.NET
|
80
|
+
Access-Control-Allow-Origin:
|
81
|
+
- "*"
|
82
|
+
Date:
|
83
|
+
- Sat, 19 Apr 2014 03:25:12 GMT
|
84
|
+
Content-Length:
|
85
|
+
- '705'
|
86
|
+
body:
|
87
|
+
encoding: UTF-8
|
88
|
+
string: "{\"Title\":\"Star Wars\",\"Year\":\"1983\",\"Rated\":\"N/A\",\"Released\":\"01
|
89
|
+
May 1983\",\"Runtime\":\"N/A\",\"Genre\":\"Action, Adventure, Sci-Fi\",\"Director\":\"N/A\",\"Writer\":\"N/A\",\"Actors\":\"Harrison
|
90
|
+
Ford, Alec Guinness, Mark Hamill, James Earl Jones\",\"Plot\":\"N/A\",\"Language\":\"English\",\"Country\":\"USA\",\"Awards\":\"N/A\",\"Poster\":\"N/A\",\"Metascore\":\"N/A\",\"imdbRating\":\"7.3\",\"imdbVotes\":\"292\",\"imdbID\":\"tt0251413\",\"Type\":\"game\",\"tomatoMeter\":\"N/A\",\"tomatoImage\":\"N/A\",\"tomatoRating\":\"N/A\",\"tomatoReviews\":\"N/A\",\"tomatoFresh\":\"N/A\",\"tomatoRotten\":\"N/A\",\"tomatoConsensus\":\"N/A\",\"tomatoUserMeter\":\"N/A\",\"tomatoUserRating\":\"N/A\",\"tomatoUserReviews\":\"N/A\",\"DVD\":\"N/A\",\"BoxOffice\":\"N/A\",\"Production\":\"N/A\",\"Website\":\"N/A\",\"Response\":\"True\"}"
|
91
|
+
http_version:
|
92
|
+
recorded_at: Sat, 19 Apr 2014 03:25:15 GMT
|
93
|
+
- request:
|
94
|
+
method: get
|
95
|
+
uri: http://omdbapi.com/?plot=full&t=Star%20Wars&y=1983
|
96
|
+
body:
|
97
|
+
encoding: US-ASCII
|
98
|
+
string: ''
|
99
|
+
headers:
|
100
|
+
User-Agent:
|
101
|
+
- Faraday v0.8.9
|
102
|
+
Accept-Encoding:
|
103
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
104
|
+
Accept:
|
105
|
+
- "*/*"
|
106
|
+
response:
|
107
|
+
status:
|
108
|
+
code: 200
|
109
|
+
message: OK
|
110
|
+
headers:
|
111
|
+
Cache-Control:
|
112
|
+
- no-cache
|
113
|
+
Pragma:
|
114
|
+
- no-cache
|
115
|
+
Content-Type:
|
116
|
+
- text/html; charset=utf-8
|
117
|
+
Expires:
|
118
|
+
- "-1"
|
119
|
+
Server:
|
120
|
+
- Microsoft-IIS/7.5
|
121
|
+
X-Aspnet-Version:
|
122
|
+
- 4.0.30319
|
123
|
+
X-Powered-By:
|
124
|
+
- ASP.NET
|
125
|
+
Access-Control-Allow-Origin:
|
126
|
+
- "*"
|
127
|
+
Date:
|
128
|
+
- Sat, 19 Apr 2014 03:25:12 GMT
|
129
|
+
Content-Length:
|
130
|
+
- '417'
|
131
|
+
body:
|
132
|
+
encoding: UTF-8
|
133
|
+
string: "{\"Title\":\"Star Wars\",\"Year\":\"1983\",\"Rated\":\"N/A\",\"Released\":\"01
|
134
|
+
May 1983\",\"Runtime\":\"N/A\",\"Genre\":\"Action, Adventure, Sci-Fi\",\"Director\":\"N/A\",\"Writer\":\"N/A\",\"Actors\":\"Harrison
|
135
|
+
Ford, Alec Guinness, Mark Hamill, James Earl Jones\",\"Plot\":\"N/A\",\"Language\":\"English\",\"Country\":\"USA\",\"Awards\":\"N/A\",\"Poster\":\"N/A\",\"Metascore\":\"N/A\",\"imdbRating\":\"7.3\",\"imdbVotes\":\"292\",\"imdbID\":\"tt0251413\",\"Type\":\"game\",\"Response\":\"True\"}"
|
136
|
+
http_version:
|
137
|
+
recorded_at: Sat, 19 Apr 2014 03:25:16 GMT
|
48
138
|
- request:
|
49
139
|
method: get
|
50
140
|
uri: http://omdbapi.com/?t=True%20Grit
|
@@ -80,7 +170,7 @@ http_interactions:
|
|
80
170
|
Access-Control-Allow-Origin:
|
81
171
|
- "*"
|
82
172
|
Date:
|
83
|
-
-
|
173
|
+
- Sat, 19 Apr 2014 03:25:12 GMT
|
84
174
|
Content-Length:
|
85
175
|
- '737'
|
86
176
|
body:
|
@@ -93,7 +183,7 @@ http_interactions:
|
|
93
183
|
woman track down her father's murderer.\",\"Language\":\"English\",\"Country\":\"USA\",\"Awards\":\"Nominated
|
94
184
|
for 10 Oscars. Another 31 wins & 85 nominations.\",\"Poster\":\"http://ia.media-imdb.com/images/M/MV5BMjIxNjAzODQ0N15BMl5BanBnXkFtZTcwODY2MjMyNA@@._V1_SX300.jpg\",\"Metascore\":\"80\",\"imdbRating\":\"7.7\",\"imdbVotes\":\"186,806\",\"imdbID\":\"tt1403865\",\"Type\":\"movie\",\"Response\":\"True\"}"
|
95
185
|
http_version:
|
96
|
-
recorded_at:
|
186
|
+
recorded_at: Sat, 19 Apr 2014 03:25:16 GMT
|
97
187
|
- request:
|
98
188
|
method: get
|
99
189
|
uri: http://omdbapi.com/?t=True%20Grit&y=1969
|
@@ -129,7 +219,7 @@ http_interactions:
|
|
129
219
|
Access-Control-Allow-Origin:
|
130
220
|
- "*"
|
131
221
|
Date:
|
132
|
-
-
|
222
|
+
- Sat, 19 Apr 2014 03:25:12 GMT
|
133
223
|
Content-Length:
|
134
224
|
- '745'
|
135
225
|
body:
|
@@ -142,7 +232,7 @@ http_interactions:
|
|
142
232
|
father's murderer in Indian territory.\",\"Language\":\"English\",\"Country\":\"USA\",\"Awards\":\"Won
|
143
233
|
1 Oscar. Another 7 wins & 5 nominations.\",\"Poster\":\"http://ia.media-imdb.com/images/M/MV5BMTYwNTE3NDYzOV5BMl5BanBnXkFtZTcwNTU5MzY0MQ@@._V1_SX300.jpg\",\"Metascore\":\"N/A\",\"imdbRating\":\"7.4\",\"imdbVotes\":\"26,792\",\"imdbID\":\"tt0065126\",\"Type\":\"movie\",\"Response\":\"True\"}"
|
144
234
|
http_version:
|
145
|
-
recorded_at:
|
235
|
+
recorded_at: Sat, 19 Apr 2014 03:25:16 GMT
|
146
236
|
- request:
|
147
237
|
method: get
|
148
238
|
uri: http://omdbapi.com/?t=Game%20of%20Thrones
|
@@ -178,7 +268,7 @@ http_interactions:
|
|
178
268
|
Access-Control-Allow-Origin:
|
179
269
|
- "*"
|
180
270
|
Date:
|
181
|
-
-
|
271
|
+
- Sat, 19 Apr 2014 03:25:13 GMT
|
182
272
|
Content-Length:
|
183
273
|
- '693'
|
184
274
|
body:
|
@@ -201,7 +291,7 @@ http_interactions:
|
|
201
291
|
MjksNDgyIiwiaW1kYklEIjoidHQwOTQ0OTQ3IiwiVHlwZSI6InNlcmllcyIs
|
202
292
|
IlJlc3BvbnNlIjoiVHJ1ZSJ9
|
203
293
|
http_version:
|
204
|
-
recorded_at:
|
294
|
+
recorded_at: Sat, 19 Apr 2014 03:25:17 GMT
|
205
295
|
- request:
|
206
296
|
method: get
|
207
297
|
uri: http://omdbapi.com/?plot=full&t=Game%20of%20Thrones
|
@@ -237,7 +327,7 @@ http_interactions:
|
|
237
327
|
Access-Control-Allow-Origin:
|
238
328
|
- "*"
|
239
329
|
Date:
|
240
|
-
-
|
330
|
+
- Sat, 19 Apr 2014 03:25:14 GMT
|
241
331
|
Content-Length:
|
242
332
|
- '1588'
|
243
333
|
body:
|
@@ -280,7 +370,7 @@ http_interactions:
|
|
280
370
|
MiIsImltZGJJRCI6InR0MDk0NDk0NyIsIlR5cGUiOiJzZXJpZXMiLCJSZXNw
|
281
371
|
b25zZSI6IlRydWUifQ==
|
282
372
|
http_version:
|
283
|
-
recorded_at:
|
373
|
+
recorded_at: Sat, 19 Apr 2014 03:25:18 GMT
|
284
374
|
- request:
|
285
375
|
method: get
|
286
376
|
uri: http://omdbapi.com/?t=lsdfoweirjrpwef323423dsfkip
|
@@ -316,17 +406,17 @@ http_interactions:
|
|
316
406
|
Access-Control-Allow-Origin:
|
317
407
|
- "*"
|
318
408
|
Date:
|
319
|
-
-
|
409
|
+
- Sat, 19 Apr 2014 03:25:14 GMT
|
320
410
|
Content-Length:
|
321
411
|
- '47'
|
322
412
|
body:
|
323
413
|
encoding: UTF-8
|
324
414
|
string: "{\"Response\":\"False\",\"Error\":\"Movie not found!\"}"
|
325
415
|
http_version:
|
326
|
-
recorded_at:
|
416
|
+
recorded_at: Sat, 19 Apr 2014 03:25:18 GMT
|
327
417
|
- request:
|
328
418
|
method: get
|
329
|
-
uri: http://omdbapi.com/?i=tt0411008
|
419
|
+
uri: http://omdbapi.com/?i=tt0411008&tomatoes=true
|
330
420
|
body:
|
331
421
|
encoding: US-ASCII
|
332
422
|
string: ''
|
@@ -359,9 +449,9 @@ http_interactions:
|
|
359
449
|
Access-Control-Allow-Origin:
|
360
450
|
- "*"
|
361
451
|
Date:
|
362
|
-
-
|
452
|
+
- Sat, 19 Apr 2014 03:25:15 GMT
|
363
453
|
Content-Length:
|
364
|
-
- '
|
454
|
+
- '1172'
|
365
455
|
body:
|
366
456
|
encoding: ASCII-8BIT
|
367
457
|
string: !binary |-
|
@@ -383,12 +473,20 @@ http_interactions:
|
|
383
473
|
bDVCYW5CblhrRnRaVGN3TmpjMU9EVXdNZ0BALl9WMV9TWDMwMC5qcGciLCJN
|
384
474
|
ZXRhc2NvcmUiOiJOL0EiLCJpbWRiUmF0aW5nIjoiOC42IiwiaW1kYlZvdGVz
|
385
475
|
IjoiMjcxLDg0MiIsImltZGJJRCI6InR0MDQxMTAwOCIsIlR5cGUiOiJzZXJp
|
386
|
-
|
476
|
+
ZXMiLCJ0b21hdG9NZXRlciI6IjgwIiwidG9tYXRvSW1hZ2UiOiJmcmVzaCIs
|
477
|
+
InRvbWF0b1JhdGluZyI6IjYuMiIsInRvbWF0b1Jldmlld3MiOiI1IiwidG9t
|
478
|
+
YXRvRnJlc2giOiI0IiwidG9tYXRvUm90dGVuIjoiMSIsInRvbWF0b0NvbnNl
|
479
|
+
bnN1cyI6Ik4vQSIsInRvbWF0b1VzZXJNZXRlciI6IjcyIiwidG9tYXRvVXNl
|
480
|
+
clJhdGluZyI6IjMuNyIsInRvbWF0b1VzZXJSZXZpZXdzIjoiNCwyOTgiLCJE
|
481
|
+
VkQiOiIxNCBNYXIgMjAwNiIsIkJveE9mZmljZSI6Ik4vQSIsIlByb2R1Y3Rp
|
482
|
+
b24iOiJTaWx2ZXJDcmVzdCBFbnRlcnRhaW5tZW50IiwiV2Vic2l0ZSI6Imh0
|
483
|
+
dHA6Ly93d3cubG9zdC10aGVtb3ZpZS5jb20vIiwiUmVzcG9uc2UiOiJUcnVl
|
484
|
+
In0=
|
387
485
|
http_version:
|
388
|
-
recorded_at:
|
486
|
+
recorded_at: Sat, 19 Apr 2014 03:25:19 GMT
|
389
487
|
- request:
|
390
488
|
method: get
|
391
|
-
uri: http://omdbapi.com/?i=tt1231230123
|
489
|
+
uri: http://omdbapi.com/?i=tt1231230123&tomatoes=true
|
392
490
|
body:
|
393
491
|
encoding: US-ASCII
|
394
492
|
string: ''
|
@@ -421,14 +519,14 @@ http_interactions:
|
|
421
519
|
Access-Control-Allow-Origin:
|
422
520
|
- "*"
|
423
521
|
Date:
|
424
|
-
-
|
522
|
+
- Sat, 19 Apr 2014 03:25:15 GMT
|
425
523
|
Content-Length:
|
426
524
|
- '48'
|
427
525
|
body:
|
428
526
|
encoding: UTF-8
|
429
527
|
string: "{\"Response\":\"False\",\"Error\":\"Incorrect IMDb ID\"}"
|
430
528
|
http_version:
|
431
|
-
recorded_at:
|
529
|
+
recorded_at: Sat, 19 Apr 2014 03:25:19 GMT
|
432
530
|
- request:
|
433
531
|
method: get
|
434
532
|
uri: http://omdbapi.com/?s=Star%20Wars
|
@@ -464,7 +562,7 @@ http_interactions:
|
|
464
562
|
Access-Control-Allow-Origin:
|
465
563
|
- "*"
|
466
564
|
Date:
|
467
|
-
-
|
565
|
+
- Sat, 19 Apr 2014 03:25:16 GMT
|
468
566
|
Content-Length:
|
469
567
|
- '1009'
|
470
568
|
body:
|
@@ -494,7 +592,7 @@ http_interactions:
|
|
494
592
|
YXkgU3BlY2lhbCIsIlllYXIiOiIxOTc4IiwiaW1kYklEIjoidHQwMTkzNTI0
|
495
593
|
IiwiVHlwZSI6Im1vdmllIn1dfQ==
|
496
594
|
http_version:
|
497
|
-
recorded_at:
|
595
|
+
recorded_at: Sat, 19 Apr 2014 03:25:20 GMT
|
498
596
|
- request:
|
499
597
|
method: get
|
500
598
|
uri: http://omdbapi.com/?s=Star%20Wars:%20Episode%20VI%20-%20Return%20of%20the%20Jedi
|
@@ -530,14 +628,14 @@ http_interactions:
|
|
530
628
|
Access-Control-Allow-Origin:
|
531
629
|
- "*"
|
532
630
|
Date:
|
533
|
-
-
|
631
|
+
- Sat, 19 Apr 2014 03:25:17 GMT
|
534
632
|
Content-Length:
|
535
633
|
- '117'
|
536
634
|
body:
|
537
635
|
encoding: UTF-8
|
538
636
|
string: "{\"Search\":[{\"Title\":\"Star Wars: Episode VI - Return of the Jedi\",\"Year\":\"1983\",\"imdbID\":\"tt0086190\",\"Type\":\"movie\"}]}"
|
539
637
|
http_version:
|
540
|
-
recorded_at:
|
638
|
+
recorded_at: Sat, 19 Apr 2014 03:25:20 GMT
|
541
639
|
- request:
|
542
640
|
method: get
|
543
641
|
uri: http://omdbapi.com/?s=lsdfoweirjrpwef323423dsfkip
|
@@ -573,12 +671,12 @@ http_interactions:
|
|
573
671
|
Access-Control-Allow-Origin:
|
574
672
|
- "*"
|
575
673
|
Date:
|
576
|
-
-
|
674
|
+
- Sat, 19 Apr 2014 03:25:17 GMT
|
577
675
|
Content-Length:
|
578
676
|
- '47'
|
579
677
|
body:
|
580
678
|
encoding: UTF-8
|
581
679
|
string: "{\"Response\":\"False\",\"Error\":\"Movie not found!\"}"
|
582
680
|
http_version:
|
583
|
-
recorded_at:
|
681
|
+
recorded_at: Sat, 19 Apr 2014 03:25:21 GMT
|
584
682
|
recorded_with: VCR 2.9.0
|
data/lib/omdbgateway/gateway.rb
CHANGED
@@ -29,18 +29,19 @@ module OMDBGateway
|
|
29
29
|
end
|
30
30
|
|
31
31
|
|
32
|
-
# Retrieves a movie or show based on its title.
|
32
|
+
# Retrieves a single movie or show based on its title.
|
33
33
|
#
|
34
34
|
# @param title [String] The title of the movie or show.
|
35
35
|
# @param year [String] The year of the movie or show.
|
36
|
-
# @param
|
37
|
-
# @return [
|
36
|
+
# @param full_plot [Boolean] Full Plot data (default: false)
|
37
|
+
# @return [OMDBGateway::ResponseWrapper]
|
38
38
|
# @example
|
39
39
|
# title_search('Game of Thrones')
|
40
|
-
def title_search(title, year = nil,
|
40
|
+
def title_search(title, year = nil, full_plot = false, tomatoes = false)
|
41
41
|
response = get '/' do |req|
|
42
42
|
req.params = {:t => title}
|
43
|
-
req.params[:plot] =
|
43
|
+
req.params[:plot] = 'full' if (full_plot == true || 'full' == full_plot)
|
44
|
+
req.params[:tomatoes] = 'true' if tomatoes
|
44
45
|
req.params[:y] = year unless year.nil?
|
45
46
|
end
|
46
47
|
# Middleware creates the Hash
|
@@ -50,7 +51,7 @@ module OMDBGateway
|
|
50
51
|
# Retrieves a movie or show based on its title.
|
51
52
|
#
|
52
53
|
# @param q [String] The search string
|
53
|
-
# @return [
|
54
|
+
# @return [OMDBGateway::ResponseWrapper]
|
54
55
|
# @example
|
55
56
|
# free_search('Game')
|
56
57
|
def free_search(q)
|
@@ -61,15 +62,18 @@ module OMDBGateway
|
|
61
62
|
end
|
62
63
|
|
63
64
|
|
64
|
-
# Retrieves a movie or show based on its IMDb ID.
|
65
|
+
# Retrieves a single movie or show based on its IMDb ID.
|
65
66
|
#
|
66
67
|
# @param imdb_id [String] The IMDb ID of the movie or show.
|
67
|
-
# @
|
68
|
+
# @param full_plot [Boolean] Full Plot data (default: false)
|
69
|
+
# @return [OMDBGateway::ResponseWrapper]
|
68
70
|
# @example
|
69
71
|
# find_by_id('tt0944947')
|
70
|
-
def find_by_id(imdb_id)
|
72
|
+
def find_by_id(imdb_id, full_plot = false, tomatoes = true)
|
71
73
|
response = get '/' do |req|
|
72
74
|
req.params = {:i => imdb_id}
|
75
|
+
req.params[:plot] = 'full' if (full_plot == true || 'full' == full_plot)
|
76
|
+
req.params[:tomatoes] = 'true' if tomatoes
|
73
77
|
end
|
74
78
|
response
|
75
79
|
end
|
data/omdbgateway.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "omdbgateway"
|
7
|
-
spec.version = '0.0
|
7
|
+
spec.version = '0.1.0'
|
8
8
|
spec.authors = ["Stuart Jones"]
|
9
9
|
spec.email = ["omdbgateway@skillbox.com"]
|
10
10
|
spec.description = 'A simple API Service Gateway for the omdb omdbapi.com movie API. Supporting error handling and result pruning'
|
data/rspec_output.txt
CHANGED
@@ -23,6 +23,9 @@ OMDBGateway::Gateway
|
|
23
23
|
with a movie that exists
|
24
24
|
should return a hash of movie attributes
|
25
25
|
should contain a title
|
26
|
+
should have tomatoes
|
27
|
+
should contain a not have tomatoes
|
28
|
+
should have a longer plot
|
26
29
|
with the year parameter
|
27
30
|
should not be the same title
|
28
31
|
with the plot parameter
|
@@ -86,5 +89,5 @@ OMDBGateway::ResponseWrapper
|
|
86
89
|
should be nil for empty array
|
87
90
|
should be {'a' => 'A', 'b' => 'B'} for any array
|
88
91
|
|
89
|
-
Finished in 0.
|
90
|
-
|
92
|
+
Finished in 0.27338 seconds
|
93
|
+
55 examples, 0 failures
|
@@ -72,6 +72,12 @@ module OMDBGateway
|
|
72
72
|
let(:title_results) do
|
73
73
|
gateway.title_search('Star Wars')
|
74
74
|
end
|
75
|
+
let(:title_results_with_full_plot) do
|
76
|
+
gateway.title_search('Star Wars',1983,true)
|
77
|
+
end
|
78
|
+
let(:title_results_with_tomatoes) do
|
79
|
+
gateway.title_search('Star Wars',1983,false,true)
|
80
|
+
end
|
75
81
|
|
76
82
|
it 'should return a hash of movie attributes' do
|
77
83
|
title_results.should be_instance_of ResponseWrapper
|
@@ -80,6 +86,18 @@ module OMDBGateway
|
|
80
86
|
it 'should contain a title' do
|
81
87
|
title_results.as_hash['Title'].should be_instance_of String
|
82
88
|
end
|
89
|
+
|
90
|
+
it 'should have tomatoes' do
|
91
|
+
title_results_with_tomatoes.as_hash['tomatoMeter'].should be_instance_of String
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should contain a not have tomatoes' do
|
95
|
+
title_results.as_hash['tomatoMeter'].should eq nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should have a longer plot' do
|
99
|
+
title_results_with_full_plot.prune_hash('Plot','').body.length.should be >= title_results.prune_hash('Plot','').body.length
|
100
|
+
end
|
83
101
|
end
|
84
102
|
|
85
103
|
describe 'with the year parameter' do
|
@@ -93,7 +111,7 @@ module OMDBGateway
|
|
93
111
|
|
94
112
|
describe 'with the plot parameter' do
|
95
113
|
let(:title_results1) { gateway.title_search('Game of Thrones') }
|
96
|
-
let(:title_results2) { gateway.title_search('Game of Thrones', nil,
|
114
|
+
let(:title_results2) { gateway.title_search('Game of Thrones', nil, true) }
|
97
115
|
|
98
116
|
it 'should have different plots' do
|
99
117
|
title_results1.as_hash['Plot'].should_not eq(title_results2.as_hash['Plot'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omdbgateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|