blinkr 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ae9d41b67344e89b2be1a9114913c387bfe0137
4
- data.tar.gz: adb4a85a366617189d158bcd3296ea31d0fd6a04
3
+ metadata.gz: 1aea80c9c477eab4ce09539b9b697ef2401a33b0
4
+ data.tar.gz: 7d57e314a280981c97c9829f975bd138ba65302d
5
5
  SHA512:
6
- metadata.gz: 0a4d6eb3adf7dd35fc7a98f2c192cc6b8f04cee7536a06cec3559c617ebc172ede2c53366aa7818541b823937d5511c7265c3a14726948eb495016cf25843ec4
7
- data.tar.gz: 30ddd5da3af3a0a4acaa03bda9096f40e7d9edb72529774d356f6907945aa9a389a2f0fd8d9edf2e9ae9b752363f7783241f44586b432e51309f50ce1eb30494
6
+ metadata.gz: d00baebd8c848e05d7501cc7fda16f79fc36ff98fdeb587850cfff6fe7c78f4b1c2e5f755223e18f5ce2f1196bcc2ae82900e772ac857d23750996fb59d698d6
7
+ data.tar.gz: 60701213a46677ac5bb75701ec7a09f4f9a0b9bc03fead126eb3296a2c8eb1b924548376f8a6fb48f394ea8c5d1b2becfe82afb7fb08eb271e45be095ee028f7
data/lib/blinkr/config.rb CHANGED
@@ -39,7 +39,14 @@ module Blinkr
39
39
  end
40
40
 
41
41
  def ignored? url, code, message
42
- ignores.any? { |ignore| ( !url.nil? && ignore.has_key?('url') ? !ignore['url'].match(url).nil? : true ) && ( !code.nil? && ignore.has_key?('code') ? ignore['code'] == code : true ) && ( !message.nil? && ignore.has_key?('message') ? !ignore['message'].match(message).nil? : true ) }
42
+ return false if uril.nil? || code.nil? || message.nil?
43
+
44
+ ignores.any? do |ignore|
45
+ return true if ignore.has_key?('url') && ignore['url'].match(url)
46
+ return true if ignore.has_key?('code') && ignore['code'] == code
47
+ return true if ignore.has_key?('message') && ignore['message'].match(message)
48
+ false
49
+ end
43
50
  end
44
51
 
45
52
  def skipped? url
data/lib/blinkr/error.rb CHANGED
@@ -7,7 +7,7 @@ module Blinkr
7
7
  raise TypeError 'severity must be a string or symbol' unless opts[:severity].is_a?(String) || opts[:severity].is_a?(Symbol)
8
8
  raise 'severity not a recognized value' unless SEVERITY.include? opts[:severity].to_sym
9
9
 
10
- @severity = opts[:severity]
10
+ @severity = opts[:severity].to_sym
11
11
  @category = opts[:category]
12
12
  @type = opts[:type]
13
13
  @title = opts[:title]
@@ -10,7 +10,7 @@ module Blinkr
10
10
 
11
11
  def collect page
12
12
  page.body.css('img:not([alt])').each do |img|
