omdbapi 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 272ba0afa85cd815166b6a0b2d077f447d3b652e
4
- data.tar.gz: 112b7114fc02de8a93b491c5e6cbef4f65308419
3
+ metadata.gz: f96546e47313f62cae59711b67ad3c44e97a627e
4
+ data.tar.gz: a6d69f0a189d0a57c8c9e46334bbb23fdaa973bd
5
5
  SHA512:
6
- metadata.gz: eb65226a4f6ce075f9ff299af4577393e20be45a363ab2cdaba50fd4ca03a05c17a0152c5e84b69212d91b9fc544f05875ef65756a98f97ba5c57d99792ca66f
7
- data.tar.gz: fbbaad3014a8944a6ddd743e12872f1c3299563c1e004416ce16a166bbee40e37c821784321381b14c2f5a0970ed42ce97f0ae19053cc3bf361d3d37ef8aa1d4
6
+ metadata.gz: c9d2645b01291cf785e4e9e810abaa60a09c48c68ec932edbe613564dc49fe4e77bbe66dd9e04cf59f7113288298ca5e7d8d6eca0ac3da35a299783f151cc2ab
7
+ data.tar.gz: 599596e06bfe191982051c8a423bb242ef9f72934a225deaf834d4ba0d5bbfe475c8c0a16dcf5e0adf8d8cf3b6bf048b18f6a4aee2b8e8d12366fcc5dc70039e
data/README.md CHANGED
@@ -59,7 +59,7 @@ This function will return a Hash with the following information about the title:
59
59
  :actors, :plot, :poster, :imdb_rating, :imdb_votes, :imdb_id, :type
60
60
  ```
61
61
 
62
- You can also pass in the optional parameters for year or plot. Plot defaults to 'short', so the only other option is 'full'.
62
+ You can also pass in the optional parameters for year, plot, or season and episode. Plot defaults to 'short', so the only other option is 'full'.
63
63
 
64
64
  ```ruby
65
65
  OMDB.title('True Grit')
@@ -72,6 +72,10 @@ OMDB.title('Breaking Bad', plot: 'full')
72
72
 
73
73
  # Get the original Italian Job with the full plot
74
74
  OMDB.title('The Italian Job', year: '1969', plot: 'full')
