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



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/grubby/scraper.rb', line 110

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



108
109
110
# File 'lib/grubby/scraper.rb', line 108

def scraper
  @scraper
end