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.



5
6
7
# File 'lib/blinkr/extensions/inline_css.rb', line 5

def initialize config
  @config = config
end

Instance Method Details

#collect(page) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/blinkr/extensions/inline_css.rb', line 9

def collect page
  page.body.css('[style]').each do |elm|
    if elm['style'] == ""
      page.errors << OpenStruct.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 << OpenStruct.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