Sha256: 81bd7b93ddaeda0a37ce1c2911ffd7d0b95679971399d43a9b36f560611e66dc

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

require "yaml"

require_relative "domain_check/version"
require_relative "domain_check/console_formatter"
require_relative "domain_check/multi_check"
require_relative "domain_check/single_check"

module DomainCheck
  extend self

  def new(domain: nil, file: nil, prefixes: nil, suffixes: nil, tlds: nil)
    if domain
      SingleCheck.new(domain)
    elsif file
      config = parse_file(file)
      MultiCheck.new(prefixes: config['prefixes'], suffixes: config['suffixes'], tlds: config['tlds'])
    elsif prefixes && suffixes
      MultiCheck.new(prefixes: prefixes, suffixes: suffixes, tlds: tlds)
    elsif prefixes || suffixes || tlds
      raise ArgumentError, "Must supply prefixes, suffixes, and TLDs"
    else
      raise ArgumentError, "No arguments given"
    end
  end

  protected

  def parse_file(filename)
    YAML.load_file(filename)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
domain_check-0.0.3 lib/domain_check.rb
domain_check-0.0.2 lib/domain_check.rb
domain_check-0.0.1 lib/domain_check.rb