Skip to content

Commit be0174f

Browse files
committed
Update method name.
1 parent c597744 commit be0174f

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016 IP2Location ( [email protected] )
1+
Copyright (c) 2018 IP2Location ( [email protected] )
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ Below are the methods supported in this module.
1717
|---|---|
1818
|open|Open the IP2Proxy BIN data with **File I/O** mode for lookup.|
1919
|close|Close and clean up the file pointer.|
20-
|getPackageVersion|Get the package version (1 to 4 for PX1 to PX4 respectively).|
21-
|getModuleVersion|Get the module version.|
22-
|getDatabaseVersion|Get the database version.|
23-
|isProxy|Check whether if an IP address was a proxy. Returned value:<ul><li>-1 : errors</li><li>0 : not a proxy</li><li>1 : a proxy</li><li>2 : a data center IP address</li></ul>|
24-
|getAll|Return the proxy information in array.|
25-
|getProxyType|Return the proxy type. Please visit <a href="https://www.ip2location.com/databases/px4-ip-proxytype-country-region-city-isp" target="_blank">IP2Location</a> for the list of proxy types supported|
26-
|getCountryShort|Return the ISO3166-1 country code (2-digits) of the proxy.|
27-
|getCountryLong|Return the ISO3166-1 country name of the proxy.|
28-
|getRegion|Return the ISO3166-2 region name of the proxy. Please visit <a href="https://www.ip2location.com/free/iso3166-2" target="_blank">ISO3166-2 Subdivision Code</a> for the information of ISO3166-2 supported|
29-
|getCity|Return the city name of the proxy.|
30-
|getISP|Return the ISP name of the proxy.|
20+
|get_package_version|Get the package version (1 to 4 for PX1 to PX4 respectively).|
21+
|get_module_version|Get the module version.|
22+
|get_database_version|Get the database version.|
23+
|is_proxy|Check whether if an IP address was a proxy. Returned value:<ul><li>-1 : errors</li><li>0 : not a proxy</li><li>1 : a proxy</li><li>2 : a data center IP address</li></ul>|
24+
|get_all|Return the proxy information in array.|
25+
|get_proxytype|Return the proxy type. Please visit <a href="https://www.ip2location.com/databases/px4-ip-proxytype-country-region-city-isp" target="_blank">IP2Location</a> for the list of proxy types supported|
26+
|get_country_short|Return the ISO3166-1 country code (2-digits) of the proxy.|
27+
|get_country_long|Return the ISO3166-1 country name of the proxy.|
28+
|get_region|Return the ISO3166-2 region name of the proxy. Please visit <a href="https://www.ip2location.com/free/iso3166-2" target="_blank">ISO3166-2 Subdivision Code</a> for the information of ISO3166-2 supported|
29+
|get_city|Return the city name of the proxy.|
30+
|get_isp|Return the ISP name of the proxy.|
3131

3232
## Usage
3333

@@ -38,21 +38,21 @@ require 'ip2proxy_ruby'
3838
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
3939
4040
# get versioning information
41-
print 'Module Version: ' + i2p.getModuleVersion + "\n"
42-
print 'Package Version: ' + i2p.getPackageVersion + "\n"
43-
print 'Database Version: ' + i2p.getDatabaseVersion + "\n"
41+
print 'Module Version: ' + i2p.get_module_version + "\n"
42+
print 'Package Version: ' + i2p.get_package_version + "\n"
43+
print 'Database Version: ' + i2p.get_database_version + "\n"
4444
4545
# individual proxy data check
46-
print 'Is Proxy: ' + i2p.isProxy('4.0.0.47').to_s + "\n"
47-
print 'Proxy Type: ' + i2p.getProxyType('4.0.0.47') + "\n"
48-
print 'Country Code: ' + i2p.getCountryShort('4.0.0.47') + "\n"
49-
print 'Country Name: ' + i2p.getCountryLong('4.0.0.47') + "\n"
50-
print 'Region Name: ' + i2p.getRegion('4.0.0.47') + "\n"
51-
print 'City Name: ' + i2p.getCity('4.0.0.47') + "\n"
52-
print 'ISP: ' + i2p.getISP('4.0.0.47') + "\n"
46+
print 'Is Proxy: ' + i2p.is_proxy('4.0.0.47').to_s + "\n"
47+
print 'Proxy Type: ' + i2p.get_proxytype('4.0.0.47') + "\n"
48+
print 'Country Code: ' + i2p.get_country_short('4.0.0.47') + "\n"
49+
print 'Country Name: ' + i2p.get_country_long('4.0.0.47') + "\n"
50+
print 'Region Name: ' + i2p.get_region('4.0.0.47') + "\n"
51+
print 'City Name: ' + i2p.get_city('4.0.0.47') + "\n"
52+
print 'ISP: ' + i2p.get_isp('4.0.0.47') + "\n"
5353
5454
# single function to get all proxy data returned in array
55-
record = i2p.getAll('4.0.0.47')
55+
record = i2p.get_all('4.0.0.47')
5656
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
5757
print 'Proxy Type: ' + record['proxy_type'] + "\n"
5858
print 'Country Code: ' + record['country_short'] + "\n"

example.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
55

66
# get versioning information
7-
print 'Module Version: ' + i2p.getModuleVersion + "\n"
8-
print 'Package Version: ' + i2p.getPackageVersion + "\n"
9-
print 'Database Version: ' + i2p.getDatabaseVersion + "\n"
7+
print 'Module Version: ' + i2p.get_module_version + "\n"
8+
print 'Package Version: ' + i2p.get_package_version + "\n"
9+
print 'Database Version: ' + i2p.get_database_version + "\n"
1010

