spotlite 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +90 -0
- data/Rakefile +8 -0
- data/lib/spotlite.rb +9 -0
- data/lib/spotlite/movie.rb +240 -0
- data/lib/spotlite/version.rb +3 -0
- data/spec/fixtures/tt0002186/index +1920 -0
- data/spec/fixtures/tt0047396/releaseinfo +1226 -0
- data/spec/fixtures/tt0133093/fullcredits +867 -0
- data/spec/fixtures/tt0133093/index +2546 -0
- data/spec/fixtures/tt0133093/keywords +1604 -0
- data/spec/fixtures/tt0133093/releaseinfo +1143 -0
- data/spec/fixtures/tt0133093/trivia +3284 -0
- data/spec/fixtures/tt0169547/index +2523 -0
- data/spec/fixtures/tt0317248/index +2517 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/spotlite/movie_spec.rb +156 -0
- data/spotlite.gemspec +22 -0
- data/tasks/fixtures.rake +15 -0
- metadata +128 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spotlite'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.color_enabled = true
|
6
|
+
config.formatter = 'documentation'
|
7
|
+
end
|
8
|
+
|
9
|
+
def read_fixture(path)
|
10
|
+
File.read(File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', path)))
|
11
|
+
end
|
12
|
+
|
13
|
+
IMDB_SAMPLES = {
|
14
|
+
"http://www.imdb.com/title/tt0133093/" => "tt0133093/index",
|
15
|
+
"http://www.imdb.com/title/tt0133093/fullcredits" => "tt0133093/fullcredits",
|
16
|
+
"http://www.imdb.com/title/tt0133093/keywords" => "tt0133093/keywords",
|
17
|
+
"http://www.imdb.com/title/tt0133093/releaseinfo" => "tt0133093/releaseinfo",
|
18
|
+
"http://www.imdb.com/title/tt0133093/trivia" => "tt0133093/trivia",
|
19
|
+
"http://www.imdb.com/title/tt0317248/" => "tt0317248/index",
|
20
|
+
"http://www.imdb.com/title/tt0169547/" => "tt0169547/index",
|
21
|
+
"http://www.imdb.com/title/tt0047396/releaseinfo" => "tt0047396/releaseinfo",
|
22
|
+
"http://www.imdb.com/title/tt0002186/" => "tt0002186/index"
|
23
|
+
}
|
24
|
+
|
25
|
+
unless ENV['LIVE_TEST']
|
26
|
+
begin
|
27
|
+
require 'rubygems'
|
28
|
+
require 'fakeweb'
|
29
|
+
|
30
|
+
FakeWeb.allow_net_connect = false
|
31
|
+
IMDB_SAMPLES.each do |url, response|
|
32
|
+
FakeWeb.register_uri(:get, url, :response => read_fixture(response))
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
puts "Could not load FakeWeb, these tests will hit IMDb.com"
|
36
|
+
puts "You can run `gem install fakeweb` to stub out the responses."
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Spotlite::Movie" do
|
4
|
+
|
5
|
+
describe "valid movie" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
# The Matrix (1999)
|
9
|
+
@movie = Spotlite::Movie.new("0133093")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return title" do
|
13
|
+
@movie.title.should eql("The Matrix")
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "original title" do
|
17
|
+
it "should return original title if it exists" do
|
18
|
+
# City of God (2002)
|
19
|
+
@movie = Spotlite::Movie.new("0317248")
|
20
|
+
@movie.original_title.should eql("Cidade de Deus")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return nil if it doesn't exist" do
|
24
|
+
@movie.original_title.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return original release year" do
|
29
|
+
@movie.year.should eql(1999)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return IMDb rating" do
|
33
|
+
@movie.rating.should eql(8.7)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return number of votes" do
|
37
|
+
@movie.votes.should be_within(50000).of(700000)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return description" do
|
41
|
+
@movie.description.should match(/A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers./)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return genres" do
|
45
|
+
@movie.genres.should be_an(Array)
|
46
|
+
@movie.genres.size.should eql(3)
|
47
|
+
@movie.genres.should include("Action")
|
48
|
+
@movie.genres.should include("Adventure")
|
49
|
+
@movie.genres.should include("Sci-Fi")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return countries" do
|
53
|
+
@movie.countries.should be_an(Array)
|
54
|
+
@movie.countries.size.should eql(2)
|
55
|
+
@movie.countries.should include({:code => "us", :name => "USA"})
|
56
|
+
@movie.countries.should include({:code => "au", :name => "Australia"})
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return languages" do
|
60
|
+
@movie.languages.should be_an(Array)
|
61
|
+
@movie.languages.size.should eql(1)
|
62
|
+
@movie.languages.should include({:code => "en", :name => "English"})
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return runtime in minutes" do
|
66
|
+
@movie.runtime.should eql(136)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return MPAA content rating" do
|
70
|
+
@movie.content_rating.should eql({:code => "R", :description => "Rated R for sci-fi violence and brief language"})
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "poster URL" do
|
74
|
+
it "should return old style poster URL" do
|
75
|
+
@movie.poster_url.should eql("http://ia.media-imdb.com/images/M/MV5BMjEzNjg1NTg2NV5BMl5BanBnXkFtZTYwNjY3MzQ5.jpg")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return new style poster URL" do
|
79
|
+
# American Beauty (1999)
|
80
|
+
@movie = Spotlite::Movie.new("0169547")
|
81
|
+
@movie.poster_url.should eql("http://ia.media-imdb.com/images/M/MV5BOTU1MzExMDg3N15BMl5BanBnXkFtZTcwODExNDg3OA@@.jpg")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return nil if poster doesn't exist" do
|
85
|
+
# The Flying Circus (1912)
|
86
|
+
@movie = Spotlite::Movie.new("0002186")
|
87
|
+
@movie.poster_url.should be_nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return plot keywords" do
|
92
|
+
@movie.keywords.should be_an(Array)
|
93
|
+
@movie.keywords.size.should be_within(50).of(250)
|
94
|
+
@movie.keywords.should include("Computer")
|
95
|
+
@movie.keywords.should include("Artificial Reality")
|
96
|
+
@movie.keywords.should include("Hand To Hand Combat")
|
97
|
+
@movie.keywords.should include("White Rabbit")
|
98
|
+
@movie.keywords.should include("Chosen One")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should return trivia" do
|
102
|
+
@movie.trivia.should be_an(Array)
|
103
|
+
@movie.trivia.size.should be_within(10).of(100)
|
104
|
+
@movie.trivia.should include("Nicolas Cage turned down the part of Neo because of family commitments. Other actors considered for the role included Tom Cruise and Leonardo DiCaprio.")
|
105
|
+
@movie.trivia.should include("Carrie-Anne Moss twisted her ankle while shooting one of her scenes but decided not to tell anyone until after filming, so they wouldn't re-cast her.")
|
106
|
+
@movie.trivia.should include("Gary Oldman was considered as Morpheus at one point, as well as Samuel L. Jackson.")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should return directors" do
|
110
|
+
@movie.directors.should be_an(Array)
|
111
|
+
@movie.directors.size.should eql(2)
|
112
|
+
@movie.directors.should include({:imdb_id => "0905152", :name => "Andy Wachowski"})
|
113
|
+
@movie.directors.should include({:imdb_id => "0905154", :name => "Lana Wachowski"})
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return writers" do
|
117
|
+
@movie.writers.should be_an(Array)
|
118
|
+
@movie.writers.size.should eql(2)
|
119
|
+
@movie.writers.should include({:imdb_id => "0905152", :name => "Andy Wachowski"})
|
120
|
+
@movie.writers.should include({:imdb_id => "0905154", :name => "Lana Wachowski"})
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should return producers" do
|
124
|
+
@movie.producers.should be_an(Array)
|
125
|
+
@movie.producers.size.should eql(10)
|
126
|
+
@movie.producers.should include({:imdb_id => "0075732", :name => "Bruce Berman"})
|
127
|
+
@movie.producers.should include({:imdb_id => "0185621", :name => "Dan Cracchiolo"})
|
128
|
+
@movie.producers.should include({:imdb_id => "0400492", :name => "Carol Hughes"})
|
129
|
+
@movie.producers.should include({:imdb_id => "0905152", :name => "Andy Wachowski"})
|
130
|
+
@movie.producers.should include({:imdb_id => "0905154", :name => "Lana Wachowski"})
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should return cast members and characters" do
|
134
|
+
@movie.cast.should be_an(Array)
|
135
|
+
@movie.cast.size.should eql(37)
|
136
|
+
@movie.cast.should include({:imdb_id => "0000206", :name => "Keanu Reeves", :character => "Neo"})
|
137
|
+
@movie.cast.should include({:imdb_id => "0000401", :name => "Laurence Fishburne", :character => "Morpheus"})
|
138
|
+
@movie.cast.should include({:imdb_id => "0005251", :name => "Carrie-Anne Moss", :character => "Trinity"})
|
139
|
+
@movie.cast.should include({:imdb_id => "0915989", :name => "Hugo Weaving", :character => "Agent Smith"})
|
140
|
+
@movie.cast.should include({:imdb_id => "3269395", :name => "Rana Morrison", :character => "Shaylae - Woman in Office (uncredited)"})
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should return release dates" do
|
144
|
+
# Rear Window (1954)
|
145
|
+
@movie = Spotlite::Movie.new("0047396")
|
146
|
+
@movie.release_dates.should be_an(Array)
|
147
|
+
@movie.release_dates.size.should eql(42)
|
148
|
+
@movie.release_dates.should include({:code => "jp", :region => "Japan", :date => Date.new(1955,1,14)})
|
149
|
+
@movie.release_dates.should include({:code => "tr", :region => "Turkey", :date => Date.new(1956,4,1)})
|
150
|
+
@movie.release_dates.should include({:code => "us", :region => "USA", :date => Date.new(1968,1,1)})
|
151
|
+
@movie.release_dates.detect{ |r| r[:region] == "France" }.should eql({:code => "fr", :region => "France", :date => Date.new(1955,4,1)})
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
data/spotlite.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'spotlite/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "spotlite"
|
8
|
+
gem.version = Spotlite::VERSION
|
9
|
+
gem.authors = ["Artem Pakk"]
|
10
|
+
gem.email = ["apakk@me.com"]
|
11
|
+
gem.description = %q{Spotlite gem helps you fetch all kinds of publicly available information about movies and people from IMDb movie website, including title, year, genres, directors, writers, actors, runtime, countries, poster, keywords, etc.}
|
12
|
+
gem.summary = %q{Ruby gem to fetch publicly available information about movies from IMDb}
|
13
|
+
gem.homepage = "http://github.com/defeed/spotlite"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_dependency "nokogiri", "~> 1.5.6"
|
20
|
+
gem.add_development_dependency "rspec", "~> 2.12.0"
|
21
|
+
gem.add_development_dependency "fakeweb"
|
22
|
+
end
|
data/tasks/fixtures.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :fixtures do
|
2
|
+
desc "Refresh spec fixtures with fresh data from IMDb.com"
|
3
|
+
task :refresh do
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec/spec_helper")
|
5
|
+
|
6
|
+
IMDB_SAMPLES.each_pair do |url, fixture|
|
7
|
+
page = `curl -is #{url}`
|
8
|
+
|
9
|
+
File.open(File.expand_path(File.dirname(__FILE__) + "/../spec/fixtures/#{fixture}"), 'w') do |f|
|
10
|
+
f.write(page)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spotlite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Artem Pakk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.5.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.5.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.12.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: 2.12.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fakeweb
|
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
|
+
description: Spotlite gem helps you fetch all kinds of publicly available information
|
63
|
+
about movies and people from IMDb movie website, including title, year, genres,
|
64
|
+
directors, writers, actors, runtime, countries, poster, keywords, etc.
|
65
|
+
email:
|
66
|
+
- apakk@me.com
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- .gitignore
|
72
|
+
- CHANGELOG.md
|
73
|
+
- Gemfile
|
74
|
+
- LICENSE.txt
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- lib/spotlite.rb
|
78
|
+
- lib/spotlite/movie.rb
|
79
|
+
- lib/spotlite/version.rb
|
80
|
+
- spec/fixtures/tt0002186/index
|
81
|
+
- spec/fixtures/tt0047396/releaseinfo
|
82
|
+
- spec/fixtures/tt0133093/fullcredits
|
83
|
+
- spec/fixtures/tt0133093/index
|
84
|
+
- spec/fixtures/tt0133093/keywords
|
85
|
+
- spec/fixtures/tt0133093/releaseinfo
|
86
|
+
- spec/fixtures/tt0133093/trivia
|
87
|
+
- spec/fixtures/tt0169547/index
|
88
|
+
- spec/fixtures/tt0317248/index
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/spotlite/movie_spec.rb
|
91
|
+
- spotlite.gemspec
|
92
|
+
- tasks/fixtures.rake
|
93
|
+
homepage: http://github.com/defeed/spotlite
|
94
|
+
licenses: []
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.8.24
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Ruby gem to fetch publicly available information about movies from IMDb
|
117
|
+
test_files:
|
118
|
+
- spec/fixtures/tt0002186/index
|
119
|
+
- spec/fixtures/tt0047396/releaseinfo
|
120
|
+
- spec/fixtures/tt0133093/fullcredits
|
121
|
+
- spec/fixtures/tt0133093/index
|
122
|
+
- spec/fixtures/tt0133093/keywords
|
123
|
+
- spec/fixtures/tt0133093/releaseinfo
|
124
|
+
- spec/fixtures/tt0133093/trivia
|
125
|
+
- spec/fixtures/tt0169547/index
|
126
|
+
- spec/fixtures/tt0317248/index
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/spotlite/movie_spec.rb
|