ruby-imdb 0.7.2 → 0.7.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/{README → README.md} +4 -2
- data/VERSION +1 -1
- data/lib/imdb/search.rb +36 -12
- data/ruby-imdb.gemspec +3 -3
- metadata +4 -4
data/{README → README.md}
RENAMED
@@ -28,7 +28,8 @@ IMDB::Configuration.db(:hostname => "localhost", :database => "imdb")
|
|
28
28
|
require 'rubygems'
|
29
29
|
require 'imdb'
|
30
30
|
|
31
|
-
IMDB::Search.
|
31
|
+
s = IMDB::Search.new
|
32
|
+
s.movie("fear and loathing in las vegas").each do
|
32
33
|
|result|
|
33
34
|
movie = IMDB::Movie.new(result.id)
|
34
35
|
p movie.title
|
@@ -44,10 +45,11 @@ p movie.poster
|
|
44
45
|
|
45
46
|
== Examples
|
46
47
|
|
47
|
-
Under
|
48
|
+
Are Under features directory
|
48
49
|
|
49
50
|
== Authors
|
50
51
|
* Yalcin ACIKYILDIZ (mailto:yalcin@webliyacelebi.com)
|
51
52
|
|
52
53
|
|
53
54
|
This library is released under the terms of the GNU/GPL.
|
55
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.3
|
data/lib/imdb/search.rb
CHANGED
@@ -1,23 +1,47 @@
|
|
1
1
|
module IMDB
|
2
|
-
class Search
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class Search
|
3
|
+
def movie(keyword)
|
4
|
+
doc = Nokogiri::HTML(open("http://www.imdb.com/find?s=tt&q=#{CGI.escape(keyword)}"))
|
5
|
+
@ret_val = []
|
6
|
+
doc.search('a[@href^="/title/tt"]').reject { |node|
|
7
|
+
@ret_val.push(IMDB::Result.new(node["href"][/\d+/], node.content, "http://www.imdb.com#{node['href']}")) unless node.content.blank?
|
8
|
+
}
|
9
|
+
@ret_val
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_hash
|
13
|
+
i = 0
|
14
|
+
tmp_hash = {}
|
15
|
+
@ret_val.each {|r|
|
16
|
+
tmp_hash[i] = r.to_hash
|
17
|
+
i = i + 1
|
8
18
|
}
|
9
|
-
|
10
|
-
|
19
|
+
tmp_hash
|
20
|
+
end
|
11
21
|
|
22
|
+
def to_json
|
23
|
+
to_hash.to_json
|
24
|
+
end
|
12
25
|
end # Search
|
13
26
|
|
14
27
|
class Result < IMDB::Skeleton
|
15
|
-
|
16
|
-
|
17
|
-
def initialize(id, title, link)
|
28
|
+
def initialize(imdb_id, title, link)
|
29
|
+
super("Result",{:title => String, :link => String, :imdb_id => String}, [:imdb_id])
|
18
30
|
@title = title
|
19
31
|
@link = link
|
20
|
-
@
|
32
|
+
@imdb_id = imdb_id
|
33
|
+
end
|
34
|
+
|
35
|
+
def title
|
36
|
+
@title
|
37
|
+
end
|
38
|
+
|
39
|
+
def link
|
40
|
+
@link
|
41
|
+
end
|
42
|
+
|
43
|
+
def imdb_id
|
44
|
+
@imdb_id
|
21
45
|
end
|
22
46
|
end
|
23
47
|
end
|
data/ruby-imdb.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-imdb}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Yalcin Acikyildiz"]
|
@@ -14,12 +14,12 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.email = %q{yalcin@webliyacelebi.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README"
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
21
21
|
"LICENSE",
|
22
|
-
"README",
|
22
|
+
"README.md",
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
25
|
"features/movie.feature",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 3
|
9
|
+
version: 0.7.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yalcin Acikyildiz
|
@@ -95,11 +95,11 @@ extensions: []
|
|
95
95
|
|
96
96
|
extra_rdoc_files:
|
97
97
|
- LICENSE
|
98
|
-
- README
|
98
|
+
- README.md
|
99
99
|
files:
|
100
100
|
- .gitignore
|
101
101
|
- LICENSE
|
102
|
-
- README
|
102
|
+
- README.md
|
103
103
|
- Rakefile
|
104
104
|
- VERSION
|
105
105
|
- features/movie.feature
|