geo_ip 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Jeroen Jacobs
1
+ Copyright (c) 2010-2011 Jeroen Jacobs
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/lib/geo_ip.rb CHANGED
@@ -21,12 +21,12 @@ class GeoIp
21
21
 
22
22
  # Retreive the remote location of a given ip address.
23
23
  #
24
- # It takes two optional arguments: precision and timezone
25
- # preceision can either be :city (default) or :country
26
- # timezone can either be false (default) or true
24
+ # It takes two optional arguments:
25
+ # * +preceision+: can either be +:city+ (default) or +:country+
26
+ # * +timezone+: can either be +false+ (default) or +true+
27
27
  #
28
- # Example:
29
- # GeoIp.geolocation('209.85.227.104', {:precision => :city, :timezone => true})
28
+ # ==== Example:
29
+ # GeoIp.geolocation('209.85.227.104', {:precision => :city, :timezone => true})
30
30
  def self.geolocation(ip, options={})
31
31
  @precision = options[:precision] || :city
32
32
  @timezone = options[:timezone] || false
data/spec/api.yml ADDED
@@ -0,0 +1 @@
1
+ key: 704e80b26abee33fd191f94c1ea3f62e8ec12dc77514fb4a2b4dbf3cac5c60f2
data/spec/geo_ip_spec.rb CHANGED
@@ -5,7 +5,7 @@ IP_LOCAL = '127.0.0.1'
5
5
 
6
6
  describe "GeoIp" do
7
7
 
8
- before(:all) do
8
+ before :each do
9
9
  api_config = YAML.load_file(File.dirname(__FILE__) + '/api.yml')
10
10
  GeoIp.api_key = api_config['key']
11
11
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,3 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
3
  require 'geo_ip'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_ip
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeroen Jacobs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-16 00:00:00 +01:00
18
+ date: 2011-03-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,45 +42,36 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 27
45
+ hash: 9
46
46
  segments:
47
- - 1
48
- - 3
49
- - 0
50
- version: 1.3.0
47
+ - 2
48
+ - 5
49
+ version: "2.5"
51
50
  type: :development
52
51
  version_requirements: *id002
53
52
  description: A call to the ipinfodb.com will be done to retreive the geolocation based on the IP address. No need to include a database file in the application.
54
- email: jacobsjeroen@gmail.com
53
+ email: gems@jeroenj.be
55
54
  executables: []
56
55
 
57
56
  extensions: []
58
57
 
59
- extra_rdoc_files:
60
- - LICENSE
61
- - README.rdoc
58
+ extra_rdoc_files: []
59
+
62
60
  files:
63
- - .document
64
- - .gitignore
65
- - CHANGES
66
61
  - LICENSE
67
- - README.rdoc
68
- - Rakefile
69
- - VERSION
70
- - geo_ip.gemspec
71
- - init.rb
72
62
  - lib/geo_ip.rb
63
+ - spec/api.yml
73
64
  - spec/api.yml.example
74
65
  - spec/geo_ip_spec.rb
75
66
  - spec/spec.opts
76
67
  - spec/spec_helper.rb
77
68
  has_rdoc: true
78
- homepage: http://github.com/jeroenj/geo_ip
69
+ homepage: http://jeroenj.be
79
70
  licenses: []
80
71
 
81
72
  post_install_message:
82
- rdoc_options:
83
- - --charset=UTF-8
73
+ rdoc_options: []
74
+
84
75
  require_paths:
85
76
  - lib
86
77
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -104,10 +95,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
95
  requirements: []
105
96
 
106
97
  rubyforge_project:
107
- rubygems_version: 1.3.7
98
+ rubygems_version: 1.5.0
108
99
  signing_key:
109
100
  specification_version: 3
110
101
  summary: Retreive the geolocation of an IP address based on the ipinfodb.com webservice
111
102
  test_files:
