mirror of https://github.com/freeCodeCamp/devdocs
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.
28 lines
820 B
28 lines
820 B
8 years ago
|
# 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.kilobyte.to_f).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
|