You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/lib/docs/subscribers/image_subscriber.rb

28 lines
812 B

# frozen_string_literal: true
module Docs
class ImageSubscriber < Subscriber
self.namespace = 'image'
def broken(event)
log "Skipped broken image (#{event.payload[:code]}): #{event.payload[:url]}"
end
def invalid(event)
log "Skipped invalid image (#{event.payload[:content_type]}): #{event.payload[:url]}"
end
def too_big(event)
log "Skipped large image (#{(event.payload[:size] / 1_000.0).round} KB): #{event.payload[:url]}"
end
def error(event)
exception = event.payload[:exception]
log "ERROR: #{event.payload[:url]}"
puts " #{exception.class}: #{exception.message.gsub("\n", "\n ")}"
puts exception.backtrace.select { |line| line.start_with?(Docs.root_path) }.join("\n ").prepend("\n ")
puts "\n"
end
end
end