Sha256: 27044b400d94e8817f283eeef23936881bd90322afb0866f181f473102a2b185

Contents?: true

Size: 833 Bytes

Versions: 2

Compression:

Stored size: 833 Bytes

Contents

#!/usr/bin/env ruby
# Propagates an initial list of best-guess government domains

require 'public_suffix'
require 'yaml'
require_relative '../lib/gman'
require_relative '../lib/gman/importer'

# https://gist.github.com/benbalter/6147066
REGEX = /(\.g[ou]{1,2}(v|b|vt)|\.mil|\.gc|\.fed)(\.[a-z]{2})?$/i

domains = []
PublicSuffix::List.default.each do |rule|
  domain = nil

  if rule.parts.length == 1
    domain = rule.parts.first if ".#{rule.value}" =~ REGEX
  elsif ".#{rule.value}" =~ REGEX
    domain = rule.parts.pop(2).join('.')
  end

  domains.push domain unless domain.nil? || domains.include?(domain)
end

# Note: We want to skip resolution here, because a domain like `gov.sv` may be
# a valid TLD, not have any top-level sites, and we'd still want it listed
Gman.import({ 'non-us gov' => domains }, skip_resolve: true)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gman-6.0.1 script/vendor-public-suffix
gman-6.0.0 script/vendor-public-suffix