imdb 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -30
- data/Rakefile +1 -0
- data/lib/imdb/movie.rb +16 -0
- data/lib/imdb/version.rb +1 -1
- data/spec/imdb/movie_spec.rb +26 -0
- metadata +18 -39
data/README.rdoc
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
= imdb
|
2
2
|
|
3
|
-
|
3
|
+
home :: http://github.com/ariejan/imdb
|
4
|
+
rdoc :: http://ariejan.github.com/imdb/
|
5
|
+
bugs :: http://github.com/ariejan/imdb/issues
|
4
6
|
|
5
|
-
|
7
|
+
== Description
|
6
8
|
|
7
|
-
|
9
|
+
This gem allows you to easy access publicly available data from IMDB.
|
8
10
|
|
9
|
-
==
|
10
|
-
|
11
|
-
This packages allows you to easy access publicly available data from IMDB.
|
12
|
-
|
13
|
-
== FEATURES/PROBLEMS:
|
11
|
+
== Features
|
14
12
|
|
15
13
|
IMDB currently features the following:
|
16
14
|
|
@@ -18,16 +16,16 @@ IMDB currently features the following:
|
|
18
16
|
* Searching for movies
|
19
17
|
* Command-line utility included.
|
20
18
|
|
21
|
-
==
|
19
|
+
== Synopsis
|
22
20
|
|
23
21
|
Movies:
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
i = Imdb::Movie.new("0095016")
|
24
|
+
|
25
|
+
i.title
|
26
|
+
#=> "Die Hard"
|
27
|
+
i.cast_members.first
|
28
|
+
#=> "Bruce Willis"
|
31
29
|
|
32
30
|
Searching:
|
33
31
|
|
@@ -35,38 +33,32 @@ Searching:
|
|
35
33
|
|
36
34
|
i.movies.size
|
37
35
|
#=> 97
|
38
|
-
|
36
|
+
|
39
37
|
Using the command line utility is quite easy:
|
40
38
|
|
41
39
|
$ imdb Star Trek
|
42
|
-
|
40
|
+
|
43
41
|
or to get movie info
|
44
42
|
|
45
43
|
$ imdb 0095016
|
46
44
|
|
47
|
-
==
|
48
|
-
|
49
|
-
All required gems are installed automagically through RubyGems.
|
50
|
-
|
51
|
-
* Hpricot 0.8.1
|
52
|
-
|
53
|
-
== INSTALL:
|
45
|
+
== Installation
|
54
46
|
|
55
|
-
$
|
47
|
+
$ gem install imdb
|
56
48
|
|
57
|
-
==
|
49
|
+
== Documentation
|
58
50
|
|
59
51
|
This README and generated RDoc documentation are available from http://ariejan.github.com/imdb/
|
60
52
|
|
61
|
-
==
|
53
|
+
== Running tests
|
62
54
|
|
63
|
-
You'll need rspec and fakeweb installed to run the specs.
|
55
|
+
You'll need rspec and fakeweb installed to run the specs.
|
64
56
|
|
65
57
|
$ bundle install
|
66
58
|
$ bundle exec rake spec
|
67
59
|
|
68
60
|
Although not recommended, you may run the specs against the live imdb.com
|
69
|
-
website. This will make a lot of calls to imdb.com, use it wisely.
|
61
|
+
website. This will make a lot of calls to imdb.com, use it wisely.
|
70
62
|
|
71
63
|
$ LIVE_TEST=true bundle exec rake spec
|
72
64
|
|
@@ -75,7 +67,7 @@ fixtures:refresh rake task
|
|
75
67
|
|
76
68
|
$ bundle exec rake fixtures:refresh
|
77
69
|
|
78
|
-
==
|
70
|
+
== License
|
79
71
|
|
80
72
|
(The MIT License)
|
81
73
|
|
data/Rakefile
CHANGED
data/lib/imdb/movie.rb
CHANGED
@@ -28,6 +28,22 @@ module Imdb
|
|
28
28
|
document.search("table.cast td.nm a").map {|l| l['href'].sub(%r{^/name/(.*)/}, '\1') }
|
29
29
|
end
|
30
30
|
|
31
|
+
# Returns an array with cast characters
|
32
|
+
def cast_characters
|
33
|
+
document.search("table.cast td.char").map { |link| link.innerText } rescue []
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns an array with cast members and characters
|
37
|
+
def cast_members_characters(sep = '=>')
|
38
|
+
memb_char = Array.new
|
39
|
+
i = 0
|
40
|
+
self.cast_members.each{|m|
|
41
|
+
memb_char[i] = "#{self.cast_members[i]} #{sep} #{self.cast_characters[i]}"
|
42
|
+
i=i+1
|
43
|
+
}
|
44
|
+
return memb_char
|
45
|
+
end
|
46
|
+
|
31
47
|
# Returns the name of the director
|
32
48
|
def director
|
33
49
|
document.search("h5[text()^='Director'] ~ a").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
data/lib/imdb/version.rb
CHANGED
data/spec/imdb/movie_spec.rb
CHANGED
@@ -22,6 +22,32 @@ describe "Imdb::Movie" do
|
|
22
22
|
cast.should include("Bonnie Bedelia")
|
23
23
|
cast.should include("Alan Rickman")
|
24
24
|
end
|
25
|
+
|
26
|
+
it "should find the cast characters" do
|
27
|
+
char = @movie.cast_characters
|
28
|
+
|
29
|
+
char.should be_an(Array)
|
30
|
+
char.should include("Karl")
|
31
|
+
char.should include("Officer John McClane")
|
32
|
+
char.should include("Police Detective (uncredited)")
|
33
|
+
char.should include("Hostage")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should associates the cast members to the charachters" do
|
37
|
+
cast = @movie.cast_members
|
38
|
+
char = @movie.cast_characters
|
39
|
+
cast_char = @movie.cast_members_characters
|
40
|
+
|
41
|
+
cast_char[0].should eql("#{cast[0]} => #{char[0]}")
|
42
|
+
cast_char[10].should eql("#{cast[10]} => #{char[10]}")
|
43
|
+
cast_char[-1].should eql("#{cast[-1]} => #{char[-1]}")
|
44
|
+
|
45
|
+
cast_char = @movie.cast_members_characters('as')
|
46
|
+
|
47
|
+
cast_char[1].should eql("#{cast[1]} as #{char[1]}")
|
48
|
+
cast_char[11].should eql("#{cast[11]} as #{char[11]}")
|
49
|
+
cast_char[-2].should eql("#{cast[-2]} as #{char[-2]}")
|
50
|
+
end
|
25
51
|
|
26
52
|
describe 'fetching a list of imdb actor ids for the cast members' do
|
27
53
|
it 'should not require arguments' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hpricot
|
16
|
-
requirement: &
|
16
|
+
requirement: &17336340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17336340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &17335800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17335800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &17335340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.3.2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17335340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gokdok
|
49
|
-
requirement: &
|
49
|
+
requirement: &17334940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *17334940
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &17334380 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.11'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *17334380
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeweb
|
71
|
-
requirement: &
|
71
|
+
requirement: &17333940 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *17333940
|
80
80
|
description: Easily use Ruby or the command line to find information on IMDB.com.
|
81
81
|
email:
|
82
82
|
- ariejan@ariejan.net
|
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
segments:
|
144
144
|
- 0
|
145
|
-
hash:
|
145
|
+
hash: 713179150627652883
|
146
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
147
|
none: false
|
148
148
|
requirements:
|
@@ -151,32 +151,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
segments:
|
153
153
|
- 0
|
154
|
-
hash:
|
154
|
+
hash: 713179150627652883
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project: imdb
|
157
|
-
rubygems_version: 1.8.
|
157
|
+
rubygems_version: 1.8.11
|
158
158
|
signing_key:
|
159
159
|
specification_version: 3
|
160
160
|
summary: Easily access the publicly available information on IMDB.
|
161
|
-
test_files:
|
162
|
-
- spec/fixtures/search_kannethirey_thondrinal
|
163
|
-
- spec/fixtures/search_killed_wife
|
164
|
-
- spec/fixtures/search_star_trek
|
165
|
-
- spec/fixtures/top_250
|
166
|
-
- spec/fixtures/tt0036855
|
167
|
-
- spec/fixtures/tt0083987
|
168
|
-
- spec/fixtures/tt0095016
|
169
|
-
- spec/fixtures/tt0110912
|
170
|
-
- spec/fixtures/tt0111161
|
171
|
-
- spec/fixtures/tt0117731
|
172
|
-
- spec/fixtures/tt0166222
|
173
|
-
- spec/fixtures/tt0242653
|
174
|
-
- spec/fixtures/tt0330508
|
175
|
-
- spec/fixtures/tt0468569
|
176
|
-
- spec/fixtures/tt1401252
|
177
|
-
- spec/imdb/cli_spec.rb
|
178
|
-
- spec/imdb/movie_spec.rb
|
179
|
-
- spec/imdb/search_spec.rb
|
180
|
-
- spec/imdb/top_250_spec.rb
|
181
|
-
- spec/spec.opts
|
182
|
-
- spec/spec_helper.rb
|
161
|
+
test_files: []
|