Skip to content
Browse files

serialization fix

  • Loading branch information...
1 parent 3a7b18a commit 00c5acd94dddcd0d413412a5715a3d3f03791bc5 root committed May 30, 2010
Showing with 24 additions and 22 deletions.
  1. +1 −0 Rakefile
  2. +0 −1 lib/imdb.rb
  3. +12 −12 lib/imdb/movie.rb
  4. +2 −2 lib/imdb/search.rb
  5. +4 −5 lib/imdb/skeleton.rb
  6. +5 −2 ruby-imdb.gemspec
View
1 Rakefile
@@ -15,6 +15,7 @@ begin
s.add_dependency "mongo", ">= 1.0.1"
s.add_dependency "mongo_mapper", ">= 0.7.5"
s.add_dependency "chronic", ">= 0.2.3"
+ #s.add_dependency "rack", ">= 1.1.0"
end
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
View
1 lib/imdb.rb
@@ -19,4 +19,3 @@ def to_hash(default=nil)
require "imdb/movie"
require "imdb/person"
-
View
24 lib/imdb/movie.rb
@@ -12,9 +12,9 @@ def initialize(id_of)
super("Movie", {:imdb_id => String,
:poster => String,
:title => String,
+ :release_date => String,
:cast => Array,
:photos => Array,
- :release_date => String,
:director => String,
:genres => Array,
:writers => Array}, [:imdb_id])
@@ -51,21 +51,21 @@ def cast
# Get movie photos
# @return [Array]
def photos
- doc.search("img").map { |img|
- unless img["src"][/_CR/].nil?
- img["src"]
- end
- }.compact
- rescue
- nil
-
+ begin
+ doc.search("img").map { |img|
+ unless img["src"][/_CR/].nil?
+ img["src"]
+ end
+ }
+ rescue
+ nil
+ end
end
# Get release date
# @return [String]
def release_date
- Date.parse(Chronic.parse(doc.xpath("//h5[contains(., 'Release Date')]/..").first.content[/^\d{1,2} \w+ \d{4}/]).strftime('%Y/%m/%d'))
- rescue nil
+ Date.parse(Chronic.parse(doc.xpath("//h5[contains(., 'Release Date')]/..").first.content[/^\d{1,2} \w+ \d{4}/]).strftime('%Y/%m/%d')).to_s rescue nil
end
# Get Director
@@ -90,7 +90,7 @@ def writers
doc.xpath("//a[@name='writers']/../../../..").search('a[@href^="/name/nm"]').map {|w|
name = w.content
profile = w['href']
- IMDB::Person.new(@imdb_id, name, nil, profile, nil)
+ IMDB::Person.new(@imdb_id, name, "nil", profile, "nil")
}
end
View
4 lib/imdb/search.rb
@@ -1,5 +1,5 @@
module IMDB
- class Search
+ class Search < IMDB::Skeleton
def self.movie(keyword)
doc = Nokogiri::HTML(open("http://www.imdb.com/find?s=tt&q=#{CGI.escape(keyword)}"))
ret_val = []
@@ -11,7 +11,7 @@ def self.movie(keyword)
end # Search
- class Result
+ class Result < IMDB::Skeleton
attr_accessor :id, :title, :link, :year
def initialize(id, title, link)
View
9 lib/imdb/skeleton.rb
@@ -28,14 +28,13 @@ def initialize(model_name = "", method_names = {}, keys = [])
end
if @db_query[meth].nil? or (@db_query[meth].length.zero? if @db_query[meth].kind_of?(Array))
-
a = send(old_meth)
if a.kind_of?(Array)
a.compact!
- a.map! {
- |c|
- c.to_hash
- }
+ #a.map! {
+ # |c|
+ # c.to_hash
+ #}.compact
@db_query[meth] = a
else
@db_query[meth] = a
View
7 ruby-imdb.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{ruby-imdb}
- s.version = "0.6.0"
+ s.version = "0.7.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Yalcin Acikyildiz"]
- s.date = %q{2010-05-21}
+ s.date = %q{2010-05-24}
s.description = %q{Ruby IMDB Parsing Library}
s.email = %q{yalcin@webliyacelebi.com}
s.extra_rdoc_files = [
@@ -62,17 +62,20 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<json>, [">= 1.4.3"])
s.add_runtime_dependency(%q<mongo>, [">= 1.0.1"])
s.add_runtime_dependency(%q<mongo_mapper>, [">= 0.7.5"])
+ s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
else
s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
s.add_dependency(%q<json>, [">= 1.4.3"])
s.add_dependency(%q<mongo>, [">= 1.0.1"])
s.add_dependency(%q<mongo_mapper>, [">= 0.7.5"])
+ s.add_dependency(%q<chronic>, [">= 0.2.3"])
end
else
s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
s.add_dependency(%q<json>, [">= 1.4.3"])
s.add_dependency(%q<mongo>, [">= 1.0.1"])
s.add_dependency(%q<mongo_mapper>, [">= 0.7.5"])
+ s.add_dependency(%q<chronic>, [">= 0.2.3"])
end
end

0 comments on commit 00c5acd

Please sign in to comment.
Something went wrong with that request. Please try again.