103
+ - spec/api.yml
104
+ - spec/api.yml.example
112
105
  - spec/geo_ip_spec.rb
106
+ - spec/spec.opts
113
107
  - spec/spec_helper.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- spec/api.yml
data/CHANGES DELETED
@@ -1,20 +0,0 @@
1
- == 0.3.0
2
-
3
- * Added support for API key requirement (Thanks to seanconaty and luigi)
4
- * Explicit gem dependency for json and removed rubygems requirement (idris) (http://tomayko.com/writings/require-rubygems-antipattern)
5
- * Removed deprecated GeoIp#remote_geolocation method
6
-
7
- == 0.2.0
8
-
9
- * Added support for timezone information. Use the optional {:timezone => true|false} option
10
- * Added support for country lookup. This will result in a faster reply since less queries need
11
- to be done at ipinfodb's side. Use the optional {:precision => :city|:country} option
12
- * API change: GeoIp.remote_geolocation(ip) is deprecated in favor of GeoIp.geolocation(ip)
13
-
14
- == 0.1.1
15
-
16
- * Removed time zone information since this has been deprecated with the service
17
-
18
- == 0.1.0
19
-
20
- * Initial commit
data/README.rdoc DELETED
@@ -1,118 +0,0 @@
1
- = GeoIp
2
-
3
- Retreive the geolocation of an IP address based on the {ipinfodb.com}[http://ipinfodb.com/] webservice.
4
-
5
- As of 8th November 2010, the service is asking that all users {register}[http://ipinfodb.com/register.php] for an API key.
6
-
7
- Consider making a donation to {ipinfodb.com}[http://ipinfodb.com/] at {http://ipinfodb.com/donate.php}[http://ipinfodb.com/donate.php]
8
-
9
- == Usage
10
-
11
- === Set API key
12
- GeoIp.api_key = "YOUR_API_KEY"
13
-
14
- This must be done before making the geolocation call.
15
-
16
- === Retrieve geolocation
17
- GeoIp.geolocation(ip_address)
18
-
19
- === Example
20
-
21
- # 209.85.227.104 = google.be (US)
22
- GeoIp.geolocation('209.85.227.104')
23
-
24
- returns:
25
-
26
- {
27
- :status =>"OK",
28
- :ip =>"209.85.227.104"
29
- :country_code =>"US",
30
- :country_name =>"United States",
31
- :region_code =>"06",
32
- :region_name =>"California",
33
- :city =>"Mountain View",
34
- :zip_postal_code =>"94043",
35
- :latitude =>"37.4192",
36
- :longitude =>"-122.057"
37
- }
38
-
39
- === Country only
40
-
41
- There is an option to only retreive the country information and thus excluding the city details. This results in a faster response from the service since less queries need to be done.
42
-
43
- GeoIp.geolocation('209.85.227.104', {:precision => :country})
44
-
45
- returns:
46
-
47
- {
48
- :status => "OK",
49
- :ip => "209.85.227.104"
50
- :country_code => "US",
51
- :country_name => "United States"
52
- }
53
-
54
- === Timezone information
55
-
56
- There is an option now to retrieve optional timezone information too:
57
-
58
- GeoIp.geolocation('209.85.227.104', {:timezone => true})
59
-
60
- returns:
61
-
62
- {
63
- :status =>"OK",
64
- :ip =>"209.85.227.104"
65
- :country_code =>"US",
66
- :country_name =>"United States",
67
- :region_code =>"06",
68
- :region_name =>"California",
69
- :city =>"Mountain View",
70
- :zip_postal_code =>"94043",
71
- :latitude =>"37.4192",
72
- :longitude =>"-122.057"
73
- :timezone_name =>"America/Los_Angeles",
74
- :utc_offset =>-25200,
75
- :dst? =>true
76
- }
77
-
78
- Obviously it is not possible to have the country precision enabled while retrieving the timezone information.
79
-
80
- == Getting it
81
-
82
- GeoIp can be installed as a Ruby Gem:
83
-
84
- gem install geo_ip
85
-
86
- Alternatively, you can also install it as a Rails plugin:
87
-
88
- ./script/plugin install git://github.com/jeroenj/geo_ip.git
89
-
90
- == Testing
91
-
92
- Set up your API key first for the test suite by creating a spec/api.yml file. Follow the example in spec/api.yml.example. Then run the tests with:
93
-
94
- ruby spec/geo_ip_spec.rb
95
-
96
- If you get a LoadError, you should run the tests with:
97
-
98
- ruby -rubygems spec/geo_ip_spec.rb
99
-
100
- == Colaborators
101
-
102
- * {seanconaty}[https://github.com/seanconaty]
103
- * {luigi}[https://github.com/luigi]
104
- * {idris}[https://github.com/idris]
105
-
106
- == Note on Patches/Pull Requests
107
-
108
- * Fork the project.
109
- * Make your feature addition or bug fix.
110
- * Add tests for it. This is important so I don't break it in a
111
- future version unintentionally.
112
- * Commit, do not mess with rakefile, version, or history.
113
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
114
- * Send me a pull request. Bonus points for topic branches.
115
-
116
- == Copyright
117
-
118
- Copyright (c) 2010 Jeroen Jacobs, {redstorm sprl}[http://www.redstorm.be]. See LICENSE for details.
data/Rakefile DELETED
@@ -1,46 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "geo_ip"
8
- gem.summary = "Retreive the geolocation of an IP address based on the ipinfodb.com webservice"
9
- gem.description = "A call to the ipinfodb.com will be done to retreive the geolocation based on the IP address. No need to include a database file in the application."
10
- gem.email = "jacobsjeroen@gmail.com"
11
- gem.homepage = "http://github.com/jeroenj/geo_ip"
12
- gem.authors = ["Jeroen Jacobs"]
13
- gem.add_dependency "json", "~> 1.4.6"
14
- gem.add_development_dependency "rspec", "~> 1.3.0"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
- require 'spec/rake/spectask'
23
- Spec::Rake::SpecTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.spec_files = FileList['spec/**/*_spec.rb']
26
- end
27
-
28
- Spec::Rake::SpecTask.new(:rcov) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.pattern = 'spec/**/*_spec.rb'
31
- spec.rcov = true
32
- end
33
-
34
- task :spec => :check_dependencies
35
-
36
- task :default => :spec
37
-
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "geo_ip #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0
data/geo_ip.gemspec DELETED
@@ -1,61 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{geo_ip}
8
- s.version = "0.3.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jeroen Jacobs"]
12
- s.date = %q{2010-11-16}
13
- s.description = %q{A call to the ipinfodb.com will be done to retreive the geolocation based on the IP address. No need to include a database file in the application.}
14
- s.email = %q{jacobsjeroen@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "CHANGES",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "geo_ip.gemspec",
28
- "init.rb",
29
- "lib/geo_ip.rb",
30
- "spec/api.yml.example",
31
- "spec/geo_ip_spec.rb",
32
- "spec/spec.opts",
33
- "spec/spec_helper.rb"
34
- ]
35
- s.homepage = %q{http://github.com/jeroenj/geo_ip}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.7}
39
- s.summary = %q{Retreive the geolocation of an IP address based on the ipinfodb.com webservice}
40
- s.test_files = [
41
- "spec/geo_ip_spec.rb",
42
- "spec/spec_helper.rb"
43
- ]
44
-
45
- if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
- s.specification_version = 3
48
-
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<json>, ["~> 1.4.6"])
51
- s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
52
- else
53
- s.add_dependency(%q<json>, ["~> 1.4.6"])
54
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
55
- end
56
- else
57
- s.add_dependency(%q<json>, ["~> 1.4.6"])
58
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
59
- end
60
- end
61
-
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'geo_ip'