Skip to content

Commit

Permalink
Reduce duplication in scraper models
Browse files Browse the repository at this point in the history
  • Loading branch information
corincerami committed Jun 20, 2015
1 parent 9f61d9c commit 0e1f15e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 106 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ task scrape_curiosity: :environment do
end

task scrape_opportunity: :environment do
OpportunityScraper.new.scrape
OpportunitySpiritScraper.new("Opportunity").scrape
end

task scrape_spirit: :environment do
SpiritScraper.new.scrape
OpportunitySpiritScraper.new("Spirit").scrape
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class OpportunityScraper
class OpportunitySpiritScraper
BASE_URI = "http://mars.nasa.gov/mer/gallery/all/"

def initialize
@rover = Rover.find_by(name: "Opportunity")
def initialize(rover)
@rover = Rover.find_by(name: rover)
end

SOL_SELECT_CSS_PATHS = [
Expand All @@ -28,7 +28,8 @@ def scrape
end

def main_page
Nokogiri::HTML(open(BASE_URI + "opportunity.html"))
rover_html = "#{@rover.name.downcase}.html"
Nokogiri::HTML(open(BASE_URI + rover_html))
end

def sol_paths
Expand Down
92 changes: 0 additions & 92 deletions app/models/spirit_scraper.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/opportunity_scraper_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/models/spirit_scraper_spec.rb

This file was deleted.

0 comments on commit 0e1f15e

Please sign in to comment.