Sha256: a221c1590b12385541bb4b9d2893f7dae376eb36ada793be3c3cc4ca6a452d6c
Contents?: true
Size: 1.08 KB
Versions: 12
Compression:
Stored size: 1.08 KB
Contents
#! /usr/bin/env ruby # Strips domains in the form of e.g., city.<locality>.<state>.us from the domain list require './lib/gman' require './lib/gman/parser' current = Gman::Parser.file_to_array( Gman::list_path ) domain_hash = Gman::Parser.array_to_hash(current) puts "Checking for state gov regex'd domains in the list..." puts "Starting with #{current.size} domains..." domain_hash.each do |group, domains| next unless group =~ /usagov[A-Z]{2}/ state = group[-2,2].downcase domain_hash[group].reject! { |d| d =~ Gman::LOCALITY_REGEX } domain_hash[group].uniq! domain_hash[group].sort! end # PublicSuffix Formatted Output current_group = "" output = "" domain_hash.each do |group, domains| if group != current_group output << "\n\n" unless current_group.empty? # first entry output << "// #{group}\n" current_group = group end output << domains.join("\n") end File.open(Gman.list_path, "w") { |file| file.write output } result = Gman::Parser.file_to_array( Gman::list_path ) puts "New list contains #{result.size} domains. Fin." exit 1 if current.size != result.size
Version data entries
12 entries across 12 versions & 1 rubygems