html-proofer 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf114815adfcc6b231c9f8b119d2e5c02dee4738
4
- data.tar.gz: 382848c036bf27e114796531c07c55c970f8b890
3
+ metadata.gz: 4bd65ec0e68209dd5779fe7fc1b7eb2ee685b67b
4
+ data.tar.gz: e2a1ba66e4ff4294d1cc13d7374c9319abfab422
5
5
  SHA512:
6
- metadata.gz: be3e69485788801d9ce34e6374eee233b2fe91553fc8051bd8fc96fa1d22792aba37b2b06d44a50a31fb50f832730a883006282e08c52bd917c7da003465b3b5
7
- data.tar.gz: 235a71993139147fa3a1909da8bfe25d23b1124fb9f5d4e676625650ed5a3b0381aa435957f5781284c386ab7365f425bc4099b784d0309b23f9761a9ae21939
6
+ metadata.gz: 775c6de3a7beb3bd5af2c9897fd3ce2497ffa6e5667e4fce5a7b90b49fa3ab847f78dba354cb7e9628e8fbc4fde5747a89565db0e61964e128262a7b003b347a
7
+ data.tar.gz: 8c7475082e66945cc1f3b821da41284a0a7500edb73f7902942a3873aaead54a6edf1e04018925a9aa80082a6bfbc086fd5980cc22414e5a792f16e0e0ab2b57
@@ -22,6 +22,7 @@ Mercenary.program(:htmlproofer) do |p|
22
22
  p.option 'check_favicon', '--check-favicon', 'Enables the favicon checker (default: `false`).'
23
23
  p.option 'check_html', '--check-html', 'Enables HTML validation errors from Nokogiri (default: `false`).'
24
24
  p.option 'check_img_http', '--check-img-http', 'Fails an image if it\'s marked as `http` (default: `false`).'
25
+ p.option 'check_opengraph', '--check-opengraph', 'Enables the Open Graph checker (default: `false`).'
25
26
  p.option 'directory_index_file', '--directory-index-file', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
26
27
  p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker, which can take a lot of time (default: `false`)'
27
28
  p.option 'empty_alt_ignore', '--empty-alt-ignore', 'If `true`, ignores images with empty alt tags'
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ class OpenGraphElement < ::HTMLProofer::Element
4
+ def src
5
+ @content
6
+ end
7
+
8
+ def url
9
+ src
10
+ end
11
+ end
12
+
13
+ class OpenGraphCheck < ::HTMLProofer::Check
14
+ def missing_src?
15
+ !@opengraph.src
16
+ end
17
+
18
+ def empty_src?
19
+ blank?(@opengraph.src)
20
+ end
21
+
22
+ def run
23
+ @html.css('meta[property="og:url"], meta[property="og:image"]').each do |m|
24
+ @opengraph = OpenGraphElement.new(m, self)
25
+
26
+ next if @opengraph.ignore?
27
+
28
+ # does the opengraph exist?
29
+ if missing_src?
30
+ add_issue('open graph has no content attribute', line: m.line, content: m.content)
31
+ elsif empty_src?
32
+ add_issue('open graph content attribute is empty', line: m.line, content: m.content)
33
+ elsif !@opengraph.valid?
34
+ add_issue("#{@opengraph.src} is an invalid URL", line: m.line)
35
+ elsif @opengraph.remote?
36
+ add_to_external_urls(@opengraph.url)
37
+ else
38
+ add_issue("internal open graph #{@opengraph.url} does not exist", line: m.line, content: m.content) unless @opengraph.exists?
39
+ end
40
+ end
41
+
42
+ external_urls
43
+ end
44
+ end
@@ -10,6 +10,7 @@ module HTMLProofer
10
10
  :check_favicon => false,
11
11
  :check_html => false,
12
12
  :check_img_http => false,
13
+ :check_opengraph => false,
13
14
  :checks_to_ignore => [],
14
15
  :directory_index_file => 'index.html',
15
16
  :disable_external => false,
@@ -150,6 +150,7 @@ module HTMLProofer
150
150
  @checks = HTMLProofer::Check.subchecks.map(&:name)
151
151
  @checks.delete('FaviconCheck') unless @options[:check_favicon]
152
152
  @checks.delete('HtmlCheck') unless @options[:check_html]
153
+ @checks.delete('OpenGraphCheck') unless @options[:check_opengraph]
153
154
  @options[:checks_to_ignore].each { |ignored| @checks.delete(ignored) }
154
155
  @checks
155
156
  end
@@ -1,3 +1,3 @@
1
1
  module HTMLProofer
2
- VERSION = '3.2.0'.freeze
2
+ VERSION = '3.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-proofer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -228,6 +228,7 @@ files:
228
228
  - lib/html-proofer/check/html.rb
229
229
  - lib/html-proofer/check/images.rb
230
230
  - lib/html-proofer/check/links.rb
231
+ - lib/html-proofer/check/opengraph.rb
231
232
  - lib/html-proofer/check/scripts.rb
232
233
  - lib/html-proofer/configuration.rb
233
234
  - lib/html-proofer/element.rb