Class: HTML::Proofer::Checks::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/html/proofer/check.rb

Direct Known Subclasses

Favicons, Html, Images, Links, Scripts

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, path, html, opts = {}) ⇒ Check

Returns a new instance of Check.


14
15
16
17
18
19
20
21
22
23
# File 'lib/html/proofer/check.rb', line 14

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

Instance Attribute Details

#additional_alt_ignoresObject (readonly)

Returns the value of attribute additional_alt_ignores


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def additional_alt_ignores
  @additional_alt_ignores
end

#additional_href_ignoresObject (readonly)

Returns the value of attribute additional_href_ignores


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def additional_href_ignores
  @additional_href_ignores
end

#external_urlsObject (readonly)

Returns the value of attribute external_urls


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def external_urls
  @external_urls
end

#issuesObject (readonly)

Returns the value of attribute issues


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def issues
  @issues
end

#optionsObject (readonly)

Returns the value of attribute options


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def path
  @path
end

#srcObject (readonly)

Returns the value of attribute src


12
13
14
# File 'lib/html/proofer/check.rb', line 12

def src
  @src
end

Class Method Details

.subclassesObject


45
46
47
48
49
50
51
52
53
54
# File 'lib/html/proofer/check.rb', line 45

def self.subclasses
  classes = []

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

  classes
end

Instance Method Details

#add_issue(desc, status = -1)) ⇒ Object


29
30
31
# File 'lib/html/proofer/check.rb', line 29

def add_issue(desc, status = -1)
  @issues << Issue.new(@path, desc, status)
end

#add_to_external_urls(href) ⇒ Object


37
38
39
40
41
42
43
# File 'lib/html/proofer/check.rb', line 37

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

#output_filenamesObject


33
34
35
# File 'lib/html/proofer/check.rb', line 33

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

#runObject

Raises:

  • (NotImplementedError)

25
26
27
# File 'lib/html/proofer/check.rb', line 25

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