Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

drop gemfiles

  • Loading branch information...
commit 9d4a84222eae701889a258ee652ce645c1f761ee 1 parent 7910447
@Achillefs authored
View
2  Manifest.txt
@@ -6,8 +6,10 @@ Rakefile
autometal-geoip.gemspec
bin/install_geoip
lib/geoip.rb
+lib/geoip/city.rb
lib/geoip/geolocatable.rb
lib/geoip/installer.rb
+lib/geoip/organization.rb
script/console
script/destroy
script/generate
View
25 autometal-geoip.gemspec
@@ -2,21 +2,29 @@
Gem::Specification.new do |s|
s.name = %q{autometal-geoip}
- s.version = "0.1.1"
+ s.version = "0.2.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Achillefs Charmpilas"]
- s.date = %q{2010-10-11}
+ s.date = %q{2010-12-07}
+ s.default_executable = %q{install_geoip}
s.description = %q{A wrapper to MaxMind's GeoIP services, that can work with both free and paid versions.
-Also provides geo-location methods to Active Record and Sequel Models.}
+Also provides geo-location methods to Active Record and Sequel Models.
+
+This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com/.}
s.email = ["ac@humbuckercode.co.uk"]
+ s.executables = ["install_geoip"]
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
- s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "geoip.gemspec", "lib/geoip.rb", "lib/geoip/geolocatable.rb", "lib/geoip/installer.rb", "script/console", "script/destroy", "script/generate", "shellscripts/install_binary", "shellscripts/install_db", "test/test_geoip.rb", "test/test_helper.rb"]
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autometal-geoip.gemspec", "bin/install_geoip", "lib/geoip.rb", "lib/geoip/city.rb", "lib/geoip/geolocatable.rb", "lib/geoip/installer.rb", "lib/geoip/organization.rb", "script/console", "script/destroy", "script/generate", "shellscripts/install_binary", "shellscripts/install_db", "test/test_geoip.rb", "test/test_helper.rb"]
s.homepage = %q{http://github.com/Achillefs/geoip}
- s.post_install_message = %q{Thank you for installing autometal-geoip
-This gem will install and use MaxMind's GeoLiteCity database by default.
+ s.post_install_message = %q{
+Thank you for installing autometal-geoip
+
+Please run +sudo install_geoip+ to install the MaxMind binaries
+
+For more information on autometal-geoip, see http://humbuckercode.co.uk/licks/gems/geoip/
-For more information on autometal-geoip, see http://humbuckercode.co.uk/licks/gems/geoip/}
+}
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{autometal-geoip}
@@ -29,13 +37,16 @@ For more information on autometal-geoip, see http://humbuckercode.co.uk/licks/ge
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
s.add_development_dependency(%q<hoe>, [">= 2.6.2"])
else
+ s.add_dependency(%q<activesupport>, [">= 0"])
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
s.add_dependency(%q<hoe>, [">= 2.6.2"])
end
else
+ s.add_dependency(%q<activesupport>, [">= 0"])
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
s.add_dependency(%q<hoe>, [">= 2.6.2"])
end
View
BIN  pkg/autometal-geoip-0.1.3.gem
Binary file not shown
View
BIN  pkg/autometal-geoip-0.1.3.tgz
Binary file not shown
View
4 pkg/autometal-geoip-0.1.3/History.txt
@@ -1,4 +0,0 @@
-=== 0.1.1 2010-10-11
-
-* 1 major enhancement:
- * Initial release
View
17 pkg/autometal-geoip-0.1.3/Manifest.txt
@@ -1,17 +0,0 @@
-History.txt
-Manifest.txt
-PostInstall.txt
-README.rdoc
-Rakefile
-autometal-geoip.gemspec
-bin/install_geoip
-lib/geoip.rb
-lib/geoip/geolocatable.rb
-lib/geoip/installer.rb
-script/console
-script/destroy
-script/generate
-shellscripts/install_binary
-shellscripts/install_db
-test/test_geoip.rb
-test/test_helper.rb
View
7 pkg/autometal-geoip-0.1.3/PostInstall.txt
@@ -1,7 +0,0 @@
-
-Thank you for installing autometal-geoip
-
-Please run +sudo install_geoip+ to install the MaxMind binaries
-
-For more information on autometal-geoip, see http://humbuckercode.co.uk/licks/gems/geoip/
-
View
93 pkg/autometal-geoip-0.1.3/README.rdoc
@@ -1,93 +0,0 @@
-= autometal-geoip
-
-* http://github.com/Achillefs/geoip
-
-== DESCRIPTION:
-A wrapper to MaxMind's GeoIP services, that can work with both free and paid versions.
-Also provides geo-location methods to Active Record and Sequel Models.
-
-This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com/.
-
-=== Why?
-It is quite fast, simple and hackable, and it doesn't require any change to your application schema - unless you want to.
-Plus, the ruby bindings available from MaxMind are quite crap to use.
-
-== FEATURES/PROBLEMS:
-
-* While you are installing the MaxMind binaries on Linux systems, you mayget an error similar to this:
- libGeoIP.so.1: cannot open shared object file: No such file or directory
- If you do, do the following:
- $ vim /etc/ld.so.conf (and add /var/shared/lib)
- $ ldconfig
- And rerun the installer
-
-== SYNOPSIS:
-
-Autometal::Geoip provides a standalone GeoIP service:
- require "rubygems"
- require "geoip"
- @geo = Autometal::Geoip.new("66.102.13.106")
- @geo.country
- => US
-
-You can also pass it a domain instead of an IP address
- @geo = Autometal::Geoip.new("www.google.com")
- @geo.country
- => US
-
-You can make any object Geo-location aware, as long as it has an IP or a domain attribute:
- require "rubygems"
- require "geoip"
- class Site
- include Geolocatable
- end
- Site.new(:domain => "google.com")
- site.country
- => "US"
-
-The above will work if your class has a +domain+ attribute.
-You can override the attribute used to geolocate by overriding +geo_attr+
-
- require "rubygems"
- require "geoip"
- class Site
- include Geolocatable
- def geo_attr; self.weird_ip_field_name; end
- end
- Site.new(:weird_ip_field_name => "66.102.13.106")
- site.country
- => "US"
-
-== REQUIREMENTS:
-
-* GeoIP C bindings (installed along with the Gem)
-* Active Support
- This isn't really needed, I just like using the 1.day.ago stuff too much...
-
-== INSTALL:
-
- sudo gem install autometal-geoip
- sudo install_geoip (unless already installed)
-
-== LICENSE:
-
-Copyright (c) 2010 Achillefs Charmpilas, Humbucker Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
16 pkg/autometal-geoip-0.1.3/Rakefile
@@ -1,16 +0,0 @@
-require 'rubygems'
-gem 'hoe', '>= 2.1.0'
-require 'hoe'
-require 'fileutils'
-require './lib/geoip'
-
-Hoe.plugin :newgem
-$hoe = Hoe.spec 'autometal-geoip' do
- self.developer 'Achillefs Charmpilas', 'ac@humbuckercode.co.uk'
- self.post_install_message = File.read('PostInstall.txt')
- self.rubyforge_name = self.name
- self.extra_deps = [['activesupport','>= 0']]
-end
-
-require 'newgem/tasks'
-Dir['tasks/**/*.rake'].each { |t| load t }
View
42 pkg/autometal-geoip-0.1.3/autometal-geoip.gemspec
@@ -1,42 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{autometal-geoip}
- s.version = "0.1.1"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Achillefs Charmpilas"]
- s.date = %q{2010-10-11}
- s.description = %q{A wrapper to MaxMind's GeoIP services, that can work with both free and paid versions.
-Also provides geo-location methods to Active Record and Sequel Models.}
- s.email = ["ac@humbuckercode.co.uk"]
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
- s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "geoip.gemspec", "lib/geoip.rb", "lib/geoip/geolocatable.rb", "lib/geoip/installer.rb", "script/console", "script/destroy", "script/generate", "shellscripts/install_binary", "shellscripts/install_db", "test/test_geoip.rb", "test/test_helper.rb"]
- s.homepage = %q{http://github.com/Achillefs/geoip}
- s.post_install_message = %q{Thank you for installing autometal-geoip
-This gem will install and use MaxMind's GeoLiteCity database by default.
-
-For more information on autometal-geoip, see http://humbuckercode.co.uk/licks/gems/geoip/}
- s.rdoc_options = ["--main", "README.rdoc"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{autometal-geoip}
- s.rubygems_version = %q{1.3.7}
- s.summary = %q{A wrapper to MaxMind's GeoIP services, that can work with both free and paid versions}
- s.test_files = ["test/test_geoip.rb", "test/test_helper.rb"]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
- s.add_development_dependency(%q<hoe>, [">= 2.6.2"])
- else
- s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
- s.add_dependency(%q<hoe>, [">= 2.6.2"])
- end
- else
- s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
- s.add_dependency(%q<hoe>, [">= 2.6.2"])
- end
-end
View
7 pkg/autometal-geoip-0.1.3/bin/install_geoip
@@ -1,7 +0,0 @@
-#! /usr/bin/env ruby
-require "rubygems"
-require "geoip"
-
-puts "Attempting to install MaxMind GeoIP binaries..."
-Autometal::Geoip::Installer.new("GeoLiteCity")
-puts "Done."
View
36 pkg/autometal-geoip-0.1.3/lib/geoip.rb
@@ -1,36 +0,0 @@
-$:.unshift(File.dirname(__FILE__)) unless
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
-
-module Autometal
- class Geoip
- VERSION = '0.2.2'
- DATA_FILE_PATH = "/usr/local/share/GeoIP/"
- BIN = "geoiplookup"
-
- def self.bin_installed?
- %x{ #{self::BIN} --version } == "" ? false : true
- end
-
- class Package
- attr_accessor :version
- def initialize ip_or_domain
- return false unless self.class.installed?
- @response = self.lookup ip_or_domain
- process_response
- end
-
- def self.installed?
- return false unless Geoip.bin_installed?
- return false unless File.exists? data_file
- true
- end
-
- def lookup ip_or_domain
- puts "#{Geoip::BIN} -f #{self.class.data_file} #{ip_or_domain}"
- %x{ #{Geoip::BIN} -f #{self.class.data_file} #{ip_or_domain} }
- end
- end
- end
-end
-
-%W[installer geolocatable city organization].each { |r| require "#{File.dirname(__FILE__)}/geoip/#{r}" }
View
40 pkg/autometal-geoip-0.1.3/lib/geoip/geolocatable.rb
@@ -1,40 +0,0 @@
-module Autometal
- module Geolocatable
- def geoip_city
- @geoip_city = false unless @geoip_city
- if Autometal::Geoip::City.installed?
- @geoip_city = Autometal::Geoip::City.new(geo_attr) unless @geoip_city
- end
- @geoip_city
- end
- def geoip_org
- @geoip_org = false unless @geoip_org
- if Autometal::Geoip::Organization.installed?
- @geoip_org = Autometal::Geoip::Organization.new(geo_attr) unless @geoip_org
- end
- @geoip_org
- end
-
- def geo_attr
- begin
- send(:ip)
- rescue NoMethodError
- send(:domain)
- end
- end
- def country; geoip_city.country if geoip_city; end
-
- def county; geoip_city.county if geoip_city; end
-
- def city; geoip_city.city if geoip_city; end
-
- def lat; geoip_city.lat if geoip_city; end
-
- def lng; geoip_city.lng if geoip_city; end
-
- def organization; geoip_org.organization if geoip_org; end
-
- def latlng; geoip_city.latlng if geoip_city; end
- alias :latlon :latlng
- end
-end
View
36 pkg/autometal-geoip-0.1.3/lib/geoip/installer.rb
@@ -1,36 +0,0 @@
-require "active_support"
-require "fileutils"
-
-module Autometal
- class Geoip
- class Installer
- BASE_DB_URL = "http://geolite.maxmind.com/download/geoip/database/*.dat.gz"
- PACKAGE_URL = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz"
-
- def initialize package_name = "GeoLiteCity"
- @package_name = package_name
- @db_url = BASE_DB_URL.gsub("*",@package_name)
- install_binary
- install_database
- end
-
- private
- def install_binary
- if Autometal::Geoip.bin_installed?
- puts "Binary already installed, skipping"
- else
- `cd #{File.dirname(__FILE__)}/../../shellscripts/ && ./install_binary #{PACKAGE_URL}`
- end
- end
-
- def install_database
- target = File.join(Autometal::Geoip::DATA_FILE_PATH,"#{@package_name}.dat")
- if File.exists?(target) and File::ctime(target) > 1.month.ago
- puts "Datafile is up to date, skipping"
- else
- `cd #{File.dirname(__FILE__)}/../../shellscripts/ && ./install_db #{@db_url}`
- end
- end
- end
- end
-end
View
10 pkg/autometal-geoip-0.1.3/script/console
@@ -1,10 +0,0 @@
-#!/usr/bin/env ruby
-# File: script/console
-irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
-
-libs = " -r irb/completion"
-# Perhaps use a console_lib to store any extra methods I may want available in the cosole
-# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
-libs << " -r #{File.dirname(__FILE__) + '/../lib/geoip.rb'}"
-puts "Loading geoip gem"
-exec "#{irb} #{libs} --simple-prompt"
View
14 pkg/autometal-geoip-0.1.3/script/destroy
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
-begin
- require 'rubigen'
-rescue LoadError
- require 'rubygems'
- require 'rubigen'
-end
-require 'rubigen/scripts/destroy'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
-RubiGen::Scripts::Destroy.new.run(ARGV)
View
14 pkg/autometal-geoip-0.1.3/script/generate
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
-begin
- require 'rubigen'
-rescue LoadError
- require 'rubygems'
- require 'rubigen'
-end
-require 'rubigen/scripts/generate'
-
-ARGV.shift if ['--help', '-h'].include?(ARGV[0])
-RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
-RubiGen::Scripts::Generate.new.run(ARGV)
View
7 pkg/autometal-geoip-0.1.3/shellscripts/install_binary
@@ -1,7 +0,0 @@
-#! /bin/bash
-mkdir ./tmp && cd ./tmp
-wget $1
-tar -xzvf *.gz && cd GeoIP*
-./configure && make && make check && sudo make install
-cd ../..
-rm -rf ./tmp
View
9 pkg/autometal-geoip-0.1.3/shellscripts/install_db
@@ -1,9 +0,0 @@
-#! /bin/bash
-mkdir ./tmp
-cd ./tmp
-wget $1
-gunzip *.gz
-sudo mkdir -p /usr/local/share/GeoIP/
-sudo mv *.dat /usr/local/share/GeoIP/
-cd ..
-rm -rf ./tmp
View
32 pkg/autometal-geoip-0.1.3/test/test_geoip.rb
@@ -1,32 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper.rb'
-
-class TestGeoip < Test::Unit::TestCase
-
- def setup
- @dummy = Dummy.new
- @dummy2 = AnotherDummy.new
- end
-
- def test_objects_are_geolocatable
- assert_not_nil @dummy.country if Autometal::Geoip::City.installed?
- end
-
- def test_object_responds_to_organization_if_installed
- assert_not_nil @dummy.organization if Autometal::Geoip::Organization.installed?
- end
-
- def test_gem_can_install_binaries
- assert_nothing_raised do
- Autometal::Geoip::Installer.new("GeoLiteCity")
- end
- assert_equal true, Autometal::Geoip.bin_installed?
- assert_not_nil @dummy.country, "Country should not be nil"
- assert_not_nil @dummy.city, "City should not be nil"
- assert_not_nil @dummy.lat, "Latitude should not be nil"
- assert_not_nil @dummy.lng, "Longitude should not be nil"
- end
-
- def test_can_override_geo_attribute
- assert_equal @dummy.country, @dummy2.country
- end
-end
View
20 pkg/autometal-geoip-0.1.3/test/test_helper.rb
@@ -1,20 +0,0 @@
-%W[ stringio test/unit open-uri #{File.dirname(__FILE__)}/../lib/geoip ].each { |r| require r }
-
-class Dummy
- include Autometal::Geolocatable
- attr_accessor :ip
-
- def initialize
- @ip = open("http://check-rankings.co.uk").read rescue "66.102.13.105"
- end
-end
-
-class AnotherDummy
- include Autometal::Geolocatable
- attr_accessor :pantera
-
- def initialize
- @pantera = open("http://check-rankings.co.uk").read rescue "66.102.13.105"
- end
- def geo_attr; pantera; end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.