Sha256: 1fde5c825d11a8da540c2e45d56288daea01c6dbe05de1122ed75797daeb49e6

Contents?: true

Size: 739 Bytes

Versions: 12

Compression:

Stored size: 739 Bytes

Contents

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

require "public_suffix"
require "yaml"

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

YAML_FILE = File.dirname(__FILE__) + "/../lib/domains.yml"
domains = YAML.load_file YAML_FILE
domains = [] unless 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

domains = domains.sort
File.open(YAML_FILE, 'w+') {|f| f.write(domains.to_yaml)}

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gman-2.0.0 script/build
gman-1.0.0 script/build
gman-0.2.1 script/build
gman-0.2.0 script/build
gman-0.1.0 script/build
gman-0.0.7 script/build
gman-0.0.6 script/build
gman-0.0.5 script/build
gman-0.0.4 script/build
gman-0.0.3 script/build
gman-0.0.2 script/build
gman-0.0.1 script/build