markdown_proofer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CONTRIBUTING.md +6 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +12 -0
- data/lib/markdown_proofer/rake_task.rb +27 -0
- data/lib/markdown_proofer/version.rb +3 -0
- data/lib/markdown_proofer.rb +96 -0
- data/markdown_proofer.gemspec +31 -0
- data/spec/cassettes/all.yml +181 -0
- data/spec/fixtures/broken_link.md +1 -0
- data/spec/fixtures/relative_link.md +1 -0
- data/spec/fixtures/working_link.md +1 -0
- data/spec/markdown_proofer_spec.rb +77 -0
- data/spec/rake_task_spec.rb +10 -0
- data/spec/spec_helper.rb +19 -0
- metadata +197 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ccb65b045f3452c5a17722b6f8c463b9954d8dec
|
4
|
+
data.tar.gz: c2ee0b5d3af41ad7c04ae34ed202c8d70d12796a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6245c341286a73f533a0ca32ba3851da9509b397a6f81c414076920dba97e093bc2852912c1a4403350153c7113e7624b7fb9dcec92178dd4d063023075c14c
|
7
|
+
data.tar.gz: f3aa8a08a601c620788ce5ed19c1c4296519a59842a876385ea36af6a7162507dfa45e37aa00eed4a5190c7e72bab97f205aa87f6d273bebdb61baa4cd5600e7
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Aidan Feldman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# MarkdownProofer [![Build Status](https://travis-ci.org/afeld/markdown_proofer.svg?branch=master)](https://travis-ci.org/afeld/markdown_proofer)
|
2
|
+
|
3
|
+
A gem that validates your Markdown files. It uses [HTML::Proofer](https://github.com/gjtorikian/html-proofer) under the hood to check whether links and images exist.
|
4
|
+
|
5
|
+
## Setup
|
6
|
+
|
7
|
+
Requires Ruby 2.0+. Create the following files:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# Gemfile
|
11
|
+
|
12
|
+
source 'https://rubygems.org'
|
13
|
+
|
14
|
+
gem 'markdown_proofer'
|
15
|
+
gem 'rake'
|
16
|
+
```
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# Rakefile
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'bundler'
|
23
|
+
Bundler.require(:default)
|
24
|
+
|
25
|
+
desc "Run Mardown validation for the repository"
|
26
|
+
task :validate_markdown do
|
27
|
+
MarkdownProofer::RakeTask.run
|
28
|
+
end
|
29
|
+
|
30
|
+
task default: :validate_markdown
|
31
|
+
```
|
32
|
+
|
33
|
+
### Configuration
|
34
|
+
|
35
|
+
`MarkdownProofer::RakeTask.run` accepts the following named parameters:
|
36
|
+
|
37
|
+
* `excludes` – An Array of [Regexp](http://www.ruby-doc.org/core-2.1.1/Regexp.html)s. Any file paths that match will be excluded from validation. Defaults to excluding test-related files.
|
38
|
+
* `html_proofer` – Options passed to HTML::Proofer. See [the HTML::Proofer documentation](https://github.com/gjtorikian/html-proofer#configuration).
|
39
|
+
* `path` – The relative path to the file/directory that you want to validate. Defaults to the top-level directory.
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
```bash
|
44
|
+
bundle
|
45
|
+
bundle exec rake
|
46
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require_relative "lib/markdown_proofer"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
desc "Run Mardown validation for the repository"
|
8
|
+
task :validate_markdown do
|
9
|
+
MarkdownProofer::RakeTask.run
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => [:spec, :validate_markdown]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class MarkdownProofer
|
2
|
+
module RakeTask
|
3
|
+
def create_proofer(*args)
|
4
|
+
args[0] ||= {}
|
5
|
+
args[0][:excludes] ||= [
|
6
|
+
/\bfixtures\//,
|
7
|
+
/\bspec\//,
|
8
|
+
/\btext\//,
|
9
|
+
/\bvendor\//
|
10
|
+
]
|
11
|
+
MarkdownProofer.new(*args)
|
12
|
+
end
|
13
|
+
module_function :create_proofer
|
14
|
+
|
15
|
+
def run(*args)
|
16
|
+
puts "Validating Markdown..."
|
17
|
+
proofer = self.create_proofer(*args)
|
18
|
+
proofer.run
|
19
|
+
if proofer.errors.any?
|
20
|
+
raise "Failed! #{proofer.errors.join("\n")}"
|
21
|
+
else
|
22
|
+
puts "Success!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
module_function :run
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require(:default)
|
4
|
+
|
5
|
+
require 'markdown_proofer/version'
|
6
|
+
require 'markdown_proofer/rake_task'
|
7
|
+
require 'find'
|
8
|
+
require 'html/pipeline'
|
9
|
+
require 'html/proofer'
|
10
|
+
|
11
|
+
|
12
|
+
class MarkdownProofer
|
13
|
+
attr_reader :path, :excludes, :html_proofer, :errors, :pipeline
|
14
|
+
|
15
|
+
def initialize(path: '.', excludes: [], html_proofer: {})
|
16
|
+
@path = path
|
17
|
+
@excludes = excludes
|
18
|
+
@html_proofer = html_proofer
|
19
|
+
|
20
|
+
self.reset_errors
|
21
|
+
@pipeline = HTML::Pipeline.new [
|
22
|
+
HTML::Pipeline::MarkdownFilter,
|
23
|
+
HTML::Pipeline::TableOfContentsFilter
|
24
|
+
], gfm: true
|
25
|
+
end
|
26
|
+
|
27
|
+
def files
|
28
|
+
if File.file?(self.path)
|
29
|
+
[self.path]
|
30
|
+
else # directory
|
31
|
+
pattern = File.join(self.path, '**', '*.md')
|
32
|
+
Dir.glob(pattern)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def included_files
|
37
|
+
self.files.reject do |file|
|
38
|
+
self.excludes.any? do |exclude|
|
39
|
+
file =~ exclude
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
self.reset_errors
|
46
|
+
|
47
|
+
# iterate over files, and generate HTML from Markdown
|
48
|
+
self.included_files.each do |file|
|
49
|
+
# convert the Markdown to HTML
|
50
|
+
contents = File.read(file)
|
51
|
+
result = self.pipeline.call(contents)
|
52
|
+
|
53
|
+
# save the HTML file next to the Markdown one
|
54
|
+
output_file = file.sub(/\.md$/, '.html')
|
55
|
+
begin
|
56
|
+
File.open(output_file, 'w') do |file|
|
57
|
+
file.write(result[:output].to_s)
|
58
|
+
end
|
59
|
+
|
60
|
+
# do validation on the file
|
61
|
+
html_proofer = HTML::Proofer.new(output_file, self.html_proofer)
|
62
|
+
output = self.capture_stderr { html_proofer.run }
|
63
|
+
errors = output.split("\n")
|
64
|
+
self.errors.concat(errors)
|
65
|
+
ensure
|
66
|
+
# clean up the file
|
67
|
+
FileUtils.rm(output_file)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
self.errors.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
protected
|
76
|
+
|
77
|
+
def reset_errors
|
78
|
+
@errors = []
|
79
|
+
end
|
80
|
+
|
81
|
+
# https://github.com/gjtorikian/html-proofer/blob/f16643845ed26c5aaeafc7c6c8d69a00e2acad75/spec/spec_helper.rb#L17
|
82
|
+
def capture_stderr(&block)
|
83
|
+
original_stderr = $stderr
|
84
|
+
original_stdout = $stdout
|
85
|
+
$stderr = fake_err = StringIO.new
|
86
|
+
$stdout = fake_out = StringIO.new
|
87
|
+
begin
|
88
|
+
yield
|
89
|
+
rescue RuntimeError
|
90
|
+
ensure
|
91
|
+
$stderr = original_stderr
|
92
|
+
$stdout = original_stdout
|
93
|
+
end
|
94
|
+
fake_err.string
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'markdown_proofer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'markdown_proofer'
|
8
|
+
spec.version = MarkdownProofer::VERSION
|
9
|
+
spec.authors = ['Aidan Feldman']
|
10
|
+
spec.email = ['aidan.feldman@gmail.com']
|
11
|
+
spec.summary = %q{Validates for your Markdown files}
|
12
|
+
spec.description = %q{Checks whether links/images in your Markdown files are valid.}
|
13
|
+
spec.homepage = 'https://github.com/afeld/markdown_proofer'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'github-markdown', '~> 0.6.5'
|
22
|
+
spec.add_dependency 'html-pipeline', '~> 1.8'
|
23
|
+
spec.add_dependency 'html-proofer', '~> 0.6.7'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
26
|
+
spec.add_development_dependency 'guard', '~> 2.6'
|
27
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.2'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'vcr', '~> 2.9'
|
31
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: head
|
5
|
+
uri: http://brok.ensite.com
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 0
|
15
|
+
message:
|
16
|
+
headers: {}
|
17
|
+
body:
|
18
|
+
encoding: UTF-8
|
19
|
+
string: ''
|
20
|
+
http_version:
|
21
|
+
adapter_metadata:
|
22
|
+
effective_url: http://brok.ensite.com/
|
23
|
+
recorded_at: Fri, 02 May 2014 21:18:42 GMT
|
24
|
+
- request:
|
25
|
+
method: get
|
26
|
+
uri: http://brok.ensite.com/
|
27
|
+
body:
|
28
|
+
encoding: US-ASCII
|
29
|
+
string: ''
|
30
|
+
headers:
|
31
|
+
User-Agent:
|
32
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
33
|
+
response:
|
34
|
+
status:
|
35
|
+
code: 0
|
36
|
+
message:
|
37
|
+
headers: {}
|
38
|
+
body:
|
39
|
+
encoding: UTF-8
|
40
|
+
string: ''
|
41
|
+
http_version:
|
42
|
+
adapter_metadata:
|
43
|
+
effective_url: http://brok.ensite.com/
|
44
|
+
recorded_at: Fri, 02 May 2014 21:18:42 GMT
|
45
|
+
- request:
|
46
|
+
method: head
|
47
|
+
uri: https://google.com
|
48
|
+
body:
|
49
|
+
encoding: US-ASCII
|
50
|
+
string: ''
|
51
|
+
headers:
|
52
|
+
User-Agent:
|
53
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
54
|
+
response:
|
55
|
+
status:
|
56
|
+
code: 200
|
57
|
+
message: OK
|
58
|
+
headers:
|
59
|
+
Date:
|
60
|
+
- Fri, 02 May 2014 21:18:42 GMT
|
61
|
+
Expires:
|
62
|
+
- '-1'
|
63
|
+
Cache-Control:
|
64
|
+
- private, max-age=0
|
65
|
+
Content-Type:
|
66
|
+
- text/html; charset=ISO-8859-1
|
67
|
+
Set-Cookie:
|
68
|
+
- PREF=ID=adf416fd43345466:FF=0:TM=1399065522:LM=1399065522:S=6vgRllSc0IDF8aeO;
|
69
|
+
expires=Sun, 01-May-2016 21:18:42 GMT; path=/; domain=.google.com
|
70
|
+
- NID=67=VrJ_bi6tEJMlM7cKytnuxn69QRe6z9IcpGOvPamcMin5MwEUIzm7baG4HUUsn89o0lsVDr0aX1wm4i7wq2PrYEaeY9jPCjrc1k47sGdjlHx_pR3RcPlZ6DoMw-1y_B1v;
|
71
|
+
expires=Sat, 01-Nov-2014 21:18:42 GMT; path=/; domain=.google.com; HttpOnly
|
72
|
+
P3P:
|
73
|
+
- CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657
|
74
|
+
for more info."
|
75
|
+
Server:
|
76
|
+
- gws
|
77
|
+
X-XSS-Protection:
|
78
|
+
- 1; mode=block
|
79
|
+
X-Frame-Options:
|
80
|
+
- SAMEORIGIN
|
81
|
+
Alternate-Protocol:
|
82
|
+
- 443:quic
|
83
|
+
Transfer-Encoding:
|
84
|
+
- chunked
|
85
|
+
body:
|
86
|
+
encoding: UTF-8
|
87
|
+
string: ''
|
88
|
+
http_version: '1.1'
|
89
|
+
adapter_metadata:
|
90
|
+
effective_url: https://www.google.com/
|
91
|
+
recorded_at: Fri, 02 May 2014 21:18:42 GMT
|
92
|
+
- request:
|
93
|
+
method: head
|
94
|
+
uri: http://brok.ensite.com
|
95
|
+
body:
|
96
|
+
encoding: US-ASCII
|
97
|
+
string: ''
|
98
|
+
headers:
|
99
|
+
User-Agent:
|
100
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
101
|
+
response:
|
102
|
+
status:
|
103
|
+
code: 0
|
104
|
+
message:
|
105
|
+
headers: {}
|
106
|
+
body:
|
107
|
+
encoding: UTF-8
|
108
|
+
string: ''
|
109
|
+
http_version:
|
110
|
+
adapter_metadata:
|
111
|
+
effective_url: http://brok.ensite.com/
|
112
|
+
recorded_at: Fri, 02 May 2014 21:18:42 GMT
|
113
|
+
- request:
|
114
|
+
method: get
|
115
|
+
uri: http://brok.ensite.com/
|
116
|
+
body:
|
117
|
+
encoding: US-ASCII
|
118
|
+
string: ''
|
119
|
+
headers:
|
120
|
+
User-Agent:
|
121
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
122
|
+
response:
|
123
|
+
status:
|
124
|
+
code: 0
|
125
|
+
message:
|
126
|
+
headers: {}
|
127
|
+
body:
|
128
|
+
encoding: UTF-8
|
129
|
+
string: ''
|
130
|
+
http_version:
|
131
|
+
adapter_metadata:
|
132
|
+
effective_url: http://brok.ensite.com/
|
133
|
+
recorded_at: Fri, 02 May 2014 21:18:42 GMT
|
134
|
+
- request:
|
135
|
+
method: head
|
136
|
+
uri: https://google.com
|
137
|
+
body:
|
138
|
+
encoding: US-ASCII
|
139
|
+
string: ''
|
140
|
+
headers:
|
141
|
+
User-Agent:
|
142
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
143
|
+
response:
|
144
|
+
status:
|
145
|
+
code: 200
|
146
|
+
message: OK
|
147
|
+
headers:
|
148
|
+
Date:
|
149
|
+
- Fri, 02 May 2014 21:18:43 GMT
|
150
|
+
Expires:
|
151
|
+
- '-1'
|
152
|
+
Cache-Control:
|
153
|
+
- private, max-age=0
|
154
|
+
Content-Type:
|
155
|
+
- text/html; charset=ISO-8859-1
|
156
|
+
Set-Cookie:
|
157
|
+
- PREF=ID=1c284013f94e7cd4:FF=0:TM=1399065523:LM=1399065523:S=oIbt-OAJpjVaQZN_;
|
158
|
+
expires=Sun, 01-May-2016 21:18:43 GMT; path=/; domain=.google.com
|
159
|
+
- NID=67=E5XueaqIhupm2cUV7OzNnEiu5jeu7xExcGwIulG_9Nv5mThk144iTqyo6sBNpPLWsU3etIg0q06WR_TcpA1iHFkCtUbYWcVjlgtIvic3_UkECLx61X18u7lvaQdc5oYq;
|
160
|
+
expires=Sat, 01-Nov-2014 21:18:43 GMT; path=/; domain=.google.com; HttpOnly
|
161
|
+
P3P:
|
162
|
+
- CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657
|
163
|
+
for more info."
|
164
|
+
Server:
|
165
|
+
- gws
|
166
|
+
X-XSS-Protection:
|
167
|
+
- 1; mode=block
|
168
|
+
X-Frame-Options:
|
169
|
+
- SAMEORIGIN
|
170
|
+
Alternate-Protocol:
|
171
|
+
- 443:quic
|
172
|
+
Transfer-Encoding:
|
173
|
+
- chunked
|
174
|
+
body:
|
175
|
+
encoding: UTF-8
|
176
|
+
string: ''
|
177
|
+
http_version: '1.1'
|
178
|
+
adapter_metadata:
|
179
|
+
effective_url: https://www.google.com/
|
180
|
+
recorded_at: Fri, 02 May 2014 21:18:43 GMT
|
181
|
+
recorded_with: VCR 2.9.0
|
@@ -0,0 +1 @@
|
|
1
|
+
[broken link](http://brok.ensite.com)
|
@@ -0,0 +1 @@
|
|
1
|
+
[relative link](working_link.md)
|
@@ -0,0 +1 @@
|
|
1
|
+
[working link](https://google.com)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkdownProofer, vcr: vcr_options do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(MarkdownProofer::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#files' do
|
9
|
+
it "handles directories" do
|
10
|
+
proofer = MarkdownProofer.new(path: fixture_path)
|
11
|
+
files = proofer.files
|
12
|
+
expect(files.sort).to eq([
|
13
|
+
fixture_path('broken_link.md'),
|
14
|
+
fixture_path('relative_link.md'),
|
15
|
+
fixture_path('working_link.md')
|
16
|
+
])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "handles files" do
|
20
|
+
proofer = MarkdownProofer.new(path: fixture_path('broken_link.md'))
|
21
|
+
files = proofer.files
|
22
|
+
expect(files.size).to eq(1)
|
23
|
+
expect(files.first).to end_with('/spec/fixtures/broken_link.md')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#included_files' do
|
28
|
+
it "ignores the excluded glob" do
|
29
|
+
proofer = MarkdownProofer.new(path: fixture_path, excludes: [/broken/])
|
30
|
+
files = proofer.included_files
|
31
|
+
expect(files.sort).to eq([
|
32
|
+
fixture_path('relative_link.md'),
|
33
|
+
fixture_path('working_link.md')
|
34
|
+
])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#run' do
|
39
|
+
it "passes options to HTML::Proofer" do
|
40
|
+
HTML::Proofer.should_receive(:new).with(anything, ext: 'htm').and_call_original
|
41
|
+
|
42
|
+
path = fixture_path('working_link.md')
|
43
|
+
proofer = MarkdownProofer.new(path: path, html_proofer: {ext: 'htm'})
|
44
|
+
proofer.run
|
45
|
+
end
|
46
|
+
|
47
|
+
it "works for relative links" do
|
48
|
+
proofer = MarkdownProofer.new(path: fixture_path('relative_link.md'))
|
49
|
+
expect(proofer.run).to be_true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "complains for files with broken links" do
|
53
|
+
proofer = MarkdownProofer.new(path: fixture_path)
|
54
|
+
proofer.run
|
55
|
+
expect(proofer.errors.size).to eq(1)
|
56
|
+
expect(proofer.errors.first).to include("External link")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns true for no broken links" do
|
60
|
+
proofer = MarkdownProofer.new(path: fixture_path('working_link.md'))
|
61
|
+
expect(proofer.run).to be_true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns false for broken links" do
|
65
|
+
proofer = MarkdownProofer.new(path: fixture_path)
|
66
|
+
expect(proofer.run).to be_false
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can be executed multiple times" do
|
70
|
+
proofer = MarkdownProofer.new(path: fixture_path)
|
71
|
+
2.times do
|
72
|
+
proofer.run
|
73
|
+
expect(proofer.errors.size).to eq(1)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkdownProofer::RakeTask do
|
4
|
+
describe '.create_proofer' do
|
5
|
+
it "excludes vendor/ and spec/ folders by default" do
|
6
|
+
proofer = MarkdownProofer::RakeTask.create_proofer
|
7
|
+
expect(proofer.included_files.sort).to eq(['./CONTRIBUTING.md', './README.md'])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'markdown_proofer'
|
3
|
+
|
4
|
+
Bundler.require(:default, :development)
|
5
|
+
|
6
|
+
VCR.configure do |c|
|
7
|
+
c.cassette_library_dir = 'spec/cassettes'
|
8
|
+
c.hook_into :typhoeus
|
9
|
+
c.configure_rspec_metadata!
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def vcr_options
|
14
|
+
{ :cassette_name => 'all', :record => :new_episodes }
|
15
|
+
end
|
16
|
+
|
17
|
+
def fixture_path(file='')
|
18
|
+
File.join(File.dirname(__FILE__), 'fixtures', file)
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markdown_proofer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aidan Feldman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: github-markdown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: html-pipeline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: html-proofer
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.6.7
|
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.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.9'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.9'
|
139
|
+
description: Checks whether links/images in your Markdown files are valid.
|
140
|
+
email:
|
141
|
+
- aidan.feldman@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- .gitignore
|
147
|
+
- .rspec
|
148
|
+
- .travis.yml
|
149
|
+
- CONTRIBUTING.md
|
150
|
+
- Gemfile
|
151
|
+
- Guardfile
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- lib/markdown_proofer.rb
|
156
|
+
- lib/markdown_proofer/rake_task.rb
|
157
|
+
- lib/markdown_proofer/version.rb
|
158
|
+
- markdown_proofer.gemspec
|
159
|
+
- spec/cassettes/all.yml
|
160
|
+
- spec/fixtures/broken_link.md
|
161
|
+
- spec/fixtures/relative_link.md
|
162
|
+
- spec/fixtures/working_link.md
|
163
|
+
- spec/markdown_proofer_spec.rb
|
164
|
+
- spec/rake_task_spec.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
homepage: https://github.com/afeld/markdown_proofer
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - '>='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.0.3
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: Validates for your Markdown files
|
190
|
+
test_files:
|
191
|
+
- spec/cassettes/all.yml
|
192
|
+
- spec/fixtures/broken_link.md
|
193
|
+
- spec/fixtures/relative_link.md
|
194
|
+
- spec/fixtures/working_link.md
|
195
|
+
- spec/markdown_proofer_spec.rb
|
196
|
+
- spec/rake_task_spec.rb
|
197
|
+
- spec/spec_helper.rb
|