Exception: Grubby::Scraper::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/grubby/scraper.rb

Constant Summary collapse

BACKTRACE_CLEANER =
ActiveSupport::BacktraceCleaner.new.tap do |cleaner|
  cleaner.add_silencer do |line|
    line.include?(__dir__) && line.include?("scraper.rb:")
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scraper) ⇒ Error



249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/grubby/scraper.rb', line 249

def initialize(scraper)
  self.scraper = scraper

  listing = scraper.errors.
    reject{|field, error| error.is_a?(FieldScrapeFailedError) }.
    map do |field, error|
      "* `#{field}` (#{error.class})\n" +
        error.message.indent(2) + "\n\n" +
        BACKTRACE_CLEANER.clean(error.backtrace).join("\n").indent(4) + "\n"
    end.
    join("\n")

  super("Failed to scrape the following fields:\n#{listing}")
end

Instance Attribute Details

#scraperGrubby::Scraper



247
248
249
# File 'lib/grubby/scraper.rb', line 247

def scraper
  @scraper
end