omdbgateway 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +222 -3
  3. data/omdbgateway.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a46174ace209ba204b58b9c2b44fe4d20dba0fa
4
- data.tar.gz: 1212431d4abb77057a87dec2829daef71699b8a9
3
+ metadata.gz: 254627c1759f41572abe59b8214e217bdf062fc9
4
+ data.tar.gz: bf3fc197a029e2d067f3cb935f87992d8426683c
5
5
  SHA512:
6
- metadata.gz: 6c70e35a8330128ef658fef99457c4bdad4d9565fb1578c2220559b2ad2741d3bbd16e9acab916eeb3314cc576b4e0fede91c539999c717199d327e1e64da9ca
7
- data.tar.gz: 614ce6faa7bbc5728eb6f09b740cef00e11bfba78a42a2cd5530f9cabdbd14cfbacab625e603c5bcae09064b981103b9db2e0ee3949a20785b1b69307b724da8
6
+ metadata.gz: 279b29af440644685b6c7d2be30663157bf8cf3ac7253fddc85d4d1977af97a04ed63ddfeab784fa27d9d25fef684d0d9aa79cf40b096225d5bfc81f928cafed
7
+ data.tar.gz: 8230c5e47aa8f1d742e93c749e6a6012f47c86a259c13363c7bf291566a98cfe38b6ef4643ffbca5664c4c3e010bb302fcfdef31b88c8be082b105f58d3915ce
data/README.md CHANGED
@@ -1,14 +1,233 @@
1
1
  # omdbgateway
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/omdbgateway.svg)](http://badge.fury.io/rb/omdbgateway)
3
4
 
4
- OMDBGateway is not a supported Gem at this time
5
-
6
- It is a faraday rewrite of [Casey Scarborough's omdbapi](https://github.com/caseyscarborough/omdbapi)
5
+ __Note__ is a faraday rewrite of [Casey Scarborough's omdbapi](https://github.com/caseyscarborough/omdbapi)
7
6
 
8
7
  Not that there's anything wrong with what he did, I just wanted to try faraday and we're using OMDB
9
8
  in our class
10
9
 
10
+ ##Usage
11
+
12
+
13
+ ##Title Search
14
+
15
+ Returns a single item (chosen by OMDB) as a Hash
16
+
17
+ ```
18
+
19
+ require 'omdbgateway'
20
+
21
+ OMDBGateway.gateway.title_search('Star Wars')
22
+ => #<OMDBGateway::ResponseWrapper:0x00000101ca5218 @http_status=200, @body={"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"}, app_failedfalse
23
+
24
+ OMDBGateway.gateway.title_search('Star Wars').body
25
+ => {"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"}
26
+
27
+ OMDBGateway.gateway.title_search('Star Wars').body.class
28
+ => Hash
29
+
30
+ ```
31
+
32
+
33
+ ##Free Text Search
34
+
35
+ Returns an array of items (chosen by OMDB) as Hashes
36
+
37
+ each with Title, Year, imdbID and Type fields
38
+
39
+ ```
40
+
41
+ OMDBGateway.gateway.free_search('Jedi')
42
+ => #<OMDBGateway::ResponseWrapper:0x00000102167440 @http_status=200, @body=[{"Title"=>"Star Wars: Episode VI - Return of the Jedi", "Year"=>"1983", "imdbID"=>"tt0086190", "Type"=>"movie"}, {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast", "Year"=>"2002", "imdbID"=>"tt0297410", "Type"=>"game"}, {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast", "Year"=>"2002", "imdbID"=>"tt0297410", "Type"=>"game"}, {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast", "Year"=>"2002", "imdbID"=>"tt0297410", "Type"=>"game"}, {"Title"=>"Star Wars: Jedi Knight - Jedi Academy", "Year"=>"2003", "imdbID"=>"tt0362179", "Type"=>"game"}, {"Title"=>"Star Wars: Jedi Knight - Dark Forces II", "Year"=>"1997", "imdbID"=>"tt0160910", "Type"=>"game"}, {"Title"=>"From 'Star Wars' to 'Jedi': The Making of a Saga", "Year"=>"1983", "imdbID"=>"tt0295270", "Type"=>"movie"}, {"Title"=>"The Wrong Jedi", "Year"=>"2013", "imdbID"=>"tt2628854", "Type"=>"episode"}, {"Title"=>"Bombad Jedi", "Year"=>"2008", "imdbID"=>"tt1322836", "Type"=>"episode"}, {"Title"=>"Jedi Junkies", "Year"=>"2010", "imdbID"=>"tt1662514", "Type"=>"movie"}], app_failedfalse
43
+
44
+
45
+ OMDBGateway.gateway.free_search('Jedi').body
46
+ => [
47
+ {"Title"=>"Star Wars: Episode VI - Return of the Jedi",
48
+ "Year"=>"1983",
49
+ "imdbID"=>"tt0086190",
50
+ "Type"=>"movie"},
51
+ {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast",
52
+ "Year"=>"2002",
53
+ "imdbID"=>"tt0297410",
54
+ "Type"=>"game"},
55
+ {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast",
56
+ "Year"=>"2002",
57
+ "imdbID"=>"tt0297410",
58
+ "Type"=>"game"},
59
+ {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast",
60
+ "Year"=>"2002",
61
+ "imdbID"=>"tt0297410",
62
+ "Type"=>"game"},
63
+ {"Title"=>"Star Wars: Jedi Knight - Jedi Academy",
64
+ "Year"=>"2003",
65
+ "imdbID"=>"tt0362179",
66
+ "Type"=>"game"},
67
+ {"Title"=>"Star Wars: Jedi Knight - Dark Forces II",
68
+ "Year"=>"1997",
69
+ "imdbID"=>"tt0160910",
70
+ "Type"=>"game"},
71
+ {"Title"=>"From 'Star Wars' to 'Jedi': The Making of a Saga",
72
+ "Year"=>"1983",
73
+ "imdbID"=>"tt0295270",
74
+ "Type"=>"movie"},
75
+ {"Title"=>"The Wrong Jedi",
76
+ "Year"=>"2013",
77
+ "imdbID"=>"tt2628854",
78
+ "Type"=>"episode"},
79
+ {"Title"=>"Bombad Jedi",
80
+ "Year"=>"2008",
81
+ "imdbID"=>"tt1322836",
82
+ "Type"=>"episode"},
83
+ {"Title"=>"Jedi Junkies",
84
+ "Year"=>"2010",
85
+ "imdbID"=>"tt1662514",
86
+ "Type"=>"movie"}
87
+ ]
88
+
89
+ ```
90
+
91
+ ## Find By Id
92
+
93
+ Returns a single item as a Hash with all available fields
94
+
95
+
96
+ ```
97
+
98
+ OMDBGateway.gateway.find_by_id('tt0297410').body
99
+ =>{
100
+ "Title"=>"Star Wars: Jedi Knight II - Jedi Outcast",
101
+ "Year"=>"2002",
102
+ "Rated"=>"N/A",
103
+ "Released"=>"29 Mar 2002",
104
+ "Runtime"=>"N/A",
105
+ "Genre"=>"Action, Adventure, Fantasy",
106
+ "Director"=>"N/A",
107
+ "Writer"=>"Kenn Hoekstra (manual), Michael Stemmle (script)",
108
+ "Actors"=>
109
+ "Jeff Bennett, Mark Klastorin, Billy Dee Williams, Vanessa Marshall",
110
+ "Plot"=>
111
+ "You guide mercenary Kyle Katarn, who must stop the evil plot of a renegade Jedi by relearning his skills as a Jedi Knight.",
112
+ "Language"=>"English",
113
+ "Country"=>"USA",
114
+ "Awards"=>"N/A",
115
+ "Poster"=>"N/A",
116
+ "Metascore"=>"N/A",
117
+ "imdbRating"=>"8.3",
118
+ "imdbVotes"=>"1,000",
119
+ "imdbID"=>"tt0297410",
120
+ "Type"=>"game",
121
+ "Response"=>"True"
122
+ }
123
+ ```
124
+
125
+
126
+
127
+ ## Error States
128
+
129
+ ### success?
130
+
131
+ ```
132
+ # An failed request, returns false for success?
133
+
134
+ OMDBGateway.gateway.find_by_id('tt0297CCC').success?
135
+ => false
136
+
137
+ # An successful request, returns true for success?
138
+
139
+ OMDBGateway.gateway.find_by_id('tt1322836').success?
140
+ => true
141
+
142
+ ```
143
+
144
+
145
+ ### app_success?
146
+
147
+ If you need to know if the app (The omdbapi.com service) was successfully called
148
+ and then failed or succeeded to successfully process the input then use app_success?
149
+
150
+ ```
151
+ # An failed request, returns false for app_success?
152
+
153
+ OMDBGateway.gateway.find_by_id('tt0297CCC').app_success?
154
+ => false
155
+
156
+ # An successful request, returns true for app_success?
157
+
158
+ OMDBGateway.gateway.find_by_id('tt1322836').app_success?
159
+ => true
160
+
161
+ ```
162
+
163
+ ### http_success?
164
+
165
+ If you need to know if the transport failed, use http_success?
166
+
167
+ ```
168
+ #Transport succeeded but the app returned a failure
169
+
170
+ OMDBGateway.gateway.find_by_id('tt0297CCC').http_success?
171
+ => true
172
+
173
+ ```
174
+
175
+
176
+
177
+
178
+
179
+ ## Result Pruning
180
+
181
+ Sometimes you don't want the whole result body, you just want a single tag or index
182
+
183
+ ```
184
+ #All the data
185
+
186
+ OMDBGateway.gateway.find_by_id('tt1322836').body
187
+ => {"Title"=>"Bombad Jedi", "Year"=>"2008", "Rated"=>"N/A", "Released"=>"N/A", "Runtime"=>"22 min", "Genre"=>"Animation, Action, Adventure, Drama, Fantasy, Sci-Fi", "Director"=>"Dave Filoni", "Writer"=>"George Lucas, Steven Melching", "Actors"=>"Anthony Daniels, Ahmed Best, Catherine Taber, Matthew Wood", "Plot"=>"Padmé Amidala travels to Rodia to meet with old family friend Onaconda Farr about the lack of food rations...", "Language"=>"N/A", "Country"=>"N/A", "Awards"=>"N/A", "Poster"=>"http://ia.media-imdb.com/images/M/MV5BMTM0NjQ2Mjk0OV5BMl5BanBnXkFtZTcwODQ3Njc3Mg@@._V1_SX300.jpg", "Metascore"=>"N/A", "imdbRating"=>"6.8", "imdbVotes"=>"265", "imdbID"=>"tt1322836", "Type"=>"episode", "Response"=>"True"}
188
+
189
+ ```
190
+
191
+ ## prune_hash(tag)
192
+
193
+ ```
194
+ #Just the Poster value
195
+
196
+ OMDBGateway.gateway.find_by_id('tt1322836').prune_hash('Poster').body
197
+ => "http://ia.media-imdb.com/images/M/MV5BMTM0NjQ2Mjk0OV5BMl5BanBnXkFtZTcwODQ3Njc3Mg@@._V1_SX300.jpg"
198
+
199
+
200
+ ```
201
+
202
+ ## prune_array(index)
203
+
204
+ ```
205
+ #Just the 2nd result
206
+
207
+ OMDBGateway.gateway.free_search('Jedi').prune_array(1).body
208
+ => {"Title"=>"Star Wars: Jedi Knight II - Jedi Outcast", "Year"=>"2002", "imdbID"=>"tt0297410", "Type"=>"game"}
209
+
210
+ ```
211
+
212
+ ## prune_xxx chaining
213
+
214
+ If needed prune methods can be chained
215
+
216
+ ```
217
+
218
+ OMDBGateway.gateway.free_search('Jedi').prune_array(1).prune_hash('Year').body
219
+ => "2002"
220
+
221
+ ```
222
+
223
+
224
+ ## prune_xxx default
11
225
 
226
+ If needed a default value can be specified, used if the key does not exist
12
227
 
228
+ ```
13
229
 
230
+ OMDBGateway.gateway.free_search('Jedi').prune_array(1).prune_hash('Axiom', 123).body
231
+ => 123
14
232
 
233
+ ```
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.1'
7
+ spec.version = '0.0.2'
8
8
  spec.authors = ["Stuart Jones"]
9
9
  spec.email = ["omdbgateway@skillbox.com"]
10
10
  spec.description = 'A Service Gateway for the omdbapi.com movie API.'
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.1
4
+ version: 0.0.2
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-17 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler