worth_watching 0.0.3
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.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/config/example_config.yml +7 -0
- data/lib/worth_watching.rb +7 -0
- data/lib/worth_watching/aggregator.rb +201 -0
- data/lib/worth_watching/movie.rb +35 -0
- data/lib/worth_watching/version.rb +3 -0
- data/lib/worth_watching/written_review.rb +25 -0
- data/spec/vcr_setup.rb +7 -0
- data/spec/worth_watching_spec.rb +139 -0
- data/worth_watching.gemspec +34 -0
- metadata +214 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--COLOR
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Alex M
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# WorthWatching
|
2
|
+
|
3
|
+
WorthWatching is a gem that allows you to aggregate movie review data from a
|
4
|
+
number of different sources.
|
5
|
+
|
6
|
+
Current supported sources are Rotten Tomatoes, IMDb and Metacritic.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
```ruby
|
12
|
+
gem 'worth_watching'
|
13
|
+
```
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install worth_watching
|
21
|
+
|
22
|
+
## Setup
|
23
|
+
|
24
|
+
* Apply for the required API keys. You will need a [Rotten Tomatoes API Key](http://developer.rottentomatoes.com/) and a [TMDB API key](http://docs.themoviedb.apiary.io/).
|
25
|
+
|
26
|
+
* Fill in the details of your API keys in config/config.yml
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# Create a new aggregator
|
32
|
+
movie_aggregator = WorthWatching::Aggregator.new
|
33
|
+
|
34
|
+
# Search for movie by Rotten Tomatoes ID
|
35
|
+
toy_story_3 = movie_aggregator.movie_info('770672122')
|
36
|
+
|
37
|
+
# We now have a Movie object and can access many attributes, including rating information
|
38
|
+
toy_story_3.title
|
39
|
+
=> "Toy Story 3"
|
40
|
+
|
41
|
+
toy_story_3.rt_rating
|
42
|
+
=> 99
|
43
|
+
|
44
|
+
toy_story_3.imdb_rating
|
45
|
+
=> 85
|
46
|
+
|
47
|
+
toy_story_3.metacritic_rating
|
48
|
+
=> 92
|
49
|
+
|
50
|
+
|
51
|
+
# Get a short 5-film list of movies currently on release
|
52
|
+
recent_movies = movie_aggregator.in_cinemas(5)
|
53
|
+
|
54
|
+
iron_man = recent_movies.first
|
55
|
+
|
56
|
+
iron_man.title
|
57
|
+
=> "Iron Man 3"
|
58
|
+
|
59
|
+
critic_review = iron_man.reviews.first
|
60
|
+
critic_review.quote
|
61
|
+
=> "The trouble is that, as the plot quickens, any cleverness withdraws, to make
|
62
|
+
way for the firecrackers of the climax. That is not Black's forte, and his
|
63
|
+
movie duly slumps into a mess."
|
64
|
+
```
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module WorthWatching
|
6
|
+
class Aggregator
|
7
|
+
|
8
|
+
attr_accessor :rt_api_key, :tmdb_api_key
|
9
|
+
|
10
|
+
RT_API_BASE_URL = 'http://api.rottentomatoes.com/api/public/v1.0'
|
11
|
+
TMDB_API_BASE_URL = 'http://api.themoviedb.org/3'
|
12
|
+
|
13
|
+
# Initialize a new Aggregator object to retrieve movie info
|
14
|
+
def initialize
|
15
|
+
config = YAML.load_file('config/config.yml')
|
16
|
+
@rt_api_key = config['rt_api_key']
|
17
|
+
@tmdb_api_key = config['tmdb_api_key']
|
18
|
+
end
|
19
|
+
|
20
|
+
# Retrieve the details of a specific movie using its IMDB ID
|
21
|
+
# @param rt_id [String] the Rotten Tomatoes ID of the movie
|
22
|
+
# @return [Movie] a Movie object representing the movie
|
23
|
+
def movie_info(rt_id)
|
24
|
+
uri = "#{RT_API_BASE_URL}/movies/#{rt_id}.json?apikey=#{rt_api_key}"
|
25
|
+
movie_hash = HTTParty.get(uri)
|
26
|
+
aggregate(Movie.new(movie_hash))
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieve a list of movies that are currently in cinemas
|
30
|
+
# @param result_limit [Integer] the maximum number of results to return
|
31
|
+
# @return [Array] an Array of Movie objects
|
32
|
+
def in_cinemas(result_limit, type)
|
33
|
+
|
34
|
+
case type
|
35
|
+
when :cinema
|
36
|
+
uri = "#{RT_API_BASE_URL}/lists/movies/in_theaters.json?page_limit=#{result_limit}"\
|
37
|
+
"&page=1&country=uk&apikey=#{rt_api_key}"
|
38
|
+
when :dvd
|
39
|
+
uri = "#{RT_API_BASE_URL}/lists/dvds/top_rentals.json?page_limit=#{result_limit}"\
|
40
|
+
"&page=1&country=uk&apikey=#{rt_api_key}"
|
41
|
+
end
|
42
|
+
|
43
|
+
movie_list = HTTParty.get(uri)
|
44
|
+
movie_list = movie_list["movies"]
|
45
|
+
in_theaters = []
|
46
|
+
|
47
|
+
movie_list.each do |movie|
|
48
|
+
if enough_info?(movie)
|
49
|
+
movie = movie_info(movie['id'])
|
50
|
+
in_theaters << movie
|
51
|
+
end
|
52
|
+
end
|
53
|
+
Aggregator.clean_up(in_theaters)
|
54
|
+
return in_theaters
|
55
|
+
end
|
56
|
+
|
57
|
+
# Aggregates exta information about a movie that cannot be derived directly from the
|
58
|
+
# Rotten Tomatoes API e.g IMDb/Metacritic rating, HQ posters
|
59
|
+
# @param movie [Movie] the movie to aggregate information for
|
60
|
+
# @return [Movie] the movie passed in with aggregated info completed
|
61
|
+
def aggregate(movie)
|
62
|
+
extra_info = get_extra_info_via_omdb(movie.imdb_id)
|
63
|
+
|
64
|
+
movie.imdb_rating = extra_info[:imdb_rating]
|
65
|
+
movie.metacritic_rating = extra_info[:metacritic_rating]
|
66
|
+
movie.metacritic_url = extra_info[:metacritic_url]
|
67
|
+
|
68
|
+
movie.poster = get_poster(movie.imdb_id)
|
69
|
+
movie.reviews = get_reviews(movie.rt_id)
|
70
|
+
|
71
|
+
return movie
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
# Retrieves extra info about a particular movie that cannot be found using
|
77
|
+
# the Rotten Tomatoes API. All facilitated by its IMDb ID.
|
78
|
+
# @params imdb_id [String] the IMDb ID of the required movie (without 'tt' prefixed)
|
79
|
+
# @return [Hash] a hash containing IMDb rating, Metacritic rating and movie URL
|
80
|
+
def get_extra_info(imdb_id)
|
81
|
+
imdb_url = "http://m.imdb.com/title/tt#{imdb_id}"
|
82
|
+
|
83
|
+
imdb_page = Nokogiri::HTML(open(imdb_url))
|
84
|
+
extra_info = {}
|
85
|
+
|
86
|
+
# Extract IMDB rating
|
87
|
+
extra_info[:imdb_rating] = imdb_page.css('.votes strong').text
|
88
|
+
|
89
|
+
# Extract Metacritic rating (IMDB has a page listing MC reviews)
|
90
|
+
imdb_mc_page = Nokogiri::HTML(open("http://www.imdb.com/title/tt#{imdb_id}/criticreviews"))
|
91
|
+
|
92
|
+
mc_rating = imdb_mc_page.css(".metascore > span").text
|
93
|
+
|
94
|
+
if mc_rating != ""
|
95
|
+
extra_info[:metacritic_rating] = mc_rating
|
96
|
+
extra_info[:metacritic_url] = imdb_mc_page.css(".see-more .offsite-link")[0]["href"]
|
97
|
+
else
|
98
|
+
extra_info[:metacritic_rating] = "No Rating"
|
99
|
+
extra_info[:metacritic_url] = "No URL"
|
100
|
+
end
|
101
|
+
|
102
|
+
return extra_info
|
103
|
+
end
|
104
|
+
|
105
|
+
# TEMPORARY METHOD NAME. Horrible name, I know.
|
106
|
+
def get_extra_info_via_omdb(imdb_id)
|
107
|
+
extra_info = {}
|
108
|
+
omdb_response = HTTParty.get("http://www.omdbapi.com/?i=tt#{imdb_id}&r=xml")
|
109
|
+
|
110
|
+
if omdb_response["root"]["response"] == "True"
|
111
|
+
imdb_rating = omdb_response["root"]["movie"]["imdbRating"]
|
112
|
+
movie_title = omdb_response["root"]["movie"]["title"]
|
113
|
+
|
114
|
+
# Extract Metacritic rating (IMDB has a page listing MC reviews)
|
115
|
+
metacritic_page = Nokogiri::HTML(open("http://www.metacritic.com/search/"\
|
116
|
+
"movie/#{CGI.escape(movie_title)}/results"))
|
117
|
+
mc_rating = metacritic_page.css('.first_result .metascore').text
|
118
|
+
mc_link = "http://www.metacritic.com#{metacritic_page.at_css('.first_result a').attr(:href)}"
|
119
|
+
else
|
120
|
+
imdb_rating = "Unavailable"
|
121
|
+
end
|
122
|
+
|
123
|
+
# Extract IMDB rating
|
124
|
+
extra_info[:imdb_rating] =imdb_rating
|
125
|
+
|
126
|
+
if mc_rating != ""
|
127
|
+
extra_info[:metacritic_rating] = mc_rating
|
128
|
+
extra_info[:metacritic_url] = mc_link
|
129
|
+
else
|
130
|
+
extra_info[:metacritic_rating] = "Unavailable"
|
131
|
+
extra_info[:metacritic_url] = "No URL"
|
132
|
+
end
|
133
|
+
|
134
|
+
return extra_info
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
# Retrieves the URL of a high resolution poster of a movie
|
140
|
+
# @params imdb_id [String] the IMDb ID of the required movie (without 'tt' prefixed)
|
141
|
+
# @return [String] the URL of the poster as a string
|
142
|
+
def get_poster(imdb_id)
|
143
|
+
uri = "#{TMDB_API_BASE_URL}/movie/tt#{imdb_id}?api_key=#{tmdb_api_key}"
|
144
|
+
movie_info = HTTParty.get(uri, :headers => { 'Accept' => 'application/json'})
|
145
|
+
|
146
|
+
if movie_info.has_key?("poster_path")
|
147
|
+
"http://cf2.imgobject.com/t/p/original" + movie_info["poster_path"]
|
148
|
+
else
|
149
|
+
"No poster available"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def get_reviews(rt_id)
|
154
|
+
uri = "#{RT_API_BASE_URL}/movies/#{rt_id}/reviews.json?review_type=top_critic"\
|
155
|
+
"&page_limit=5&page=1&country=uk&apikey=#{rt_api_key}"
|
156
|
+
review_hash = HTTParty.get(uri)
|
157
|
+
|
158
|
+
review_list = []
|
159
|
+
|
160
|
+
review_hash["reviews"].each do |review|
|
161
|
+
review_list << WrittenReview.new(review)
|
162
|
+
end
|
163
|
+
|
164
|
+
return review_list
|
165
|
+
end
|
166
|
+
|
167
|
+
# Checks that a given movie has enough information available via API to aggregate
|
168
|
+
# data. It MUST have an IMDb id and a release date.
|
169
|
+
# @param [Hash] the hash representation of the movie to check
|
170
|
+
# @return [Boolean] whether the movie has a theater release date and IMDb ID
|
171
|
+
def enough_info?(movie)
|
172
|
+
|
173
|
+
has_release_date = false
|
174
|
+
has_imdb_id = false
|
175
|
+
|
176
|
+
if movie.has_key?("release_dates")
|
177
|
+
if movie["release_dates"].has_key?("theater")
|
178
|
+
has_release_date = !movie["release_dates"]["theater"].empty?
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Check IMDb ID is present
|
183
|
+
if movie.has_key?("alternate_ids")
|
184
|
+
if movie["alternate_ids"].has_key?("imdb")
|
185
|
+
has_imdb_id = !movie["alternate_ids"]["imdb"].empty?
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
return has_release_date && has_imdb_id
|
190
|
+
end
|
191
|
+
|
192
|
+
# Removes movies from an array that do no have the required rating information
|
193
|
+
# @param movie_list [Array] the list to clean up
|
194
|
+
# @return [Array] the pruned list of movies
|
195
|
+
def self.clean_up(movie_list)
|
196
|
+
movie_list.delete_if do |movie|
|
197
|
+
movie.metacritic_rating == "No Rating"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module WorthWatching
|
4
|
+
class Movie
|
5
|
+
attr_accessor :title, :plot, :director, :genre, :rt_rating, :rt_url, :cast,
|
6
|
+
:imdb_rating, :imdb_url, :metacritic_rating, :metacritic_url,
|
7
|
+
:release_date, :poster, :rt_id, :imdb_id, :reviews
|
8
|
+
|
9
|
+
def initialize(movie_params)
|
10
|
+
@title = movie_params['title']
|
11
|
+
@plot = movie_params['synopsis']
|
12
|
+
@director = movie_params['abridged_directors'][0]['name']
|
13
|
+
@genre = movie_params['genres'][0]
|
14
|
+
@rt_rating = movie_params['ratings']['critics_score']
|
15
|
+
@rt_url = movie_params['links']['alternate']
|
16
|
+
@cast = extract_cast(movie_params['abridged_cast'])
|
17
|
+
@imdb_id = movie_params['alternate_ids']['imdb']
|
18
|
+
@imdb_url = "http://www.imdb.com/title/tt#{imdb_id}/"
|
19
|
+
@release_date = Date.parse(movie_params['release_dates']['theater'])
|
20
|
+
@rt_id = movie_params['id']
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def extract_cast(cast)
|
26
|
+
cast_list = ""
|
27
|
+
# Extract the first 4 actors, formatting with a comma when necessary
|
28
|
+
cast[0..3].each_with_index do |actor, i|
|
29
|
+
actor = (i < 3) ? "#{actor['name']}, " : "#{actor['name']}"
|
30
|
+
cast_list << actor
|
31
|
+
end
|
32
|
+
return cast_list
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module WorthWatching
|
4
|
+
class WrittenReview
|
5
|
+
attr_accessor :author, :date, :rating, :source, :quote, :link
|
6
|
+
|
7
|
+
def initialize(review_hash)
|
8
|
+
@author = review_hash["critic"]
|
9
|
+
@date = Date.parse(review_hash["date"])
|
10
|
+
@rating = review_hash["freshness"]
|
11
|
+
@source = review_hash["publication"]
|
12
|
+
@quote = review_hash["quote"]
|
13
|
+
@link = review_hash["links"]["review"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
"#{author} wrote on #{date} : #{quote}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_hash
|
21
|
+
hash = {author: author, date: date, rating: rating, source: source,
|
22
|
+
quote: quote, link: link}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/vcr_setup.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
#worth_watching_spec.rb
|
2
|
+
require 'vcr_setup'
|
3
|
+
require 'worth_watching'
|
4
|
+
|
5
|
+
describe 'WorthWatching' do
|
6
|
+
|
7
|
+
let(:aggregator) {WorthWatching::Aggregator.new}
|
8
|
+
|
9
|
+
describe 'get individual movie info' do
|
10
|
+
|
11
|
+
let(:movie) do
|
12
|
+
VCR.use_cassette('toy story 3') do
|
13
|
+
aggregator.movie_info("770672122")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:release_date) { Date.new(2010, 06, 18) }
|
18
|
+
|
19
|
+
it "should have the title 'Toy Story 3" do
|
20
|
+
movie.title.should == "Toy Story 3"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have correct plot'" do
|
24
|
+
movie.plot.should == "Pixar returns to their first success with Toy Story 3. The movie begins with Andy leaving for college and donating his beloved toys -- including Woody (Tom Hanks) and Buzz (Tim Allen) -- to a daycare. While the crew meets new friends, including Ken (Michael Keaton), they soon grow to hate their new surroundings and plan an escape. The film was directed by Lee Unkrich from a script co-authored by Little Miss Sunshine scribe Michael Arndt. ~ Perry Seibert, Rovi"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have rotten tomatoes rating 99'" do
|
28
|
+
movie.rt_rating.should == 99
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have a link to RT page 'http://www.rottentomatoes.com/m/toy_story_3/'" do
|
32
|
+
movie.rt_url.should == "http://www.rottentomatoes.com/m/toy_story_3/"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have imdb rating of 8.5" do
|
36
|
+
movie.imdb_rating.should == "8.5"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have imdb url 'http://www.imdb.com/title/tt0435761/" do
|
40
|
+
movie.imdb_url.should == "http://www.imdb.com/title/tt0435761/"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have metacritic rating of 92" do
|
44
|
+
movie.metacritic_rating.should == "92"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have metacritic url 'http://www.metacritic.com/movie/toy-story-3'" do
|
48
|
+
movie.metacritic_url.should == "http://www.metacritic.com/movie/toy-story-3"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have cast 'Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty'" do
|
52
|
+
movie.cast.should == "Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have release date '2010-06-18'" do
|
56
|
+
movie.release_date.should == release_date
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have director 'Lee Unkrich'" do
|
60
|
+
movie.director.should == "Lee Unkrich"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have genre 'Animation'" do
|
64
|
+
movie.genre.should == "Animation"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have the correct poster url" do
|
68
|
+
movie.poster.should == "http://cf2.imgobject.com/t/p/original/tOwAAVeL1p3ls9dhOBo45ElodU3.jpg"
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "movie reviews" do
|
72
|
+
it "should have an author" do
|
73
|
+
#puts movie.reviews.first.to_hash
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should have a date" do
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have rating" do
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should have a source" do
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should have a review quote" do
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should have a link to the review" do
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "Retrieve movies currently in cinemas" do
|
99
|
+
|
100
|
+
let(:movies) do
|
101
|
+
VCR.use_cassette('in cinemas') do
|
102
|
+
aggregator.in_cinemas(16, :cinema)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should return a non-empty array of movies" do
|
107
|
+
movies.size.should_not == 0
|
108
|
+
end
|
109
|
+
|
110
|
+
it "all movies should have a release date" do
|
111
|
+
movies.each {|movie| movie.release_date.should_not == nil}
|
112
|
+
end
|
113
|
+
|
114
|
+
it "all movies should have a poster url" do
|
115
|
+
movies.each {|movie| puts "#{movie.title} #{movie.rt_rating} | #{movie.imdb_rating} | #{movie.metacritic_rating}"; movie.poster.should_not == nil}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "Retrieve movies released on DVD" do
|
120
|
+
|
121
|
+
let(:movies) do
|
122
|
+
VCR.use_cassette('in cinemas') do
|
123
|
+
aggregator.in_cinemas(16, :dvd)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should return a non-empty array of movies" do
|
128
|
+
movies.size.should_not == 0
|
129
|
+
end
|
130
|
+
|
131
|
+
it "all movies should have a release date" do
|
132
|
+
movies.each {|movie| movie.release_date.should_not == nil}
|
133
|
+
end
|
134
|
+
|
135
|
+
it "all movies should have a poster url" do
|
136
|
+
movies.each {|movie| puts "#{movie.title} #{movie.rt_rating} | #{movie.imdb_rating} | #{movie.metacritic_rating}"; movie.poster.should_not == nil}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'worth_watching/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "worth_watching"
|
8
|
+
spec.version = WorthWatching::VERSION
|
9
|
+
spec.authors = ["Sandro"]
|
10
|
+
spec.email = ["sandro@?.com"]
|
11
|
+
spec.description = %q{Retrieve the ratings of a movie from IMDB, Rotten
|
12
|
+
Tomatoes and Metacritic}
|
13
|
+
spec.summary = %q{Retrieve the ratings of a movie from IMDB, Rotten
|
14
|
+
Tomatoes and Metacritic}
|
15
|
+
spec.homepage = ""
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "vcr"
|
27
|
+
spec.add_development_dependency "webmock"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
|
30
|
+
|
31
|
+
spec.add_dependency "json"
|
32
|
+
spec.add_dependency "nokogiri"
|
33
|
+
spec.add_dependency "httparty"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: worth_watching
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sandro
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: vcr
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webmock
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: pry
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: json
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: nokogiri
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: httparty
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: ! "Retrieve the ratings of a movie from IMDB, Rotten\n Tomatoes
|
159
|
+
and Metacritic"
|
160
|
+
email:
|
161
|
+
- sandro@?.com
|
162
|
+
executables: []
|
163
|
+
extensions: []
|
164
|
+
extra_rdoc_files: []
|
165
|
+
files:
|
166
|
+
- .gitignore
|
167
|
+
- .rspec
|
168
|
+
- Gemfile
|
169
|
+
- LICENSE.txt
|
170
|
+
- README.md
|
171
|
+
- Rakefile
|
172
|
+
- config/example_config.yml
|
173
|
+
- lib/worth_watching.rb
|
174
|
+
- lib/worth_watching/aggregator.rb
|
175
|
+
- lib/worth_watching/movie.rb
|
176
|
+
- lib/worth_watching/version.rb
|
177
|
+
- lib/worth_watching/written_review.rb
|
178
|
+
- spec/vcr_setup.rb
|
179
|
+
- spec/worth_watching_spec.rb
|
180
|
+
- worth_watching.gemspec
|
181
|
+
homepage: ''
|
182
|
+
licenses:
|
183
|
+
- MIT
|
184
|
+
post_install_message:
|
185
|
+
rdoc_options: []
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ! '>='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
segments:
|
195
|
+
- 0
|
196
|
+
hash: -284392166262815710
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
none: false
|
199
|
+
requirements:
|
200
|
+
- - ! '>='
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
segments:
|
204
|
+
- 0
|
205
|
+
hash: -284392166262815710
|
206
|
+
requirements: []
|
207
|
+
rubyforge_project:
|
208
|
+
rubygems_version: 1.8.23
|
209
|
+
signing_key:
|
210
|
+
specification_version: 3
|
211
|
+
summary: Retrieve the ratings of a movie from IMDB, Rotten Tomatoes and Metacritic
|
212
|
+
test_files:
|
213
|
+
- spec/vcr_setup.rb
|
214
|
+
- spec/worth_watching_spec.rb
|