Sha256: 9fe1fb76cc149a3048347d50569812eea88f69c641288371d7713143db4ecd25

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 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, :additional_alt_ignores

    def initialize(src, path, html, opts={})
      @src    = src
      @path   = path
      @html   = html
      @options = opts
      @issues = []
      @additional_href_ignores = @options[:href_ignore]
      @additional_alt_ignores = @options[:alt_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

5 entries across 5 versions & 1 rubygems

Version Path
html-proofer-1.1.3 lib/html/proofer/check.rb
html-proofer-1.1.2 lib/html/proofer/check.rb
html-proofer-1.1.1 lib/html/proofer/check.rb
html-proofer-1.1.0 lib/html/proofer/check.rb
html-proofer-1.0.0 lib/html/proofer/check.rb