Sha256: 4182587933476a8fa7e216095cf10a7ce3036c82d65851dcdb0f2312e314e845
Contents?: true
Size: 992 Bytes
Versions: 2
Compression:
Stored size: 992 Bytes
Contents
require "typhoeus" require "sitemap_check/logger" require "colorize" class SitemapCheck class Page def initialize(url, logger = Logger.new) self.url = url self.request = Typhoeus::Request.new(self.url, method: :head, followlocation: true) self.logger = logger setup_callbacks end attr_reader :url, :request, :exists, :error protected attr_writer :url, :request attr_accessor :logger def setup_callbacks # rubocop:disable Metrics/AbcSize request.on_complete do |response| if response.success? @exists = true elsif response.timed_out? @exists = true logger.log " warning: request to #{url} timed out".magenta elsif response.code == 404 @exists = false logger.log " missing: #{url}".magenta else @error = true logger.log " error: (#{response.code}) while connecting to #{url}".magenta end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sitemap_check-0.1.8 | lib/sitemap_check/page.rb |
sitemap_check-0.1.7 | lib/sitemap_check/page.rb |