File: html-proofer.rb

package info (click to toggle)
ruby-html-proofer 3.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 180 kB
  • sloc: ruby: 1,326; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download
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
# frozen_string_literal: true

def require_all(path)
  dir = File.join(File.dirname(__FILE__), path)
  Dir[File.join(dir, '*.rb')].each do |f|
    require f
  end
end

require_relative 'html-proofer/utils'
require_all 'html-proofer'
require_all 'html-proofer/check'

require 'parallel'
require 'fileutils'

begin
  require 'awesome_print'
  require 'pry-byebug'
rescue LoadError; end # rubocop:disable Lint/HandleExceptions
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