Skip to content

Commit 40cd8a3

Browse files
committed
Initial commit.
1 parent be6b83b commit 40cd8a3

19 files changed

+583
-64
lines changed

.document

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
lib/**/*.rb
2+
bin/*
3+
-
4+
features/**/*.feature
5+
LICENSE.txt

.gitattributes

Lines changed: 0 additions & 17 deletions
This file was deleted.

.gitignore

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
1-
# Windows image file caches
2-
Thumbs.db
3-
ehthumbs.db
4-
5-
# Folder config file
6-
Desktop.ini
7-
8-
# Recycle Bin used on file shares
9-
$RECYCLE.BIN/
10-
11-
# Windows Installer files
12-
*.cab
13-
*.msi
14-
*.msm
15-
*.msp
16-
17-
# Windows shortcuts
18-
*.lnk
19-
20-
# =========================
21-
# Operating System Files
22-
# =========================
23-
24-
# OSX
25-
# =========================
26-
27-
.DS_Store
28-
.AppleDouble
29-
.LSOverride
30-
31-
# Thumbnails
32-
._*
33-
34-
# Files that might appear in the root of a volume
35-
.DocumentRevisions-V100
36-
.fseventsd
37-
.Spotlight-V100
38-
.TemporaryItems
39-
.Trashes
40-
.VolumeIcon.icns
41-
42-
# Directories potentially created on remote AFP share
43-
.AppleDB
44-
.AppleDesktop
45-
Network Trash Folder
46-
Temporary Items
47-
.apdisk
1+
/.bundle/
2+
/.yardoc
3+
/Gemfile.lock
4+
/_yardoc/
5+
/coverage/
6+
/doc/
7+
/pkg/
8+
/spec/reports/
9+
/tmp/

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in ip2proxy_ruby.gemspec
4+
gemspec
5+
gem 'bindata'

LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2016 IP2Location ( [email protected] )
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# IP2Proxy Ruby Library
2+
3+
This is IP2Proxy Ruby library that lookup IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes and data center ranges. The library reads the geo location information from [IP2Proxy database](https://www.ip2location.com/proxy-database)
4+
5+
For more details, please visit:
6+
[https://www.ip2location.com/ip2proxy/developers/ruby](https://www.ip2location.com/ip2proxy/developers/ruby)
7+
8+
## Usage
9+
10+
```
11+
require 'ip2proxy_ruby'
12+
13+
# open IP2Proxy BIN database for proxy lookup
14+
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
15+
16+
# get versioning information
17+
print 'Module Version: ' + i2p.getModuleVersion + "\n"
18+
print 'Package Version: ' + i2p.getPackageVersion + "\n"
19+
print 'Database Version: ' + i2p.getDatabaseVersion + "\n"
20+
21+
# individual proxy data check
22+
print 'Is Proxy: ' + i2p.isProxy('4.0.0.47').to_s + "\n"
23+
print 'Proxy Type: ' + i2p.getProxyType('4.0.0.47') + "\n"
24+
print 'Country Code: ' + i2p.getCountryShort('4.0.0.47') + "\n"
25+
print 'Country Name: ' + i2p.getCountryLong('4.0.0.47') + "\n"
26+
print 'Region Name: ' + i2p.getRegion('4.0.0.47') + "\n"
27+
print 'City Name: ' + i2p.getCity('4.0.0.47') + "\n"
28+
print 'ISP: ' + i2p.getISP('4.0.0.47') + "\n"
29+
30+
# single function to get all proxy data returned in array
31+
record = i2p.getAll('4.0.0.47')
32+
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
33+
print 'Proxy Type: ' + record['proxy_type'] + "\n"
34+
print 'Country Code: ' + record['country_short'] + "\n"
35+
print 'Country Name: ' + record['country_long'] + "\n"
36+
print 'Region Name: ' + record['region'] + "\n"
37+
print 'City Name: ' + record['city'] + "\n"
38+
print 'ISP: ' + record['isp'] + "\n"
39+
40+
# close IP2Proxy BIN database
41+
i2p.close()
42+
```
43+
44+
## Support
45+
46+
47+
URL: [http://www.ip2location.com](http://www.ip2location.com)

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "bundler/gem_tasks"
2+
task :default => :spec

example.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'ip2proxy_ruby'
2+
3+
# open IP2Proxy BIN database for proxy lookup
4+
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
5+
6+
# get versioning information
7+
print 'Module Version: ' + i2p.getModuleVersion + "\n"
8+
print 'Package Version: ' + i2p.getPackageVersion + "\n"
9+
print 'Database Version: ' + i2p.getDatabaseVersion + "\n"
10+
11+
# individual proxy data check
12+
print 'Is Proxy: ' + i2p.isProxy('4.0.0.47').to_s + "\n"
13+
print 'Proxy Type: ' + i2p.getProxyType('4.0.0.47') + "\n"
14+
print 'Country Code: ' + i2p.getCountryShort('4.0.0.47') + "\n"
15+
print 'Country Name: ' + i2p.getCountryLong('4.0.0.47') + "\n"
16+
print 'Region Name: ' + i2p.getRegion('4.0.0.47') + "\n"
17+
print 'City Name: ' + i2p.getCity('4.0.0.47') + "\n"
18+
print 'ISP: ' + i2p.getISP('4.0.0.47') + "\n"
19+
20+
# single function to get all proxy data returned in array
21+
record = i2p.getAll('4.0.0.47')
22+
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
23+
print 'Proxy Type: ' + record['proxy_type'] + "\n"
24+
print 'Country Code: ' + record['country_short'] + "\n"
25+
print 'Country Name: ' + record['country_long'] + "\n"
26+
print 'Region Name: ' + record['region'] + "\n"
27+
print 'City Name: ' + record['city'] + "\n"
28+
print 'ISP: ' + record['isp'] + "\n"
29+
30+
# close IP2Proxy BIN database
31+
i2p.close()

ip2proxy_ruby.gemspec

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# coding: utf-8
2+
3+
Gem::Specification.new do |s|
4+
s.name = "ip2proxy_ruby"
5+
s.version = "1.0.0"
6+
s.authors = ["ip2location"]
7+
s.email = ["[email protected]"]
8+
9+
s.summary = "IP2Proxy Ruby library"
10+
s.description = "Ruby library for IP2Proxy"
11+
s.homepage = "https://github.com/ip2location/ip2proxy-ruby"
12+
s.licenses = ["MIT"]
13+
s.require_paths = ["lib"]
14+
15+
s.extra_rdoc_files = [
16+
"LICENSE.txt",
17+
"README.md"
18+
]
19+
s.files = [
20+
".document",
21+
".gitignore",
22+
"Gemfile",
23+
"Gemfile.lock",
24+
"LICENSE.txt",
25+
"README.md",
26+
"Rakefile",
27+
"ip2proxy_ruby.gemspec",
28+
"example.rb",
29+
"lib/ip2proxy_ruby.rb",
30+
"lib/ip2proxy_ruby/database_config.rb",
31+
"lib/ip2proxy_ruby/i2p_ip_data.rb",
32+
"lib/ip2proxy_ruby/i2p_string_data.rb",
33+
"lib/ip2proxy_ruby/ip2proxy_config.rb",
34+
"lib/ip2proxy_ruby/ip2proxy_record.rb",
35+
"spec/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN",
36+
"spec/ip2proxy_ruby_spec.rb",
37+
"spec/spec_helper.rb",
38+
"rb/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN"
39+
]
40+
41+
if s.respond_to? :specification_version then
42+
s.specification_version = 4
43+
44+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45+
s.add_runtime_dependency(%q<bindata>, [">= 0"])
46+
s.add_development_dependency(%q<awesome_print>, [">= 0"])
47+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
48+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49+
s.add_development_dependency(%q<bundler>, [">= 1.2.0"])
50+
s.add_development_dependency(%q<simplecov>, [">= 0"])
51+
else
52+
s.add_dependency(%q<bindata>, [">= 0"])
53+
s.add_dependency(%q<awesome_print>, [">= 0"])
54+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
55+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
56+
s.add_dependency(%q<bundler>, [">= 1.2.0"])
57+
s.add_dependency(%q<simplecov>, [">= 0"])
58+
end
59+
else
60+
s.add_dependency(%q<bindata>, [">= 0"])
61+
s.add_dependency(%q<awesome_print>, [">= 0"])
62+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
63+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
64+
s.add_dependency(%q<bundler>, [">= 1.2.0"])
65+
s.add_dependency(%q<simplecov>, [">= 0"])
66+
end
67+
end

0 commit comments

Comments
 (0)