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