html-proofer 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MGZjNTUyZGY2NWNjMzI5Y2MzZWJlMGIzNTQ0ZjZiZjg4ODJmZjMxMw==
5
- data.tar.gz: !binary |-
6
- YzE4OTgyMzQ1NDFiNmYzNjI5OWUzYmQzMjhkYzg0NTYwM2JiNTRlMg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZGE1MDg2YjI4ZmYzYTMzMzAwYzE1NmM5N2FiYTBiM2MyZjc1MzIxYjA5YTM3
10
- N2Y3YzE3ZDYwNGUwNGQ1YmNmYWQxYzk1ZDBjMWNlMWMwZWVhYWEyOGZiYWUx
11
- MGRmMjVjYjA1MjRlNjk4NDU4ZGMyYTRhMTYzOGFhMGI0OWU5NmE=
12
- data.tar.gz: !binary |-
13
- N2IzYTQ5NWYyYmRjZDk4ZmZiOTkwMjM2YmJiYTA4NzI3Yzc5ZWRmZWE2ODEx
14
- MWU3ODAyYjYyZGM1MzdhNDExN2M0OGFlNTA4YjA0MmQ5NmE3MTRjZWI5ODhl
15
- MmFjZmMzMzllZDBhZjMxZTdkNDNiZmUzNDQxNjMxY2ZiZGJkMWI=
2
+ SHA1:
3
+ metadata.gz: 0c6a1c51716811e1e38a4eef20a167b2490c5ab5
4
+ data.tar.gz: d7501e48d9ce855f3a0a75e0bc7794081b875609
5
+ SHA512:
6
+ metadata.gz: 60524eeedd9b6d31e8d0d629730e1f236b0ff8710b50bbad9444cf28bd275749c98295a54be40a73d32508d6b7d641b715358e57a21fd449d241fb3c75264355
7
+ data.tar.gz: 6cf390b2b717a84039a96a77c2693f0ea0941ff68c5b918f0ed288e18f545b5264c973fa1d8213ef0abebeb8c88d30a532ed8a023a27910690f740d9aac65a50
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,3 +1,11 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gemspec
3
+ gem "nokogiri", "1.6.0"
4
+ gem "typhoeus", "~> 0.6.3"
5
+ gem "colored", "~> 1.2"
6
+ gem 'rake'
7
+
8
+ group :test, :development do
9
+ gem "rspec", "~> 2.13.0"
10
+ gem "html-pipeline", "~> 0.0.12"
11
+ end
data/Gemfile.lock CHANGED
@@ -1,11 +1,3 @@
1
- PATH
2
- remote: .
3
- specs:
4
- html-proofer (0.0.14)
5
- colored (~> 1.2)
6
- nokogiri (= 1.6.0)
7
- typhoeus (~> 0.6.3)
8
-
9
1
  GEM
10
2
  remote: http://rubygems.org/
11
3
  specs:
@@ -40,6 +32,7 @@ GEM
40
32
  multi_json (1.7.7)
41
33
  nokogiri (1.6.0)
42
34
  mini_portile (~> 0.5.0)
35
+ rake (10.1.0)
43
36
  rinku (1.7.3)
44
37
  rspec (2.13.0)
45
38
  rspec-core (~> 2.13.0)
@@ -61,6 +54,9 @@ PLATFORMS
61
54
  ruby
62
55
 
63
56
  DEPENDENCIES
57
+ colored (~> 1.2)
64
58
  html-pipeline (~> 0.0.12)
65
- html-proofer!
59
+ nokogiri (= 1.6.0)
60
+ rake
66
61
  rspec (~> 2.13.0)
62
+ typhoeus (~> 0.6.3)
data/README.md CHANGED
@@ -4,6 +4,8 @@ Generate HTML files? Use them for documentation? Great, then this tool might be
4
4
 
5
5
  Here are a set of tests to validate your HTML output. These tests check if your image references are legitimate, if they have alt tags, if your internal links are working, and so on. It's intended to be an all-in-one checker for your documentation output.
6
6
 
