Sha256: 662b4f78e6dbb4ea0c6cfb56bc8b50252bab5b42e7451f4ba0c426816cf7d504

Contents?: true

Size: 739 Bytes

Versions: 21

Compression:

Stored size: 739 Bytes

Contents

#!/usr/bin/env ruby
# Propagates 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

21 entries across 21 versions & 1 rubygems

Version Path
gman-4.6.5 script/build
gman-4.6.4 script/build
gman-4.6.3 script/build
gman-4.6.2 script/build
gman-4.6.1 script/build
gman-4.6.0 script/build
gman-4.5.1 script/build
gman-4.5.0 script/build
gman-4.4.3 script/build
gman-4.4.2 script/build
gman-4.4.1 script/build
gman-4.4.0 script/build
gman-3.1.1 script/build
gman-3.1.0 script/build
gman-3.0.2 script/build
gman-3.0.1 script/build
gman-3.0.0 script/build
gman-2.1.3 script/build
gman-2.1.2 script/build
gman-2.1.1 script/build