geoip 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -95,8 +95,9 @@ version here:
95
95
  This library is distributed in the hope that it will be useful,
96
96
  but WITHOUT ANY WARRANTY; without even the implied warranty of
97
97
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
98
- General Public License for more details.
98
+ Lesser General Public License for more details.
99
99
 
100
- You should have received a copy of the GNU General Public
100
+ You should have received a copy of the GNU Lesser General Public
101
101
  License along with this library; if not, write to the Free Software
102
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
102
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
103
+
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ Jeweler::Tasks.new do |gem|
9
9
  gem.name = "geoip"
10
10
  gem.version = GeoIP::VERSION
11
11
  gem.homepage = "http://github.com/cjheath/geoip"
12
- gem.license = "GPL"
12
+ gem.license = "LGPL"
13
13
  gem.summary = %Q{GeoIP searches a GeoIP database for a given host or IP address, and returns information about the country where the IP address is allocated, and the city, ISP and other information, if you have that database version.}
14
14
  gem.description = %Q{GeoIP searches a GeoIP database for a given host or IP address, and
15
15
  returns information about the country where the IP address is allocated,
data/geoip.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "geoip"
8
- s.version = "1.2.1"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Clifford Heath", "Roland Moriz"]
12
- s.date = "2012-12-18"
12
+ s.date = "2013-08-05"
13
13
  s.description = "GeoIP searches a GeoIP database for a given host or IP address, and\nreturns information about the country where the IP address is allocated,\nand the city, ISP and other information, if you have that database version."
14
14
  s.email = ["clifford.heath@gmail.com", "rmoriz@gmail.com"]
15
15
  s.executables = ["geoip"]
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  "website/template.rhtml"
41
41
  ]
42
42
  s.homepage = "http://github.com/cjheath/geoip"
43
- s.licenses = ["GPL"]
43
+ s.licenses = ["LGPL"]
44
44
  s.require_paths = ["lib"]
45
45
  s.rubygems_version = "1.8.24"
46
46
  s.summary = "GeoIP searches a GeoIP database for a given host or IP address, and returns information about the country where the IP address is allocated, and the city, ISP and other information, if you have that database version."
data/lib/geoip.rb CHANGED
@@ -8,19 +8,18 @@
8
8
  # Derived from the C version, Copyright (C) 2003 MaxMind LLC
9
9
  #
10
10
  # This library is free software; you can redistribute it and/or
11
- # modify it under the terms of the GNU General Public
11
+ # modify it under the terms of the GNU Lesser General Public
12
12
  # License as published by the Free Software Foundation; either
13
13
  # version 2.1 of the License, or (at your option) any later version.
14
14
  #
15
15
  # This library is distributed in the hope that it will be useful,
16
16
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
17
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- # General Public License for more details.
18
+ # Lesser General Public License for more details.
19
19
  #
20
- # You should have received a copy of the GNU General Public
20
+ # You should have received a copy of the GNU Lesser General Public
21
21
  # License along with this library; if not, write to the Free Software
22
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
- #
22
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
23
  # = SYNOPSIS
25
24
  #
26
25
  # require 'geoip'
@@ -59,7 +58,7 @@ require 'yaml'
59
58
  class GeoIP
60
59
 
61
60
  # The GeoIP GEM version number
62
- VERSION = "1.2.1"
61
+ VERSION = "1.2.2"
63
62
 
64
63
  # The +data/+ directory for geoip
65
64
  DATA_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','data','geoip'))
@@ -137,6 +136,9 @@ class GeoIP
137
136
  # The Edition number that identifies which kind of database you've opened
138
137
  attr_reader :database_type
139
138
 
139
+ # An IP that is used instead of local IPs
140
+ attr_accessor :local_ip_alias
141
+
140
142
  alias databaseType database_type
141
143
 
142
144
  # Open the GeoIP database and determine the file format version.
@@ -443,7 +445,7 @@ class GeoIP
443
445
 
444
446
  # Get the postal code:
445
447
  postal_code = spl[2]
446
- @iter_pos += (postal_code.size + 1) unless @iter_pos.nil?
448
+ @iter_pos += (postal_code.size + 1) unless @iter_pos.nil? || postal_code.nil?
447
449
 
448
450
  record = spl[3]
449
451
 
@@ -500,6 +502,10 @@ class GeoIP
500
502
  end
501
503
 
502
504
  def lookup_ip(ip_or_hostname) # :nodoc:
505
+ if is_local?(ip_or_hostname) && @local_ip_alias
506
+ ip_or_hostname = @local_ip_alias
507
+ end
508
+
503
509
  if !ip_or_hostname.kind_of?(String) or ip_or_hostname =~ /^[0-9.]+$/
504
510
  return ip_or_hostname
505
511
  end
@@ -510,6 +516,10 @@ class GeoIP
510
516
  ip
511
517
  end
512
518
 
519
+ def is_local?(ip_or_hostname) #:nodoc:
520
+ ["127.0.0.1", "localhost", "::1", "0000::1", "0:0:0:0:0:0:0:1"].include? ip_or_hostname
521
+ end
522
+
513
523
  # Convert numeric IP address to Integer.
514
524
  def iptonum(ip) #:nodoc:
515
525
  if (ip.kind_of?(String) &&
data/script/txt2html CHANGED
@@ -2,9 +2,8 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'redcloth'
5
- require 'syntax/convertors/html'
6
5
  require 'erb'
7
- require File.dirname(__FILE__) + '/../lib/geoip.rb'
6
+ require './' + File.dirname(__FILE__) + '/../lib/geoip.rb'
8
7
 
9
8
  version = GeoIP::VERSION
10
9
  download = 'http://rubyforge.org/projects/geoip'
@@ -15,9 +14,9 @@ class Fixnum
15
14
  return 'th' if (10..19).include?(self % 100)
16
15
  # others
17
16
  case self % 10
18
- when 1: return 'st'
19
- when 2: return 'nd'
20
- when 3: return 'rd'
17
+ when 1; return 'st'
18
+ when 2; return 'nd'
19
+ when 3; return 'rd'
21
20
  else return 'th'
22
21
  end
23
22
  end
data/website/index.txt CHANGED
@@ -65,15 +65,15 @@ This version Copyright (C) 2005 Clifford Heath
65
65
  Derived from the C version, Copyright (C) 2003 MaxMind LLC
66
66
 
67
67
  This library is free software; you can redistribute it and/or
68
- modify it under the terms of the GNU General Public
68
+ modify it under the terms of the GNU Lesser General Public
69
69
  License as published by the Free Software Foundation; either
70
70
  version 2.1 of the License, or (at your option) any later version.
71
71
 
72
72
  This library is distributed in the hope that it will be useful,
73
73
  but WITHOUT ANY WARRANTY; without even the implied warranty of
74
74
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
75
- General Public License for more details.
75
+ Lesser General Public License for more details.
76
76
 
77
- You should have received a copy of the GNU General Public
77
+ You should have received a copy of the GNU Lesser General Public
78
78
  License along with this library; if not, write to the Free Software
79
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
79
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-18 00:00:00.000000000 Z
13
+ date: 2013-08-05 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: ! 'GeoIP searches a GeoIP database for a given host or IP address, and
16
16
 
@@ -49,7 +49,7 @@ files:
49
49
  - website/template.rhtml
50
50
  homepage: http://github.com/cjheath/geoip
51
51
  licenses:
52
- - GPL
52
+ - LGPL
53
53
  post_install_message:
54
54
  rdoc_options: []
55
55
  require_paths: