<commit_before>##
## GeoIP Test
##

GeoIPdat = '/usr/local/share/GeoLiteCity.dat'
GeoIPhost = 'www.google.com'

# from: https://github.com/maxmind/geoip-api-php/blob/master/tests/data/GeoIPOrg.dat
GeoIPIspdat = '/usr/local/share/GeoIPOrg.dat'

assert("GeoIP#new") do
  geoip = GeoIP.new GeoIPdat

  assert_not_equal(nil, geoip)
end

assert("GeoIP#country_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal("US", geoip.country_code)
end

assert("GeoIP#region") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal("CA", geoip.region)
end

assert("GeoIP#region_name") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal("California", geoip.region_name)
end

assert("GeoIP#city") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal("Mountain View", geoip.city)
end

assert("GeoIP#postal_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal("94043", geoip.postal_code)
end

assert("GeoIP#org") do
  geoip = GeoIP.new(GeoIPdat, GeoIPIspdat)
  geoip.record_by_addr '172.16.17.32'

  assert_equal('<NAME> LLP', geoip.org)
end

assert("GeoIP#latitude") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal(37.4192, geoip.latitude.round(4))
end

assert("GeoIP#longitude") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal(-122.0574, geoip.longitude.round(4))
end

assert("GeoIP#metro_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal(807, geoip.metro_code)
end

assert("GeoIP#area_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal(650, geoip.area_code)
end

assert("GeoIP#time_zone") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_name GeoIPhost

  assert_equal("America/Los_Angeles", geoip.time_zone)
end

assert("GeoIP#close") do
  geoip = GeoIP.new GeoIPdat

  assert_equal(nil, geoip.close)
end<commit_msg>Google's A record varies from country to country<commit_after>##
## GeoIP Test
##

GeoIPdat = '/usr/local/share/GeoLiteCity.dat'
GeoIPhost = '172.16.17.32'

# from: https://github.com/maxmind/geoip-api-php/blob/master/tests/data/GeoIPOrg.dat
GeoIPIspdat = '/usr/local/share/GeoIPOrg.dat'

assert("GeoIP#new") do
  geoip = GeoIP.new GeoIPdat

  assert_not_equal(nil, geoip)
end

assert("GeoIP#country_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal("US", geoip.country_code)
end

assert("GeoIP#region") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal("CA", geoip.region)
end

assert("GeoIP#region_name") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal("California", geoip.region_name)
end

assert("GeoIP#city") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal("Mountain View", geoip.city)
end

assert("GeoIP#postal_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal("94043", geoip.postal_code)
end

assert("GeoIP#org") do
  geoip = GeoIP.new(GeoIPdat, GeoIPIspdat)
  geoip.record_by_addr '172.16.17.32'

  assert_equal('<NAME> LLP', geoip.org)
end

assert("GeoIP#latitude") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal(37.4192, geoip.latitude.round(4))
end

assert("GeoIP#longitude") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal(-122.0574, geoip.longitude.round(4))
end

assert("GeoIP#metro_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal(807, geoip.metro_code)
end

assert("GeoIP#area_code") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal(650, geoip.area_code)
end

assert("GeoIP#time_zone") do
  geoip = GeoIP.new GeoIPdat
  geoip.record_by_addr GeoIPhost

  assert_equal("America/Los_Angeles", geoip.time_zone)
end

assert("GeoIP#close") do
  geoip = GeoIP.new GeoIPdat

  assert_equal(nil, geoip.close)
end
{'fraction_non_alphanumeric': 0.11621554507077228, 'fraction_numerical': 0.01961758132604917, 'mean_word_length': 5.0389805097451275, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5855466', 'n_tokens_mistral': 1867, 'n_tokens_neox': 1662, 'n_words': 284}