class Utterson::Base

Attributes

errors[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/utterson/base.rb, line 9
def initialize(opts={})
  @dir = opts[:dir] || './'
  @root = opts[:root] || @dir
  @errors = {}
  @checked_urls = {}
  @stats = {errors: 0, files: 0, urls: 0}
end

Public Instance Methods

check() click to toggle source
# File lib/utterson/base.rb, line 17
def check
  bar = ProgressBar.create
  threads = []
  Dir.glob(File.join(@dir, '**/*.{html,htm}')) do |f|
    @stats[:files] += 1
    bar.total = @stats[:files]
    c = HtmlCheck.new(file: f, root: @root)
    c.when_done do |r|
      bar.increment
      @stats[:urls] = r[:urls]
      @errors.merge! r[:errors]
    end
    threads << c.run
  end
  threads.each {|t| t.join}
  print_results
end
print_results() click to toggle source