lib/opml_janitor.rb
def validate!(since = nil)
      # this threading methodology is highly expensive for simple blocks, but a life-saver for IO-bound blocks
      @work_queue = Queue.new
      data = @opml.css("body").children
      boss = Thread.new do
        filter!(data)
      end
      
      workers = (0...@threads).map do
        @work_queue.push(false) # this will end each thread
        Thread.new do
          begin
            while work = @work_queue.pop()
              val = validate_callback(work[:outline], since)
              spaces = 80 - work[:outline][:xml_url].length
              spaces = 1 if spaces < 1
              puts "#{work[:outline][:xml_url]}#{' ' * spaces}#{val}" if @debug
              unless val == "PASS"
                work[:node].unlink
              end
            end
          rescue ThreadError
          end
        end
      end
      boss.join
      workers.map(&:join)
    end
##
# validate! takes in one argument, +since+, specifing a Time object. Since is used to check if any posts have been posted since that time, thus detecting "stale" blogs/rss feeds 
validate. takes in one argument, +since+, specifing a Time object. Since is used to check if any posts have been posted since that time, thus detecting "stale" blogs/rss feeds
validate . takes in one argument + since + specifing a Time object . Since is used to check if any posts have been posted since that time thus detecting " stale " blogs / rss feeds
def validate!(since = nil)
      @work_queue = Queue.new
      data = @opml.css("body").children
      boss = Thread.new do
        filter!(data)
      end
      workers = (0...@threads).map do
        @work_queue.push(false) 
        Thread.new do
          begin
            while work = @work_queue.pop()
              val = validate_callback(work[:outline], since)
              spaces = 80 - work[:outline][:xml_url].length
              spaces = 1 if spaces < 1
              puts "#{work[:outline][:xml_url]}#{' ' * spaces}#{val}" if @debug
              unless val == "PASS"
                work[:node].unlink
              end
            end
          rescue ThreadError
          end
        end
      end
      boss.join
      workers.map(&:join)
    end
def validate! ( since = nil ) @work_queue = Queue . new data = @opml . css ( "body" ) . children boss = Thread . new do filter! ( data ) end workers = ( 0 ... @threads ) . map do @work_queue . push ( false ) Thread . new do begin while work = @work_queue . pop ( ) val = validate_callback ( work [ :outline ] , since ) spaces = 80 - work [ :outline ] [ :xml_url ] . length spaces = 1 if spaces < 1 puts "#{work[:outline][:xml_url]}#{' ' * spaces}#{val}" if @debug unless val == "PASS" work [ :node ] . unlink end end rescue ThreadError end end end boss . join workers . map ( & :join ) end
validate!
validate!
# this threading methodology is highly expensive for simple blocks, but a life-saver for IO-bound blocks # this will end each thread
since