Sha256: 1c844a5dc2fcc66af609eb0742d4e385d388cac5ccf577011b1e20061b6516f8

Contents?: true

Size: 656 Bytes

Versions: 9

Compression:

Stored size: 656 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
  else
    domain = rule.parts.pop(2).join(".") if ".#{rule.value}" =~ REGEX
  end

  domains.push domain unless domain.nil? or domains.include? domain
end

Gman.import("non-us gov" => domains)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gman-5.0.6 script/vendor-public-suffix
gman-5.0.5 script/vendor-public-suffix
gman-5.0.4 script/vendor-public-suffix
gman-5.0.3 script/vendor-public-suffix
gman-5.0.2 script/vendor-public-suffix
gman-5.0.1 script/vendor-public-suffix
gman-5.0.0 script/vendor-public-suffix
gman-4.7.1 script/vendor-public-suffix
gman-4.7.0 script/vendor-public-suffix