class CheckSitemap::CommandLine

Public Class Methods

new(url_or_filename) click to toggle source
# File lib/check_sitemap/command_line.rb, line 3
def initialize(url_or_filename)
  @url_or_filename = url_or_filename
end

Public Instance Methods

process!() click to toggle source
# File lib/check_sitemap/command_line.rb, line 7
def process!
  reader = ::CheckSitemap::XMLReader.new(@url_or_filename)
  if reader.sitemap_index?
    reader.each do |url|
      queue << url
    end
    [].tap do |threads|
      ::CheckSitemap.config.num_threads.to_i.times do
        threads << Thread.new do
          until queue.empty?
            url = queue.pop(true) rescue nil
            if url
              ::CheckSitemap::CommandLine.new(url).process!
            end
          end
        end
      end
    end.each { |t| t.join }
  elsif reader.urlset?
    reader.each do |url|
      ::CheckSitemap.config.adapter.call(url)
    end
  end
end

Protected Instance Methods

queue() click to toggle source
# File lib/check_sitemap/command_line.rb, line 34
def queue
  @queue ||= Queue.new
end