1111
# 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"
12+
print 'Is Proxy: ' + i2p.is_proxy('4.0.0.47').to_s + "\n"
13+
print 'Proxy Type: ' + i2p.get_proxytype('4.0.0.47') + "\n"
14+
print 'Country Code: ' + i2p.get_country_short('4.0.0.47') + "\n"
15+
print 'Country Name: ' + i2p.get_country_long('4.0.0.47') + "\n"
16+
print 'Region Name: ' + i2p.get_region('4.0.0.47') + "\n"
17+
print 'City Name: ' + i2p.get_city('4.0.0.47') + "\n"
18+
print 'ISP: ' + i2p.get_isp('4.0.0.47') + "\n"
1919

2020
# single function to get all proxy data returned in array
21-
record = i2p.getAll('4.0.0.47')
21+
record = i2p.get_all('4.0.0.47')
2222
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
2323
print 'Proxy Type: ' + record['proxy_type'] + "\n"
2424
print 'Country Code: ' + record['country_short'] + "\n"

ip2proxy_ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gem::Specification.new do |s|
44
s.name = "ip2proxy_ruby"
5-
s.version = "1.0.2"
5+
s.version = "1.0.3"
66
s.authors = ["ip2location"]
77
s.email = ["[email protected]"]
88

lib/ip2proxy_ruby.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class Ip2proxy
1010
attr_accessor :record_class4, :record_class6, :v4, :file, :db_index, :count, :base_addr, :ipno, :record, :database, :columns, :ip_version, :ipv4databasecount, :ipv4databaseaddr, :ipv4indexbaseaddr, :ipv6databasecount, :ipv6databaseaddr, :ipv6indexbaseaddr, :databaseyear, :databasemonth, :databaseday
1111

12-
VERSION = '1.0.2'
12+
VERSION = '1.0.3'
1313
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
1414
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
1515

@@ -37,15 +37,15 @@ def close()
3737
self.file.close
3838
end
3939

40-
def getModuleVersion()
40+
def get_module_version()
4141
return VERSION
4242
end
4343

44-
def getPackageVersion()
44+
def get_package_version()
4545
return (self.db_index).to_s
4646
end
4747

48-
def getDatabaseVersion()
48+
def get_database_version()
4949
return (self.databaseyear).to_s + "." + (self.databasemonth).to_s + "." + (self.databaseday).to_s
5050
end
5151

@@ -77,7 +77,7 @@ def get_record(ip)
7777
end
7878
end
7979

80-
def getCountryShort(ip)
80+
def get_country_short(ip)
8181
valid = !(IPAddr.new(ip) rescue nil).nil?
8282
if valid
8383
rec = get_record(ip)
@@ -92,7 +92,7 @@ def getCountryShort(ip)
9292
return country_short
9393
end
9494

95-
def getCountryLong(ip)
95+
def get_country_long(ip)
9696
valid = !(IPAddr.new(ip) rescue nil).nil?
9797
if valid
9898
rec = get_record(ip)
@@ -107,7 +107,7 @@ def getCountryLong(ip)
107107
return country_long
108108
end
109109

110-
def getRegion(ip)
110+
def get_region(ip)
111111
valid = !(IPAddr.new(ip) rescue nil).nil?
112112
if valid
113113
rec = get_record(ip)
@@ -122,7 +122,7 @@ def getRegion(ip)
122122
return region
123123
end
124124

125-
def getCity(ip)
125+
def get_city(ip)
126126
valid = !(IPAddr.new(ip) rescue nil).nil?
127127
if valid
128128
rec = get_record(ip)
@@ -137,7 +137,7 @@ def getCity(ip)
137137
return city
138138
end
139139

140-
def getISP(ip)
140+
def get_isp(ip)
141141
valid = !(IPAddr.new(ip) rescue nil).nil?
142142
if valid
143143
rec = get_record(ip)
@@ -152,7 +152,7 @@ def getISP(ip)
152152
return isp
153153
end
154154

155-
def getProxyType(ip)
155+
def get_proxytype(ip)
156156
valid = !(IPAddr.new(ip) rescue nil).nil?
157157
if valid
158158
rec = get_record(ip)
@@ -167,7 +167,7 @@ def getProxyType(ip)
167167
return proxytype
168168
end
169169

170-
def isProxy(ip)
170+
def is_proxy(ip)
171171
valid = !(IPAddr.new(ip) rescue nil).nil?
172172
if valid
173173
rec = get_record(ip)
@@ -186,7 +186,7 @@ def isProxy(ip)
186186
return isproxy
187187
end
188188

189-
def getAll(ip)
189+
def get_all(ip)
190190
valid = !(IPAddr.new(ip) rescue nil).nil?
191191
if valid
192192
rec = get_record(ip)

spec/ip2proxy_ruby_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
describe "Ip2proxy" do
44
it "work correctly with ipv4" do
55
i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
6-
record = i2p.getAll('1.0.241.135')
6+
record = i2p.get_all('1.0.241.135')
77
record.should_not be_nil
88
record['is_proxy'].should == 1
99
i2p.close()
1010
end
1111

1212
it "work correctly with ipv6" do
1313
i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
14-
record = i2p.getAll('2001::')
14+
record = i2p.get_all('2001::')
1515
record.should_not be_nil
1616
record['is_proxy'].should == 0
1717
i2p.close()

0 commit comments

Comments
 (0)