Class: Blinkr::Extensions::InlineCss

Inherits:
Object
  • Object
show all
Defined in:
lib/blinkr/extensions/inline_css.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ InlineCss

Returns a new instance of InlineCss.



7
8
9
# File 'lib/blinkr/extensions/inline_css.rb', line 7

def initialize config
  @config = config
end

Instance Method Details

#collect(page) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/blinkr/extensions/inline_css.rb', line 11

def collect page
  page.body.css('[style]').each do |elm|
    if elm['style'] == ""
      page.errors << Blinkr::Error.new({:severity => 'info', :category => 'HTML Compatibility/Correctness',
                                        :type => 'style attribute is empty',
                                        :title => %Q{"#{elm['style']}" (line #{elm.line})},
                                        :message => 'style attribute is empty', :snippet => elm.to_s,
                                        :icon => 'fa-info'})
    else
      page.errors << Blinkr::Error.new({:severity => 'info',
                                        :category => 'HTML Compatibility/Correctness',
                                        :type => 'Inline CSS detected',
                                        :title => %Q{"#{elm['style']}" (line #{elm.line})},
                                        :message => 'inline style', :snippet => elm.to_s,
                                        :icon => 'fa-info'})
    end
  end
end