rottentomatoes 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -4
- data/README.rdoc +9 -1
- data/lib/rottentomatoes/rotten_movie.rb +2 -2
- data/lib/rottentomatoes/rottentomatoes.rb +3 -2
- data/lib/rottentomatoes/version.rb +1 -1
- data/spec/rotten_movie_spec.rb +11 -2
- data/spec/rottentomatoes_spec.rb +1 -1
- metadata +55 -103
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rottentomatoes (
|
4
|
+
rottentomatoes (1.1.0)
|
5
5
|
deepopenstruct (>= 0.1.2)
|
6
6
|
json
|
7
7
|
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
crack (0.1.8)
|
13
13
|
deepopenstruct (0.1.2)
|
14
14
|
diff-lcs (1.1.2)
|
15
|
-
json (1.
|
15
|
+
json (1.7.7)
|
16
16
|
rspec (2.0.1)
|
17
17
|
rspec-core (~> 2.0.1)
|
18
18
|
rspec-expectations (~> 2.0.1)
|
@@ -32,8 +32,6 @@ PLATFORMS
|
|
32
32
|
|
33
33
|
DEPENDENCIES
|
34
34
|
bundler (>= 1.0.0)
|
35
|
-
deepopenstruct (>= 0.1.2)
|
36
|
-
json
|
37
35
|
rottentomatoes!
|
38
36
|
rspec (~> 2.0.0.beta.22)
|
39
37
|
webmock (>= 1.6.2)
|
data/README.rdoc
CHANGED
@@ -18,7 +18,10 @@ rottentomatoes is an ActiveRecord-style API wrapper for {RottenTomatoes.com}[htt
|
|
18
18
|
@movie = RottenMovie.find(:title => "Fight Club", :limit => 1)
|
19
19
|
# => <OpenStruct>
|
20
20
|
|
21
|
-
@movie.
|
21
|
+
@movie = RottenMovie.find(:imdb => 137523)
|
22
|
+
# => <OpenStruct>
|
23
|
+
|
24
|
+
@movie.title
|
22
25
|
# => "Fight Club"
|
23
26
|
|
24
27
|
@movie.ratings.critics_score
|
@@ -42,6 +45,7 @@ Each object provides a find() method which accepts a number of options:
|
|
42
45
|
|
43
46
|
|
44
47
|
[:id] specifies an individual movie via it's RottenTomatoes id
|
48
|
+
[:imdb] specifies an individual movie via it's IMDb id
|
45
49
|
[:title] specifies a query string to look for in the movie titles
|
46
50
|
[:limit] specifies the maximum number of results to be returned
|
47
51
|
[:expand_results] The RottenTomatoes API by default returns only partial info for any API method that can return multiple results, or single movie lookups. When :expand_results is set to true rottentomatoes automatically makes extra API calls to fetch the full information for each item, such as the full cast and reviews. This can result in *very* slow requests though. If you need extra information for a search listing then set this to true. Defaults to 'false'. On average the overhead of the extra lookups takes 4x longer to return info.
|
@@ -67,6 +71,10 @@ Find a single movie by its RottenTomatoes ID:
|
|
67
71
|
|
68
72
|
@movie = RottenMovie.find(:id => 13153)
|
69
73
|
|
74
|
+
Find a single movie by its IMDb ID:
|
75
|
+
|
76
|
+
@movie = RottenMovie.find(:imdb => 137523)
|
77
|
+
|
70
78
|
Find a single movie and all associated information
|
71
79
|
|
72
80
|
@movie = RottenMovie.find(:title => 'Fight Club', :expand_results => true, :limit => 1)
|
@@ -3,10 +3,10 @@ module RottenTomatoes
|
|
3
3
|
class RottenMovie
|
4
4
|
|
5
5
|
def self.find(options)
|
6
|
-
raise ArgumentError, "You must search by title or id" if (options[:title].nil? && options[:id].nil?)
|
6
|
+
raise ArgumentError, "You must search by title, id or imdb id" if (options[:title].nil? && options[:id].nil? && options[:imdb].nil?)
|
7
7
|
|
8
8
|
results = []
|
9
|
-
results << Rotten.api_call("movies", options)
|
9
|
+
results << Rotten.api_call(options[:imdb].nil? ? "movies" : "movie_alias", options)
|
10
10
|
|
11
11
|
return Rotten.process_results(results, options)
|
12
12
|
end
|
@@ -25,7 +25,7 @@ module RottenTomatoes
|
|
25
25
|
|
26
26
|
def self.api_call(method, options)
|
27
27
|
raise ArgumentError, "Rotten.api_key must be set before you can use the API" if(@@api_key.nil? || @@api_key.empty?)
|
28
|
-
raise ArgumentError, "You must specify 'movies', '
|
28
|
+
raise ArgumentError, "You must specify 'movies', 'movie_alias', 'lists' or 'direct' as the method" if (method != "movies" && method != "direct" && method != "lists" && method != "movie_alias")
|
29
29
|
|
30
30
|
url = (method == "direct") ? options : base_api_url + method
|
31
31
|
|
@@ -41,7 +41,8 @@ module RottenTomatoes
|
|
41
41
|
url += ".json" if (url[-5, 5] != ".json")
|
42
42
|
url += "?apikey=" + @@api_key
|
43
43
|
url += "&q=" + CGI::escape(options[:title].to_s) if (method == "movies" && !options[:title].nil? && options[:id].nil?)
|
44
|
-
|
44
|
+
url += "&type=imdb&id=%07d" % options[:imdb].to_i if (method == "movie_alias")
|
45
|
+
|
45
46
|
response = get_url(url)
|
46
47
|
return nil if(response.code.to_i != 200)
|
47
48
|
body = JSON(response.body)
|
data/spec/rotten_movie_spec.rb
CHANGED
@@ -40,16 +40,25 @@ describe RottenMovie do
|
|
40
40
|
movie.should be_a_kind_of OpenStruct
|
41
41
|
end
|
42
42
|
|
43
|
+
it "should return a single movie when searching by imdb id" do
|
44
|
+
movie = RottenMovie.find(:imdb => 137523)
|
45
|
+
movie.should be_a_kind_of OpenStruct
|
46
|
+
end
|
47
|
+
|
43
48
|
it "should return the full movie data when searching by id" do
|
44
49
|
movie = RottenMovie.find(:id => 13153)
|
45
50
|
movie.mpaa_rating.should == "R"
|
46
51
|
end
|
47
52
|
|
53
|
+
it "should return the full movie data when searching by imdb id" do
|
54
|
+
movie = RottenMovie.find(:imdb => 137523)
|
55
|
+
movie.mpaa_rating.should == "R"
|
56
|
+
end
|
57
|
+
|
48
58
|
it "should return the full movie data when expand_results set to true and searching by title" do
|
49
59
|
movie = RottenMovie.find(:title => "Fight Club", :limit => 1, :expand_results => true)
|
50
60
|
movie.mpaa_rating.should == "R"
|
51
|
-
movie.
|
52
|
-
movie.reviews.first.should_not be_nil
|
61
|
+
movie.abridged_cast.should_not be_nil
|
53
62
|
end
|
54
63
|
|
55
64
|
it "should show movies found with the same data as equal" do
|
data/spec/rottentomatoes_spec.rb
CHANGED
@@ -36,7 +36,7 @@ describe Rotten do
|
|
36
36
|
it "should return an array of results when searching by title" do
|
37
37
|
movies = Rotten.api_call("movies", :title => "Fight Club")
|
38
38
|
movies.should be_a_kind_of Array
|
39
|
-
movies.length.should have_at_least(
|
39
|
+
movies.length.should have_at_least(3).things
|
40
40
|
movies.each do |movie|
|
41
41
|
movie.should be_a_kind_of Hash
|
42
42
|
end
|
metadata
CHANGED
@@ -1,113 +1,78 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rottentomatoes
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Nicholas Munson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-04-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: bundler
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &79008530 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.0.0
|
35
22
|
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *79008530
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &79008110 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 62196431
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 0
|
49
|
-
- 0
|
50
|
-
- beta
|
51
|
-
- 22
|
31
|
+
- !ruby/object:Gem::Version
|
52
32
|
version: 2.0.0.beta.22
|
53
33
|
type: :development
|
54
|
-
version_requirements: *id002
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: webmock
|
57
34
|
prerelease: false
|
58
|
-
|
35
|
+
version_requirements: *79008110
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: webmock
|
38
|
+
requirement: &79007830 !ruby/object:Gem::Requirement
|
59
39
|
none: false
|
60
|
-
requirements:
|
61
|
-
- -
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
hash: 11
|
64
|
-
segments:
|
65
|
-
- 1
|
66
|
-
- 6
|
67
|
-
- 2
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
68
43
|
version: 1.6.2
|
69
44
|
type: :development
|
70
|
-
version_requirements: *id003
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: deepopenstruct
|
73
45
|
prerelease: false
|
74
|
-
|
46
|
+
version_requirements: *79007830
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: deepopenstruct
|
49
|
+
requirement: &79007540 !ruby/object:Gem::Requirement
|
75
50
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
hash: 31
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
- 1
|
83
|
-
- 2
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
84
54
|
version: 0.1.2
|
85
55
|
type: :runtime
|
86
|
-
version_requirements: *id004
|
87
|
-
- !ruby/object:Gem::Dependency
|
88
|
-
name: json
|
89
56
|
prerelease: false
|
90
|
-
|
57
|
+
version_requirements: *79007540
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: json
|
60
|
+
requirement: &79007270 !ruby/object:Gem::Requirement
|
91
61
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
segments:
|
97
|
-
- 0
|
98
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
99
66
|
type: :runtime
|
100
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *79007270
|
101
69
|
description: An ActiveRecord-style API wrapper for RottenTomatoes.com
|
102
|
-
email:
|
70
|
+
email:
|
103
71
|
- nmunson@gmail.com
|
104
72
|
executables: []
|
105
|
-
|
106
73
|
extensions: []
|
107
|
-
|
108
74
|
extra_rdoc_files: []
|
109
|
-
|
110
|
-
files:
|
75
|
+
files:
|
111
76
|
- .gitignore
|
112
77
|
- Gemfile
|
113
78
|
- Gemfile.lock
|
@@ -126,41 +91,28 @@ files:
|
|
126
91
|
- spec/setup/.gitignore
|
127
92
|
- spec/setup/setup_api_key.rb
|
128
93
|
- spec/setup/spec_helper.rb
|
129
|
-
has_rdoc: true
|
130
94
|
homepage: http://rubygems.org/gems/rottentomatoes
|
131
95
|
licenses: []
|
132
|
-
|
133
96
|
post_install_message:
|
134
97
|
rdoc_options: []
|
135
|
-
|
136
|
-
require_paths:
|
98
|
+
require_paths:
|
137
99
|
- lib
|
138
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
101
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
|
145
|
-
- 0
|
146
|
-
version: "0"
|
147
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
107
|
none: false
|
149
|
-
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
hash: 23
|
153
|
-
segments:
|
154
|
-
- 1
|
155
|
-
- 3
|
156
|
-
- 6
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
157
111
|
version: 1.3.6
|
158
112
|
requirements: []
|
159
|
-
|
160
113
|
rubyforge_project: rottentomatoes
|
161
|
-
rubygems_version: 1.
|
114
|
+
rubygems_version: 1.8.5
|
162
115
|
signing_key:
|
163
116
|
specification_version: 3
|
164
117
|
summary: An ActiveRecord-style API wrapper for RottenTomatoes.com
|
165
118
|
test_files: []
|
166
|
-
|