Skip to content

Commit

Permalink
New id hash since reviews don't have id anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Garneau committed Aug 16, 2011
1 parent 3994022 commit 75de772
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lib/peekapp/ratings.rb
Expand Up @@ -45,6 +45,8 @@ def self.parse data # {{{

class Rating

attr_accessor :data

def initialize data # {{{
@data = data
end # }}}
Expand Down
13 changes: 6 additions & 7 deletions lib/peekapp/reviews.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(" ", ""),
Expand All @@ -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.