7
+ [![Build Status](https://travis-ci.org/gjtorikian/html-proofer.png?branch=master)](https://travis-ci.org/gjtorikian/html-proofer)
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require 'bundler'
2
- Bundler::GemHelper.install_tasks
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
data/html-proofer.gemspec CHANGED
@@ -13,11 +13,4 @@ Gem::Specification.new do |gem|
13
13
  gem.files = `git ls-files`.split($/)
14
14
  gem.test_files = gem.files.grep(%r{^(spec)/})
15
15
  gem.require_paths = ["lib"]
16
-
17
- gem.add_dependency "nokogiri", "1.6.0"
18
- gem.add_dependency "colored", "~> 1.2"
19
- gem.add_dependency "typhoeus", "~> 0.6.3"
20
-
21
- gem.add_development_dependency "html-pipeline", "~> 0.0.12"
22
- gem.add_development_dependency "rspec", "~> 2.13.0"
23
16
  end
data/lib/html/proofer.rb CHANGED
@@ -41,6 +41,7 @@ module HTML
41
41
  end
42
42
 
43
43
  def self.create_nokogiri(path)
44
+ path << "index.html" if File.directory? path #support for Jekyll-style links
44
45
  Nokogiri::HTML(File.read(path))
45
46
  end
46
47
 
@@ -7,7 +7,7 @@ class Links < ::HTML::Proofer::Checks::Check
7
7
  href = a['href']
8
8
 
9
9
  if href && href.length > 0
10
- if @options[:href_swap]
10
+ if @options[:href_swap]
11
11
  @options[:href_swap].each do |link, replace|
12
12
  href = href.gsub(link, replace)
13
13
  end
@@ -20,15 +20,15 @@ class Links < ::HTML::Proofer::Checks::Check
20
20
  end
21
21
  if !external_href?(href)
22
22
  # an internal link, with a hash
23
- if href_split
23
+ if href_split && !href_split.empty?
24
24
  href_file = href_split[0]
25
25
  href_hash = href_split[1]
26
26
 
27
27
  # it's not an internal hash; it's pointing to some other file
28
28
  if href_file.length > 0
29
- href_location = File.join(File.dirname(@path), href_file)
29
+ href_location = resolve_path File.join(File.dirname(@path), href_file)
30
30
  if !File.exist?(href_location)
31
- self.add_issue("#{@path}".blue + ": internal link #{href_location} does not exist")
31
+ self.add_issue("#{@path}".blue + ": internal link #{href_location} does not exist")
32
32
  else
33
33
  href_html = HTML::Proofer.create_nokogiri(href_location)
34
34
  found_hash_match = false
@@ -44,7 +44,8 @@ class Links < ::HTML::Proofer::Checks::Check
44
44
  end
45
45
  # internal link, no hash
46
46
  else
47
- self.add_issue("#{@path}".blue + ": internally linking to #{href}, which does not exist") unless File.exist?(File.join(File.dirname(@path), href))
47
+ href_location = resolve_path File.join(File.dirname(@path), href)
48
+ self.add_issue("#{@path}".blue + ": internally linking to #{href_location}, which does not exist") unless File.exist?(href_location)
48
49
  end
49
50
  else
50
51
  validate_url(href, "#{@path}".blue + ": externally linking to #{href}, which does not exist")
@@ -58,4 +59,10 @@ class Links < ::HTML::Proofer::Checks::Check
58
59
  def hash_check(html, href_hash)
59
60
  html.xpath("//*[@id='#{href_hash}']", "//*[@name='#{href_hash}']").length > 0
60
61
  end
62
+
63
+ #support for implicit /index.html in URLs
64
+ def resolve_path(path)
65
+ path << "index.html" if File.directory? path
66
+ path
67
+ end
61
68
  end
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Proofer
3
- VERSION = "0.0.14"
3
+ VERSION = "0.0.15"
4
4
  end
5
5
  end
File without changes
@@ -0,0 +1 @@
1
+ root.
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <p>Blah blah blah. <a href="folder/">A pretty permlaink!</a></p>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <p>Blah blah blah. <a href="/">I am root.</a></p>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -29,7 +29,7 @@ describe "Links tests" do
29
29
  brokenLinkInternalFilepath = "#{FIXTURES_DIR}/brokenLinkInternal.html"
30
30
  @linkCheck = Links.new(brokenLinkInternalFilepath, HTML::Proofer.create_nokogiri(brokenLinkInternalFilepath))
31
31
  @linkCheck.run
32
- @linkCheck.issues[0].should eq("spec/html/proofer/fixtures/brokenLinkInternal.html".blue + ": internally linking to ./notreal.html, which does not exist")
32
+ @linkCheck.issues[0].should eq("spec/html/proofer/fixtures/brokenLinkInternal.html".blue + ": internally linking to spec/html/proofer/fixtures/./notreal.html, which does not exist")
33
33
  end
34
34
 
35
35
  it "fails for link with no href" do
@@ -59,4 +59,18 @@ describe "Links tests" do
59
59
  @linkCheck.run
60
60
  @linkCheck.issues[0].should eq(nil)
61
61
  end
62
+
63
+ it 'properly resolves implicit /index.html in link paths' do
64
+ linkToFolder = "#{FIXTURES_DIR}/linkToFolder.html"
65
+ @linkCheck = Links.new(linkToFolder, HTML::Proofer.create_nokogiri(linkToFolder))
66
+ @linkCheck.run
67
+ @linkCheck.issues[0].should eq(nil)
68
+ end
69
+
70
+ it 'properly checks links to root' do
71
+ rootLink = "#{FIXTURES_DIR}/rootLink.html"
72
+ @linkCheck = Links.new(rootLink, HTML::Proofer.create_nokogiri(rootLink))
73
+ @linkCheck.run
74
+ @linkCheck.issues[0].should eq(nil)
75
+ end
62
76
  end
metadata CHANGED
@@ -1,85 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-proofer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-29 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 1.6.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 1.6.0
27
- - !ruby/object:Gem::Dependency
28
- name: colored
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '1.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '1.2'
41
- - !ruby/object:Gem::Dependency
42
- name: typhoeus
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 0.6.3
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.6.3
55
- - !ruby/object:Gem::Dependency
56
- name: html-pipeline
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 0.0.12
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 0.0.12
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: 2.13.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: 2.13.0
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description: Test your rendered HTML files to make sure they're accurate.
84
14
  email:
85
15
  - gjtorikian@gmail.com
@@ -88,6 +18,7 @@ extensions: []
88
18
  extra_rdoc_files: []
89
19
  files:
90
20
  - .gitignore
21
+ - .travis.yml
91
22
  - Gemfile
92
23
  - Gemfile.lock
93
24
  - LICENSE.txt
@@ -108,7 +39,10 @@ files:
108
39
  - spec/html/proofer/fixtures/brokenLinkInternal.html
109
40
  - spec/html/proofer/fixtures/brokenLinkWithNumber.html
110
41
  - spec/html/proofer/fixtures/existingImageExternal.html
42
+ - spec/html/proofer/fixtures/folder/index.html
111
43
  - spec/html/proofer/fixtures/gpl.png
44
+ - spec/html/proofer/fixtures/index.html
45
+ - spec/html/proofer/fixtures/linkToFolder.html
112
46
  - spec/html/proofer/fixtures/linkWithHttps.html
113
47
  - spec/html/proofer/fixtures/linkWithRedirect.html
114
48
  - spec/html/proofer/fixtures/missingImageAlt.html
@@ -118,6 +52,7 @@ files:
118
52
  - spec/html/proofer/fixtures/missingImageInternal.html
119
53
  - spec/html/proofer/fixtures/missingImageSrc.html
120
54
  - spec/html/proofer/fixtures/missingLinkHref.html
55
+ - spec/html/proofer/fixtures/rootLink.html
121
56
  - spec/html/proofer/fixtures/terribleImageName.html
122
57
  - spec/html/proofer/images_spec.rb
123
58
  - spec/html/proofer/links_spec.rb
@@ -132,12 +67,12 @@ require_paths:
132
67
  - lib
133
68
  required_ruby_version: !ruby/object:Gem::Requirement
134
69
  requirements:
135
- - - ! '>='
70
+ - - '>='
136
71
  - !ruby/object:Gem::Version
137
72
  version: '0'
138
73
  required_rubygems_version: !ruby/object:Gem::Requirement
139
74
  requirements:
140
- - - ! '>='
75
+ - - '>='
141
76
  - !ruby/object:Gem::Version
142
77
  version: '0'
143
78
  requirements: []
@@ -156,7 +91,10 @@ test_files:
156
91
  - spec/html/proofer/fixtures/brokenLinkInternal.html
157
92
  - spec/html/proofer/fixtures/brokenLinkWithNumber.html
158
93
  - spec/html/proofer/fixtures/existingImageExternal.html
94
+ - spec/html/proofer/fixtures/folder/index.html
159
95
  - spec/html/proofer/fixtures/gpl.png
96
+ - spec/html/proofer/fixtures/index.html
97
+ - spec/html/proofer/fixtures/linkToFolder.html
160
98
  - spec/html/proofer/fixtures/linkWithHttps.html
161
99
  - spec/html/proofer/fixtures/linkWithRedirect.html
162
100
  - spec/html/proofer/fixtures/missingImageAlt.html
@@ -166,6 +104,7 @@ test_files:
166
104
  - spec/html/proofer/fixtures/missingImageInternal.html
167
105
  - spec/html/proofer/fixtures/missingImageSrc.html
168
106
  - spec/html/proofer/fixtures/missingLinkHref.html
107
+ - spec/html/proofer/fixtures/rootLink.html
169
108
  - spec/html/proofer/fixtures/terribleImageName.html
170
109
  - spec/html/proofer/images_spec.rb
171
110
  - spec/html/proofer/links_spec.rb