Skip to content

Commit

Permalink
moved to jeweler and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
djcas9 committed Nov 27, 2009
1 parent 14ff301 commit fb94bc2
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 44 deletions.
49 changes: 41 additions & 8 deletions README.txt → README.rdoc
Expand Up @@ -4,25 +4,58 @@

== DESCRIPTION:

ipdb is a simple gem that utilizes the ipinfodb.com api for IP address
lookups.
IpDB is a simple ruby interface for ipinfodb IP geographical location api.

== INSTALL:

$ sudo gem install ipdb

== FEATURES/PROBLEMS:

* FIX (list of features or problems)
* IP/Domain geographical location
* Look up multiple addresses at once.
* Convenience Methods for Google Maps
* No API usage limit.
* Timezone data is from Geonames. Please refer to Geonames.org for more info about timezones.

* A max of 25 addresses can be parsed during a single query.
* There is a one second pause when querying domain names.

== SYNOPSIS:

FIX (code sample of usage)
Using IpDB is super simple. Here are a few example of how one may use this gem.

Look up my current external address:

ip = Ipdb::Query.new.parse
puts ip.address #=> '127.0.0.1'

Get The latitude and longitude for a domain:

domain = Ipdb::Query.new('snorby.org').parse
puts domain.latitude #=> 38.6446
puts domain.longitude #=> -90.2533

Get the city for an array of IP addresses:

ips = ['127.0.0.1', 'snorby.org', '64.13.134.52']

Ipdb::Query.new(ips, :timeout => 1).each do |ip|
puts ip.hostname
puts ip.city
end

Render a google map from an array of IP addresses:

map = Ipdb::Map.new(ip_array, :width => 600, :height => 350, :units => :px)
map.render

Thats It! Below is a screenshot of its output:

== REQUIREMENTS:

* {nokogiri}[http://nokogiri.rubyforge.org/] >= 1.4.0

== INSTALL:

$ sudo gem install ipdb

== LICENSE:

(The MIT License)
Expand Down
35 changes: 17 additions & 18 deletions Rakefile
@@ -1,26 +1,25 @@
# -*- ruby -*-

require 'rubygems'
require 'hoe'
require 'rake'

require './tasks/spec.rb'
require './tasks/yard.rb'
require './lib/ipdb/version.rb'

Hoe.spec 'ipdb' do
self.rubyforge_name = 'ipdb'
self.developer('Dustin Willis Webber', 'dustin.webber@gmail.com')
self.remote_rdoc_dir = 'docs'
self.extra_deps = [
['nokogiri', '>=1.2.0']
]

self.extra_dev_deps = [
['rspec', '>=1.2.8'],
['yard', '>=0.4.0']
]

self.spec_extras = {:has_rdoc => 'yard'}
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "IpDB"
gem.summary = "IpDB is a simple IP geographical locator."
gem.description = "IpDB is a simple ruby interface for ipinfodb IP geographical location api."
gem.email = "dustin.webber@gmail.com"
gem.homepage = "http://github.com/mephux/ipdb"
gem.authors = ["Dustin Willis Webber"]
gem.add_dependency "nokogiri", ">= 1.4.0"
gem.add_development_dependency "rspec", ">= 1.2.9"
gem.add_development_dependency "yard", ">=0.2.3.5"
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end

# vim: syntax=ruby
21 changes: 9 additions & 12 deletions examples/example.rb
Expand Up @@ -4,30 +4,27 @@

require "rubygems"
require "ipdb"
require "pp"

# puts Ipdb::Query.new('snorby.org').to_xml
# puts Ipdb::Query.new('snorby.org').to_json

@ips = ['173.45.230.150', '127.0.0.1', '219.150.227.101', '219.159.199.34', '222.134.69.181', '222.188.10.1', '68.82.102.9', '80.108.206.239',
@ips = ['173.45.230.150', '219.150.227.101', '219.159.199.34', '222.134.69.181', '222.188.10.1', '68.82.102.9', '80.108.206.239',
'85.113.252.214', '86.100.64.151', '85.132.201.196', '82.228.53.39', '80.35.156.3', '82.238.32.72', '89.77.158.227', '87.97.237.135', '69.226.246.172']

# Ipdb::Query.new(@ips, :timeout => 1).each do |ip|
# puts ip.to_s
# puts ip.hostname if ip.hostname
# end

# ip = Ipdb::Query.new('127.0.0.1').parse
#
# ip = Ipdb::Query.new
# puts ip.address
# puts ip.hostname
# puts ip.latitude
# puts ip.longitude
ips = ['127.0.0.1', 'snorby.org', '64.13.134.52']

puts Ipdb::Query.new(@ips, :zoom => 1).simple_map_url
Ipdb::Query.new(ips, :timeout => 1).each do |ip|
puts ip.hostname
puts ip.city
end

# graph = Ipdb::Map.new(@ips, :zoom => 1)
# puts Ipdb::Query.new(@ips, :zoom => 1).simple_map_url
#
# graph = Ipdb::Map.new(@ips, :zoom => 1)
# puts graph.render


3 changes: 1 addition & 2 deletions lib/ipdb.rb
@@ -1,2 +1 @@
require 'ipdb/query'
require 'ipdb/version'
require 'ipdb/query'
2 changes: 1 addition & 1 deletion lib/ipdb/location.rb
Expand Up @@ -78,7 +78,7 @@ def graph(options={})
end

def to_s
"#{address} #{hostname} #{country} #{region} #{city} #{zipcode}"
"#{address} #{hostname} #{country} #{region} #{city}"
end

end
Expand Down
3 changes: 0 additions & 3 deletions lib/ipdb/version.rb

This file was deleted.

0 comments on commit fb94bc2

Please sign in to comment.