Class: Html::Proofer::MailtoAwesome::MailToAwesome

Inherits:
HTMLProofer::Check
  • Object
show all
Defined in:
lib/mailto_awesome.rb

Instance Method Summary collapse

Instance Method Details

#awesome?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/mailto_awesome.rb', line 13

def awesome?
  @link.href.downcase.include? 'subject=' and @link.href.downcase.include? 'body='
end

#mailto?Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/mailto_awesome.rb', line 8

def mailto?
  return false if @link.ignore? || @link.href.nil?
  @link.href.match /^mailto:/i
end

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mailto_awesome.rb', line 17

def run
  return unless @options[:check_mailto_awesome]
  @html.css('a').each do |node|
    @link = create_element(node)
    line = node.line
    content = node.to_s
      
    if mailto? && !awesome?
      add_issue("This is a not-awesome mailto link!", line: line, content: content)
    end
  end
end