omdbapi 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/README.md +22 -3
- data/lib/omdbapi/client.rb +8 -3
- data/lib/omdbapi/version.rb +1 -1
- data/omdbapi.gemspec +2 -1
- data/spec/omdbapi/client_spec.rb +109 -0
- data/spec/omdbapi/default_spec.rb +19 -0
- data/spec/spec_helper.rb +13 -0
- metadata +24 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fbc5708989f9d4a0c3238cba60519c45c660db3
|
4
|
+
data.tar.gz: 5ff47e43fe3546e7cc99861ae6596ffcf78c3a2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 817dcd802df11328e12d0970d74424fc19b33bb8f1a10d61b2927eb79b70253035568a81e23cbe8450d4aef54eecde63efbc2be8d899009aabc36e79a3f663d8
|
7
|
+
data.tar.gz: 6568db143c86f0e038a5209882060063d49e151eb4c78e3f6e4a69cc44fc9b7cd7d72345e2e0942c6aad821682db5f4efa5568d7f6f579bce4dbcf16f17e8fe8
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/README.md
CHANGED
@@ -4,6 +4,12 @@ This gem is (will be) a simple and easy to use wrapper for the [omdbapi.com](htt
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
### Requirements
|
8
|
+
|
9
|
+
* Ruby v1.9.3 or later
|
10
|
+
|
11
|
+
### Installing
|
12
|
+
|
7
13
|
You can install the gem by adding it your application's Gemfile:
|
8
14
|
|
9
15
|
```ruby
|
@@ -49,12 +55,12 @@ This function will return a Hash with the following information about the title:
|
|
49
55
|
|
50
56
|
### Search
|
51
57
|
|
52
|
-
You can
|
58
|
+
You can find a title by using the find method:
|
53
59
|
|
54
60
|
```ruby
|
55
|
-
|
61
|
+
results = OMDB.find('Star Wars')
|
56
62
|
# => [{:title=>"Star Wars", :year=>"1977", :imdb_id=>"tt0076759", :type=>"movie"}, {:title=>"Star Wars: Episode V - The Empire Strikes Back", :year=>"1980", :imdb_id=>"tt0080684", :type=>"movie"}, {:title=>"Star Wars: Episode VI - Return of the Jedi", :year=>"1983", :imdb_id=>"tt0086190", :type=>"movie"}, {:title=>"Star Wars: Episode I - The Phantom Menace", :year=>"1999", :imdb_id=>"tt0120915", :type=>"movie"}, {:title=>"Star Wars: Episode III - Revenge of the Sith", :year=>"2005", :imdb_id=>"tt0121766", :type=>"movie"}, {:title=>"Star Wars: Episode II - Attack of the Clones", :year=>"2002", :imdb_id=>"tt0121765", :type=>"movie"}, {:title=>"Star Wars: The Clone Wars", :year=>"2008", :imdb_id=>"tt1185834", :type=>"movie"}, {:title=>"Star Wars: Clone Wars", :year=>"2003", :imdb_id=>"tt0361243", :type=>"series"}, {:title=>"Star Wars: The Clone Wars", :year=>"2008", :imdb_id=>"tt0458290", :type=>"series"}, {:title=>"The Star Wars Holiday Special", :year=>"1978", :imdb_id=>"tt0193524", :type=>"movie"}]
|
57
|
-
|
63
|
+
results.each { |r| puts r.title }
|
58
64
|
# etc...
|
59
65
|
```
|
60
66
|
|
@@ -64,6 +70,19 @@ This method returns an Array of search results. Each search result is a Hash wit
|
|
64
70
|
:title, :year, :imdb_id, :type
|
65
71
|
```
|
66
72
|
|
73
|
+
### Find by IMDb ID
|
74
|
+
|
75
|
+
You can find a title by it's IMDb id using the id method:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
lost = OMDB.id('tt0411008')
|
79
|
+
# => {:title=>"Lost", :year=>"2004", :rated=>"TV-14", :released=>"22 Sep 2004", :runtime=>"42 min", :genre=>"Adventure, Drama, Fantasy, Mystery, Sci-Fi, Thriller", :director=>"N/A", :writer=>"J.J. Abrams, Jeffrey Lieber", :actors=>"Matthew Fox, Jorge Garcia, Evangeline Lilly, Naveen Andrews", :plot=>"The survivors of a plane crash are forced to live with each other on a remote island, a dangerous new world that poses unique threats of its own.", :poster=>"http://ia.media-imdb.com/images/M/MV5BMjA3NzMyMzU1MV5BMl5BanBnXkFtZTcwNjc1ODUwMg@@._V1_SX300.jpg", :imdb_rating=>"8.3", :imdb_votes=>"160,182", :imdb_id=>"tt0411008", :type=>"series", :response=>"True"}
|
80
|
+
lost.released # => "22 Sep 2004"
|
81
|
+
lost.imdb_rating # => "8.3"
|
82
|
+
# etc...
|
83
|
+
```
|
84
|
+
|
85
|
+
This method will return a Hash of the title's properties, exactly as the title method.
|
67
86
|
|
68
87
|
## Contributing
|
69
88
|
|
data/lib/omdbapi/client.rb
CHANGED
@@ -4,12 +4,17 @@ module OMDB
|
|
4
4
|
include HTTParty
|
5
5
|
base_uri OMDB::Default::API_ENDPOINT
|
6
6
|
|
7
|
-
def title(title)
|
7
|
+
def title(title, year=nil)
|
8
8
|
get '/', { t: title }
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def id(imdb_id)
|
12
|
+
return get '/', { i: imdb_id }
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(title)
|
16
|
+
results = get '/', { s: title }
|
17
|
+
results[:search] ? results[:search] : results
|
13
18
|
end
|
14
19
|
|
15
20
|
private
|
data/lib/omdbapi/version.rb
CHANGED
data/omdbapi.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["caseyscarborough@gmail.com"]
|
11
11
|
spec.description = '[In Progress] A wrapper for the omdbapi.com movie API.'
|
12
12
|
spec.summary = 'This gem provides easy access for information retrieval from omdbapi.com.'
|
13
|
-
spec.homepage = "https://github.com/caseyscarborough/
|
13
|
+
spec.homepage = "https://github.com/caseyscarborough/omdbapi"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
23
24
|
spec.add_dependency 'httparty', '0.11.0'
|
24
25
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OMDB::Client do
|
4
|
+
|
5
|
+
it 'should include HTTParty' do
|
6
|
+
OMDB::Client.should include(HTTParty)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have the correct API endpoint' do
|
10
|
+
OMDB::Client.base_uri.should eq(OMDB::Default::API_ENDPOINT)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'methods' do
|
14
|
+
|
15
|
+
describe 'title' do
|
16
|
+
describe 'with a movie that exists' do
|
17
|
+
let(:title) { OMDB.title('Star Wars') }
|
18
|
+
|
19
|
+
it 'should return a hash of movie attributes' do
|
20
|
+
title.should be_instance_of Hash
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should contain a title' do
|
24
|
+
title.title.should be_instance_of String
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'with a movie that doesn''t exist' do
|
29
|
+
let(:title) { OMDB.title('lsdfoweirjrpwef323423dsfkip') }
|
30
|
+
|
31
|
+
it 'should return a hash' do
|
32
|
+
title.should be_instance_of Hash
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return a hash with a false response' do
|
36
|
+
title.response.should eq('False')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return a hash with an error message' do
|
40
|
+
title.error.should be_instance_of String
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'id' do
|
46
|
+
|
47
|
+
describe 'with a title that exists' do
|
48
|
+
let(:title) { OMDB.id('tt0411008') }
|
49
|
+
|
50
|
+
it 'should return a hash of movie attributes' do
|
51
|
+
title.should be_instance_of Hash
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should contain a title' do
|
55
|
+
title.title.should be_instance_of String
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'with a movie that doesn''t exist' do
|
60
|
+
let(:title) { OMDB.id('tt1231230123') }
|
61
|
+
|
62
|
+
it 'should return a hash' do
|
63
|
+
title.should be_instance_of Hash
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should return a hash with a false response' do
|
67
|
+
title.response.should eq('False')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should return a hash with an error message' do
|
71
|
+
title.error.should be_instance_of String
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'find' do
|
77
|
+
|
78
|
+
describe 'with search results' do
|
79
|
+
let(:results) { OMDB.find('Star Wars') }
|
80
|
+
|
81
|
+
it 'should return an array' do
|
82
|
+
results.should be_instance_of Array
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should return an array with hash contents' do
|
86
|
+
results[0].should be_instance_of Hash
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'with no search results' do
|
91
|
+
let(:results) { OMDB.find('lsdfoweirjrpwef323423dsfkip') }
|
92
|
+
|
93
|
+
it 'should return a hash' do
|
94
|
+
results.should be_instance_of Hash
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should return a hash with a false response' do
|
98
|
+
results.response.should eq('False')
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should return a hash with an error message' do
|
102
|
+
results.error.should be_instance_of String
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OMDB::Default do
|
4
|
+
|
5
|
+
describe 'Hash#method_missing' do
|
6
|
+
let(:hash) { { a: 'a', b: 'b', c: 'c' } }
|
7
|
+
|
8
|
+
it 'should allow value access through dot notation' do
|
9
|
+
hash.a.should eq('a')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'String#to_snake_case' do
|
14
|
+
it 'should convert strings to snake case' do
|
15
|
+
"CamelCasedString".to_snake_case.should eq('camel_cased_string')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'omdbapi'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omdbapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Casey Scarborough
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: httparty
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- .gitignore
|
77
|
+
- .rspec
|
63
78
|
- Gemfile
|
64
79
|
- LICENSE.txt
|
65
80
|
- README.md
|
@@ -69,7 +84,10 @@ files:
|
|
69
84
|
- lib/omdbapi/default.rb
|
70
85
|
- lib/omdbapi/version.rb
|
71
86
|
- omdbapi.gemspec
|
72
|
-
|
87
|
+
- spec/omdbapi/client_spec.rb
|
88
|
+
- spec/omdbapi/default_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/caseyscarborough/omdbapi
|
73
91
|
licenses:
|
74
92
|
- MIT
|
75
93
|
metadata: {}
|
@@ -93,4 +111,7 @@ rubygems_version: 2.0.6
|
|
93
111
|
signing_key:
|
94
112
|
specification_version: 4
|
95
113
|
summary: This gem provides easy access for information retrieval from omdbapi.com.
|
96
|
-
test_files:
|
114
|
+
test_files:
|
115
|
+
- spec/omdbapi/client_spec.rb
|
116
|
+
- spec/omdbapi/default_spec.rb
|
117
|
+
- spec/spec_helper.rb
|