75
+
76
+ # Get a specific episode (season and episode must be included together)
77
+ OMDB.title('True Detective', { :season => '1', :episode => '1' })
78
+ # => {:title=>"The Long Bright Dark", :year=>"2014", :rated=>"TV-MA", :released=>"12 Jan 2014", :season=>"1", :episode=>"1", :runtime=>"58 min", :genre=>"Crime, Drama, Mystery", :director=>"Cary Fukunaga", :writer=>"Nic Pizzolatto (created by), Nic Pizzolatto", :actors=>"Matthew McConaughey, Woody Harrelson, Michelle Monaghan, Michael Potts", :plot=>"In 2012, former detective partners, Rust Cohle and Martin Hart recap one of their very first cases together involving a serial killer, back in 1995.", :language=>"English", :country=>"USA", :awards=>"N/A", :poster=>"http://ia.media-imdb.com/images/M/MV5BMTY5NjA2MjEyN15BMl5BanBnXkFtZTgwNzU2MjQ4MDE@._V1_SX300.jpg", :metascore=>"N/A", :imdb_rating=>"8.9", :imdb_votes=>"8282", :imdb_id=>"tt2657398", :series_id=>"tt2356777", :type=>"episode", :response=>"True"}
75
79
  ```
76
80
 
77
81
  ### IMDb ID
@@ -1,5 +1,4 @@
1
1
  require 'httparty'
2
- require 'json'
3
2
  require 'omdbapi/version'
4
3
  require 'omdbapi/default'
5
4
  require 'omdbapi/client'
@@ -12,11 +12,19 @@ module OMDB
12
12
  #
13
13
  # @param title [String] The title of the movie or show.
14
14
  # @param options [Hash] Options for the title, plot or year.
15
+ # @option options [Integer] :year The year of the movie.
16
+ # @option options [String] :plot 'short' (default), 'full'
17
+ # @option options [Integer] :season The season to retrieve.
18
+ # @option options [Integer] :episode The episode to retrieve. Requires the season parameter.
15
19
  # @return [Hash]
16
20
  # @example
17
21
  # OMDB.title('Game of Thrones')
18
22
  def title(title, options={})
19
- params = build_params(title, options)
23
+ params = { t: title }
24
+ params[:y] = options[:year] if options[:year]
25
+ params[:plot] = options[:plot] if options[:plot]
26
+ params[:season] = options[:season] if options[:season]
27
+ params[:episode] = options[:episode] if options[:episode]
20
28
  get '/', params
21
29
  end
22
30
 
@@ -28,7 +36,7 @@ module OMDB
28
36
  # @example
29
37
  # OMDB.id('tt0944947')
30
38
  def id(imdb_id)
31
- return get '/', { i: imdb_id }
39
+ get '/', { i: imdb_id }
32
40
  end
33
41
 
34
42
  # Search for a movie by its title.
@@ -74,7 +82,7 @@ module OMDB
74
82
  # @return [Hash]
75
83
  def build_params(title, options)
76
84
  params = { t: title }
77
- params[:plot] = options[:plot] if options[:plot]
85
+
78
86
  params[:y] = options[:year] if options[:year]
79
87
  params
80
88
  end
@@ -88,7 +96,7 @@ module OMDB
88
96
  # get '/users', { username: 'caseyscarborough' }
89
97
  def get(url, params={})
90
98
  request = self.class.get '/', query: params
91
- convert_hash_keys(JSON.parse(request.parsed_response))
99
+ convert_hash_keys(request.parsed_response)
92
100
  end
93
101
  end
94
102
  end
@@ -2,5 +2,5 @@ module OMDB
2
2
  # OMDB current version
3
3
  #
4
4
  # @return [String]
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
- spec.add_dependency 'httparty', '0.11.0'
24
+ spec.add_dependency 'httparty', '>= 0.13'
25
25
  end
@@ -43,6 +43,33 @@ describe OMDB::Client do
43
43
  end
44
44
  end
45
45
 
46
+ describe 'with the season and episode parameters' do
47
+ let(:title) { OMDB.title('True Detective', episode: 1, season: 1) }
48
+
49
+ it 'should include season and episode in the response' do
50
+ title.season.should eq("1")
51
+ title.episode.should eq("1")
52
+ end
53
+ end
54
+
55
+ describe 'with only the season parameter, missing the episode parameter' do
56
+ let(:title) { OMDB.title('True Detective', season: 1) }
57
+
58
+ it 'should not include season and episode in the response' do
59
+ expect { title.season }.to raise_error(NoMethodError)
60
+ expect { title.episode }.to raise_error(NoMethodError)
61
+ end
62
+ end
63
+
64
+ describe 'with only the episode parameter, missing the season parameter' do
65
+ let(:title) { OMDB.title('True Detective', episode: 1) }
66
+
67
+ it 'should not include season and episode in the response' do
68
+ expect { title.season }.to raise_error(NoMethodError)
69
+ expect { title.episode }.to raise_error(NoMethodError)
70
+ end
71
+ end
72
+
46
73
  describe 'with a movie that doesn''t exist' do
47
74
  let(:title) { OMDB.title('lsdfoweirjrpwef323423dsfkip') }
48
75
 
@@ -106,14 +133,14 @@ describe OMDB::Client do
106
133
  end
107
134
 
108
135
  describe 'with a single search result' do
109
- let(:result) { OMDB.search('The Star Wars Holiday Special') }
136
+ let(:result) { OMDB.search('Star Wars: Episode IV - A New Hope') }
110
137
 
111
138
  it 'should return a hash of the title' do
112
139
  result.should be_instance_of Hash
113
140
  end
114
141
 
115
142
  it 'should have a title' do
116
- result.title.should eq('The Star Wars Holiday Special')
143
+ result.title.should eq('Star Wars: Episode IV - A New Hope')
117
144
  end
118
145
  end
119
146
 
metadata CHANGED
@@ -1,80 +1,80 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omdbapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Scarborough
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-13 00:00:00.000000000 Z
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: httparty
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.11.0
61
+ version: '0.13'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.11.0
69
- description: '[In Progress] A wrapper for the omdbapi.com movie API.'
68
+ version: '0.13'
69
+ description: "[In Progress] A wrapper for the omdbapi.com movie API."
70
70
  email:
71
71
  - caseyscarborough@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
76
+ - ".gitignore"
77
+ - ".rspec"
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - README.md
@@ -97,17 +97,17 @@ require_paths:
97
97
  - lib
98
98
  required_ruby_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - '>='
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.0.5
110
+ rubygems_version: 2.4.3
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: This gem provides easy access for information retrieval from omdbapi.com.