module HTMLProofer::Configuration

Constants

CACHE_DEFAULTS
HYDRA_DEFAULTS
PARALLEL_DEFAULTS
PROOFER_DEFAULTS
TYPHOEUS_DEFAULTS
VALIDATION_DEFAULTS

Public Class Methods

parse_json_option(option_name, config) click to toggle source
# File lib/html-proofer/configuration.rb, line 70
def self.parse_json_option(option_name, config)
  raise ArgumentError, 'Must provide an option name in string format.' unless option_name.is_a?(String)
  raise ArgumentError, 'Must provide an option name in string format.' if option_name.strip.empty?

  return {} if config.nil?

  raise ArgumentError, 'Must provide a JSON configuration in string format.' unless config.is_a?(String)

  return {} if config.strip.empty?

  begin
    JSON.parse(config)
  rescue StandardError
    raise ArgumentError, "Option '" + option_name + "' did not contain valid JSON."
  end
end
to_regex?(item) click to toggle source
# File lib/html-proofer/configuration.rb, line 62
def self.to_regex?(item)
  if item.start_with?('/') && item.end_with?('/')
    Regexp.new item[1...-1]
  else
    item
  end
end