ipgeobase 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
6
+ *.swo
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ipgeobase.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ipgeobase/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ipgeobase"
7
+ s.version = Ipgeobase::VERSION
8
+ s.authors = ["Mokevnin Kirill"]
9
+ s.email = ["mokevnin@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{geo to ip}
12
+ s.description = %q{geo to ip}
13
+
14
+ s.rubyforge_project = "ipgeobase"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "happymapper"
24
+ end
@@ -0,0 +1,14 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'happymapper'
4
+
5
+ module Ipgeobase
6
+ autoload 'Version', 'ipgeobase/version'
7
+ autoload 'IpMetaData', 'ipgeobase/ip_meta_data'
8
+
9
+ def self.lookup(ip)
10
+ uri = URI.parse('http://ipgeobase.ru:7020/geo')
11
+ uri.query = URI.encode_www_form :ip => ip
12
+ IpMetaData.parse(Net::HTTP.get(uri))
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ require 'iconv'
2
+
3
+ module Ipgeobase
4
+ class IpMetaData
5
+ include HappyMapper
6
+
7
+ tag 'ip-answer'
8
+ element :city, String, :deep => true
9
+ element :country, String, :deep => true
10
+ element :region, String, :deep => true
11
+ element :district, String, :deep => true
12
+ element :lat, Float, :deep => true
13
+ element :lng, Float, :deep => true
14
+
15
+ def city
16
+ Iconv.iconv('windows-1251', 'utf-8', @city).first
17
+ end
18
+
19
+ def country
20
+ Iconv.iconv('windows-1251', 'utf-8', @country).first
21
+ end
22
+
23
+ def region
24
+ Iconv.iconv('windows-1251', 'utf-8', @region).first
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Ipgeobase
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ipgeobase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mokevnin Kirill
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: happymapper
16
+ requirement: &18988120 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *18988120
25
+ description: geo to ip
26
+ email:
27
+ - mokevnin@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - ipgeobase.gemspec
36
+ - lib/ipgeobase.rb
37
+ - lib/ipgeobase/ip_meta_data.rb
38
+ - lib/ipgeobase/version.rb
39
+ homepage: ''
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project: ipgeobase
59
+ rubygems_version: 1.8.10
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: geo to ip
63
+ test_files: []