Permalink
Browse files

New id hash since reviews don't have id anymore.

  • Loading branch information...
1 parent 3994022 commit 75de77242a92c23f387b87e798d9e6d5f89034a7 Samuel Garneau committed Aug 16, 2011
Showing with 8 additions and 7 deletions.
  1. +2 −0 lib/peekapp/ratings.rb
  2. +6 −7 lib/peekapp/reviews.rb
View
@@ -45,6 +45,8 @@ def self.parse data # {{{
class Rating
+ attr_accessor :data
+
def initialize data # {{{
@data = data
end # }}}
View
@@ -15,7 +15,7 @@ def self.from_app id, stores, options = {} # {{{
}
dom = Peekapp::query args
begin
- nb_page = Nokogiri::HTML.parse(dom).css("div.paginated-content").first["total-number-of-pages"].to_i
+ nb_page = Nokogiri::HTML.parse(dom).css("div.paginated-content").first["total-number-of-pages"].to_i
rescue
raise ReviewsUnavailableForThisApp
end
@@ -24,7 +24,7 @@ def self.from_app id, stores, options = {} # {{{
args[:page] = z+1
dom = Peekapp::query args if z > 0
parse(dom).each do |p|
- raise LatestReviewReached if p.id === options[:latest_review_id].to_s
+ raise LatestReviewReached if options[:latest_review_hash] and p.id == options[:latest_review_hash]
reviews << p
end
end
@@ -41,7 +41,6 @@ def self.parse data # {{{
dom.css("div.customer-review").each do |r|
# That's some ugly stuff... I know
reviews << Review.new({
- :id => r.css("a.report").first["href"].split("=").last,
:title => r.css("span.customerReviewTitle").children.to_s,
:comment => r.css("p.content").children.to_s.gsub("\n", "").gsub(" ", ""),
:username => r.css("a.reviewer").children.to_s.gsub("\n", "").gsub(" ", ""),
@@ -62,14 +61,14 @@ def initialize data # {{{
@data = data
end # }}}
- def id # {{{
- @data[:id]
- end # }}}
-
def method_missing method # {{{
@data[method.to_sym]
end # }}}
+ def id # {{{
+ (Digest::SHA256.new << self.username + self.title).to_s
+ end # }}}
+
end
end

0 comments on commit 75de772

Please sign in to comment.