Sha256: 971edf6aa42c435f25355e1cc650c681dce7e52476947af0f4fb21e392294cab

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8
require 'net/http'
require 'net/https'
require 'timeout'
require 'uri'
require 'colored'
require 'typhoeus'

class HTML::Proofer::Checks

  class Check

    attr_reader :issues, :src, :path, :options, :external_urls, :additional_href_ignores

    def initialize(src, path, html, opts={})
      @src    = src
      @path   = path
      @html   = html
      @options = opts
      @issues = []
      @additional_href_ignores = @options[:href_ignore]
      @external_urls = {}
    end

    def run
      raise NotImplementedError.new("HTML::Proofer::Check subclasses must implement #run")
    end

    def add_issue(desc)
      @issues << "#{@path.blue}: #{desc}"
    end

    def output_filenames
      Dir[@site.config[:output_dir] + '/**/*'].select{ |f| File.file?(f) }
    end

    def add_to_external_urls(href)
      if @external_urls[href]
        @external_urls[href] << @path
      else
        @external_urls[href] = [@path]
      end
    end

    def self.subclasses
      classes = []

      ObjectSpace.each_object(Class) do |c|
        next unless c.superclass == self
        classes << c
      end

      classes
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
html-proofer-0.9.0 lib/html/proofer/check.rb
html-proofer-0.8.0 lib/html/proofer/check.rb
html-proofer-0.7.3 lib/html/proofer/check.rb
html-proofer-0.7.2 lib/html/proofer/check.rb
html-proofer-0.7.1 lib/html/proofer/check.rb
html-proofer-0.7.0 lib/html/proofer/check.rb
html-proofer-0.6.8 lib/html/proofer/check.rb
html-proofer-0.6.7 lib/html/proofer/check.rb
html-proofer-0.6.6 lib/html/proofer/check.rb
html-proofer-0.6.5 lib/html/proofer/check.rb
html-proofer-0.6.4 lib/html/proofer/check.rb
html-proofer-0.6.2 lib/html/proofer/check.rb
html-proofer-0.6.1 lib/html/proofer/check.rb
html-proofer-0.6.0 lib/html/proofer/check.rb
html-proofer-0.5.0 lib/html/proofer/check.rb
html-proofer-0.4.1 lib/html/proofer/check.rb
html-proofer-0.4.0 lib/html/proofer/check.rb