13
- page.errors << OpenStruct.new({:severity => 'warning', :category => 'SEO',
13
+ page.errors << ::Blinkr::Error.new({:severity => :warning, :category => 'SEO',
14
14
  :type => '<img alt=""> missing',
15
15
  :title => "#{img['src']} (line #{img.line})",
16
16
  :message => '<img alt=""> missing', :snippet => img.to_s,
@@ -10,18 +10,20 @@ module Blinkr
10
10
 
11
11
  def collect page
12
12
  page.body.css('[style]').each do |elm|
13
+ elm_clone = Nokogiri.make(elm.to_s)
14
+ elm_clone.inner_html = ""
13
15
  if elm['style'] == ""
14
16
  page.errors << Blinkr::Error.new({:severity => 'info', :category => 'HTML Compatibility/Correctness',
15
17
  :type => 'style attribute is empty',
16
18
  :title => %Q{"#{elm['style']}" (line #{elm.line})},
17
- :message => 'style attribute is empty', :snippet => elm.to_s,
19
+ :message => 'style attribute is empty', :snippet => elm_clone.to_s,
18
20
  :icon => 'fa-info'})
19
21
  else
20
22
  page.errors << Blinkr::Error.new({:severity => 'info',
21
23
  :category => 'HTML Compatibility/Correctness',
22
24
  :type => 'Inline CSS detected',
23
25
  :title => %Q{"#{elm['style']}" (line #{elm.line})},
24
- :message => 'inline style', :snippet => elm.to_s,
26
+ :message => 'inline style', :snippet => elm_clone.to_s,
25
27
  :icon => 'fa-info'})
26
28
  end
27
29
  end
@@ -33,8 +33,8 @@ module Blinkr
33
33
  puts '----------------------'
34
34
  start = DateTime.now
35
35
 
36
- external_links = @links.reject { |k| k.start_with? @config.base_url }
37
36
  processed = 0
37
+
38
38
  # Find the internal links
39
39
  @links.select{|k| k.start_with? @config.base_url}.each do |url, locations|
40
40
  # TODO figure out what to do about relative links
@@ -59,32 +59,32 @@ module Blinkr
59
59
  })
60
60
  # It wasn't in the sitemap, so we'll add it to the "external_links" to still be checked
61
61
  end
62
- external_links[link.to_s] = locations
63
62
  end
64
63
  end
65
- external_links.each do |url, metadata|
64
+ @links.each do |url, metadata|
66
65
  # if link start_with? @config.base_url check to see if it's in the sitemap.xml
67
66
  browser.process(url, @config.max_retrys, :method => :get, :followlocation => true, :timeout => 30,
68
67
  :cookiefile => '_tmp/cookies', :cookiejar => '_tmp/cookies',
69
68
  :connecttimeout => 10, :maxredirs => 3) do |resp|
70
69
  puts "Loaded #{url} via #{browser.name} #{'(cached)' if resp.cached?}" if @config.verbose
71
70
 
72
- if resp.code.to_i < 200 || (resp.code.to_i > 300 && @config.warning_on_300s)
71
+ resp_code = resp.code.to_i
72
+ if resp_code < 200 || ((resp_code > 300 && resp_code < 400) && @config.warning_on_300s) || resp_code > 400
73
73
  response = resp
74
74
 
75
- metadata.each do |src|
76
- detail = nil
77
- if response.status_message.nil?
78
- message = response.return_message
79
- else
80
- message = response.status_message
81
- detail = response.return_message unless resp.return_message == 'No error'
82
- end
75
+ detail = nil
76
+ if response.status_message.nil?
77
+ message = response.return_message
78
+ else
79
+ message = response.status_message
80
+ detail = response.return_message unless resp.return_message == 'No error'
81
+ end
83
82
 
84
- severity = :danger
85
- if response.code.to_i >= 300 && response.code.to_i < 400
86
- severity = :warning
87
- end
83
+ severity = :danger
84
+ if response.code.to_i >= 300 && response.code.to_i < 400
85
+ severity = :warning
86
+ end
87
+ metadata.each do |src|
88
88
  src[:page].errors << Blinkr::Error.new({:severity => severity,
89
89
  :category => 'Resources missing',
90
90
  :type => '<a href=""> target cannot be loaded',
@@ -95,7 +95,7 @@ module Blinkr
95
95
  end
96
96
  end
97
97
  processed += 1
98
- puts "Processed #{processed} of #{external_links.size}" if @config.verbose
98
+ puts "Processed #{processed} of #{@links.size}" if @config.verbose
99
99
  end
100
100
  end
101
101
  browser.hydra.run if browser.is_a? Blinkr::TyphoeusWrapper
@@ -1,5 +1,4 @@
1
1
  require 'blinkr/error'
2
- require 'ostruct'
3
2
  require 'slim'
4
3
 
5
4
  module Blinkr
data/lib/blinkr/report.rb CHANGED
@@ -18,7 +18,6 @@ module Blinkr
18
18
  end
19
19
 
20
20
  def render
21
- @context.pages.delete_if { |_, page| page.errors.empty? }
22
21
  @context.total = 0
23
22
  @context.severity = {}
24
23
  @context.category = {}
@@ -1,4 +1,4 @@
1
1
  module Blinkr
2
- VERSION='0.3.5'
2
+ VERSION='0.3.6'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blinkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Muir
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-02 00:00:00.000000000 Z
12
+ date: 2015-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler