ipgp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/Gemfile +2 -0
  2. data/README.md +40 -0
  3. data/Rakefile +2 -0
  4. data/ipgp.gemspec +19 -0
  5. data/lib/ipgp.rb +23 -0
  6. data/lib/version.rb +3 -0
  7. metadata +86 -0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
@@ -0,0 +1,40 @@
1
+ # Ipgp gem — Wrapper around ipgp.net
2
+
3
+ ## Usage
4
+
5
+ ``` ruby
6
+ Ipgp.new('2.123.123.32', 'RyZBqulp7j')
7
+ ```
8
+
9
+ ## Installation
10
+
11
+ Puts this line into `Gemfile` then run `$ bundle`:
12
+
13
+ ``` ruby
14
+ gem 'ipgp'
15
+ ```
16
+
17
+ Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
18
+
19
+ ``` ruby
20
+ config.gem 'ipgp'
21
+ ```
22
+
23
+ Or manually install cupid gem: `$ gem install ipgp`
24
+
25
+ ## Contributors
26
+
27
+ * @aderyabin
28
+
29
+ ## License
30
+
31
+ The MIT License
32
+
33
+ Copyright (c) 2011 Andrey Deryabin <aderyabin@evilmartians.com>
34
+
35
+ 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:
36
+
37
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
38
+
39
+ 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.
40
+
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'ipgp'
6
+ s.authors = ['Andrey Deryabin']
7
+ s.email = ['aderyabin@evilmartians.com']
8
+ s.homepage = 'http://github.com/aderyabin/ipgp'
9
+ s.summary = 'Wrapper around the ipgp.net (IP Address Lookup)'
10
+ s.description = 'Wrapper around the ipgp.net (IP Address Lookup)'
11
+
12
+ s.add_dependency "xml-simple", "~> 1.1.1"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ['lib']
18
+ s.version = Ipgp::VERSION
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'xmlsimple'
2
+ require 'net/http'
3
+
4
+ class Ipgp
5
+
6
+ attr_reader :region, :city, :country, :code, :lng, :flag, :isp, :ip, :lat
7
+
8
+ def initialize(ip, key = 'RyZBqulp7j')
9
+ url = "http://www.ipgp.net/api/xml/#{ip}/#{key}"
10
+ xml_data = Net::HTTP.get_response(URI.parse(url)).body
11
+ data = XmlSimple.xml_in(xml_data)
12
+ @region = data['Region'].first
13
+ @city = data['City'].first
14
+ @country = data['Country'].first
15
+ @code = data['Code'].first
16
+ @lng = data['Lng'].first
17
+ @flag = data['Flag'].first
18
+ @isp = data['Isp'].first
19
+ @ip = data['Ip'].first
20
+ @lat = data['Lat'].first
21
+ end
22
+ end
23
+
@@ -0,0 +1,3 @@
1
+ class Ipgp
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ipgp
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Andrey Deryabin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-11 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: xml-simple
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 17
29
+ segments:
30
+ - 1
31
+ - 1
32
+ - 1
33
+ version: 1.1.1
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Wrapper around the ipgp.net (IP Address Lookup)
37
+ email:
38
+ - aderyabin@evilmartians.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - Gemfile
47
+ - README.md
48
+ - Rakefile
49
+ - ipgp.gemspec
50
+ - lib/ipgp.rb
51
+ - lib/version.rb
52
+ homepage: http://github.com/aderyabin/ipgp
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.15
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Wrapper around the ipgp.net (IP Address Lookup)
85
+ test_files: []
86
+