Skip to content

Commit

Permalink
Add BGG game url to scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
martymcguire committed Oct 13, 2012
1 parent 424c1c2 commit 1c2f6ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/board_game_geek.rb
Expand Up @@ -34,13 +34,17 @@ def self.top_games how_many
release_date = name_and_date[2].to_s.strip[1..-2]
rating = cells[3]

game_path = game_row.css(".collection_thumbnail a").first["href"]
game_url = "http://boardgamegeek.com" + game_path

image_url = game_row.css(".collection_thumbnail img").first["src"]
image_url.sub!("_mt", "_t")

games << OpenStruct.new(name: name,
ranking: ranking,
rating: rating,
release_date: release_date,
url: game_url,
image_url: image_url)
end
end
Expand All @@ -53,4 +57,4 @@ def self.break_down_total total
end
end

BGG = BoardGameGeek
BGG = BoardGameGeek
3 changes: 2 additions & 1 deletion spec/scraper_spec.rb
Expand Up @@ -39,6 +39,7 @@

it "exposes some handy attributes" do
first_game.must_respond_to :name
first_game.must_respond_to :url
first_game.must_respond_to :image_url
first_game.must_respond_to :rating
first_game.must_respond_to :ranking
Expand All @@ -59,4 +60,4 @@
VCR.insert_cassette('board_game_geek_1000')
subject.top_games(1000).length.must_be :==, 1000
end
end
end

0 comments on commit 1c2f6ab

Please sign in to comment.