-
-
Notifications
You must be signed in to change notification settings - Fork 200
/
html_proofer.rb
56 lines (44 loc) · 1.51 KB
/
html_proofer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true
require 'zeitwerk'
lib_dir = File.join(File.dirname(__dir__), 'lib')
gem_loader = Zeitwerk::Loader.for_gem
gem_loader.inflector.inflect(
'html_proofer' => 'HTMLProofer'
)
gem_loader.ignore(File.join(lib_dir, 'html-proofer.rb'))
gem_loader.setup
require 'html_proofer/version'
require 'parallel'
require 'fileutils'
%w[awesome_print debug].each do |gem|
require gem
rescue LoadError; # rubocop:disable Lint/SuppressedException
end
module HTMLProofer
def self.check_file(file, options = {})
raise ArgumentError unless file.is_a?(String)
raise ArgumentError, "#{file} does not exist" unless File.exist?(file)
options[:type] = :file
HTMLProofer::Runner.new(file, options)
end
def self.check_directory(directory, options = {})
raise ArgumentError unless directory.is_a?(String)
raise ArgumentError, "#{directory} does not exist" unless Dir.exist?(directory)
options[:type] = :directory
HTMLProofer::Runner.new([directory], options)
end
def self.check_directories(directories, options = {})
raise ArgumentError unless directories.is_a?(Array)
options[:type] = :directory
directories.each do |directory|
raise ArgumentError, "#{directory} does not exist" unless Dir.exist?(directory)
end
HTMLProofer::Runner.new(directories, options)
end
def self.check_links(links, options = {})
raise ArgumentError unless links.is_a?(Array)
options[:type] = :links
HTMLProofer::Runner.new(links, options)
end
end
gem_loader.eager_load