Sha256: cc9656bd33cb178b21bc579d568eaeee1d4105184802612dc8849c02f73371df
Contents?: true
Size: 810 Bytes
Versions: 3
Compression:
Stored size: 810 Bytes
Contents
# typed: strict class PublicSuffixList module Parser # com # *.jp # *.hokkaido.jp # *.tokyo.jp # !pref.hokkaido.jp # !metro.tokyo.jp # { # "com" => {:term => true}, # "jp" => { # "tokyo" => {"!metro" => {:term => true}, "*" => {:term => true}}, # "hokkaido" => {"!pref" => {:term => true}, "*" => {:term => true}}, # "*" => {:term => true} # } # } def self.parse(lines) lines.inject({}) do |acc, line| line.gsub!(/\s.*/, "") unless line =~ %r{//} or line.empty? tmp = acc line.split(".").reject(&:empty?).reverse.each do |p| tmp[p] = {} unless tmp[p] tmp = tmp[p] end tmp[:term] = true end acc end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
public-suffix-list-0.2.4 | lib/public_suffix_list/parser.rb |
public-suffix-list-0.2.3 | lib/public_suffix_list/parser.rb |
public-suffix-list-0.2.2 | lib/public_suffix_list/parser.rb |