ip2location_ruby 8.0.1 → 8.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
- class I2lFloatData < BinData::BasePrimitive
2
-
3
- def read_and_return_value(io)
4
- addr = BinData::FloatLe.read(io)
5
- end
6
-
1
+ class I2lFloatData < BinData::BasePrimitive
2
+
3
+ def read_and_return_value(io)
4
+ addr = BinData::FloatLe.read(io)
5
+ end
6
+
7
7
  end
@@ -1,10 +1,10 @@
1
- class I2lIpData < BinData::BasePrimitive
2
- def read_and_return_value(io)
3
- iv = eval_parameter(:ip_version)
4
- if iv == 4
5
- addr = BinData::Uint32le.read(io)
6
- elsif iv == 6
7
- addr = BinData::Uint128le.read(io)
8
- end
9
- end
1
+ class I2lIpData < BinData::BasePrimitive
2
+ def read_and_return_value(io)
3
+ iv = eval_parameter(:ip_version)
4
+ if iv == 4
5
+ addr = BinData::Uint32le.read(io)
6
+ elsif iv == 6
7
+ addr = BinData::Uint128le.read(io)
8
+ end
9
+ end
10
10
  end
@@ -1,16 +1,16 @@
1
- class I2lStringData < BinData::BasePrimitive
2
-
3
- def read_and_return_value(io)
4
- country_long = eval_parameter(:country_long)
5
- io.seekbytes(-4) if country_long
6
- file = io.instance_variable_get('@raw_io')
7
- addr = BinData::Uint32le.read(io)
8
- old_offset = file.tell
9
- country_long ? file.seek(addr + 3) : file.seek(addr)
10
- length = BinData::Uint8.read(file)
11
- res = BinData::String.new(:length => length).read(file)
12
- file.seek(old_offset)
13
- res
14
- end
15
-
1
+ class I2lStringData < BinData::BasePrimitive
2
+
3
+ def read_and_return_value(io)
4
+ country_long = eval_parameter(:country_long)
5
+ io.seekbytes(-4) if country_long
6
+ file = io.instance_variable_get('@raw_io')
7
+ addr = BinData::Uint32le.read(io)
8
+ old_offset = file.tell
9
+ country_long ? file.seek(addr + 3) : file.seek(addr)
10
+ length = BinData::Uint8.read(file)
11
+ res = BinData::String.new(:length => length).read(file)
12
+ file.seek(old_offset)
13
+ res
14
+ end
15
+
16
16
  end
@@ -1,17 +1,17 @@
1
- class Ip2locationConfig < BinData::Record
2
- endian :little
3
- uint8 :databasetype
4
- uint8 :databasecolumn
5
- uint8 :databaseday
6
- uint8 :databasemonth
7
- uint8 :databaseyear
8
- # uint32 :databasecount
9
- # uint32 :databaseaddr
10
- # uint32 :ipversion
11
- uint32 :ipv4databasecount
12
- uint32 :ipv4databaseaddr
13
- uint32 :ipv6databasecount
14
- uint32 :ipv6databaseaddr
15
- uint32 :ipv4indexbaseaddr
16
- uint32 :ipv6indexbaseaddr
1
+ class Ip2locationConfig < BinData::Record
2
+ endian :little
3
+ uint8 :databasetype
4
+ uint8 :databasecolumn
5
+ uint8 :databaseday
6
+ uint8 :databasemonth
7
+ uint8 :databaseyear
8
+ # uint32 :databasecount
9
+ # uint32 :databaseaddr
10
+ # uint32 :ipversion
11
+ uint32 :ipv4databasecount
12
+ uint32 :ipv4databaseaddr
13
+ uint32 :ipv6databasecount
14
+ uint32 :ipv6databaseaddr
15
+ uint32 :ipv4indexbaseaddr
16
+ uint32 :ipv6indexbaseaddr
17
17
  end
@@ -1,22 +1,22 @@
1
- class Ip2LocationRecord
2
- def self.init(database, ip_version)
3
- cls = Class.new(BinData::Record)
4
- cls.class_eval {
5
- endian :little
6
- i2l_ip_data :ip_from, :ip_version => ip_version
7
- database.each do |col|
8
- if [:latitude, :longitude].include? col.first
9
- i2l_float_data col.first
10
- elsif col.first == :country
11
- i2l_string_data :country_short
12
- i2l_string_data :country_long, :country_long => true
13
- else
14
- i2l_string_data col.first
15
- end
16
- end
17
-
18
- i2l_ip_data :ip_to, :ip_version => ip_version
19
- }
20
- cls
21
- end
1
+ class Ip2LocationRecord
2
+ def self.init(database, ip_version)
3
+ cls = Class.new(BinData::Record)
4
+ cls.class_eval {
5
+ endian :little
6
+ i2l_ip_data :ip_from, :ip_version => ip_version
7
+ database.each do |col|
8
+ if [:latitude, :longitude].include? col.first
9
+ i2l_float_data col.first
10
+ elsif col.first == :country
11
+ i2l_string_data :country_short
12
+ i2l_string_data :country_long, :country_long => true
13
+ else
14
+ i2l_string_data col.first
15
+ end
16
+ end
17
+
18
+ i2l_ip_data :ip_to, :ip_version => ip_version
19
+ }
20
+ cls
21
+ end
22
22
  end
@@ -1,53 +1,53 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Ip2location" do
4
- it "work correctly with ipv4" do
5
- i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP-COUNTRY-SAMPLE.bin")
6
- record = i2l.get_all('13.5.10.6')
7
- record.should_not be_nil
8
- record.country_short.should == 'US'
9
- end
10
-
11
- it "work correctly with ipv4 with new library" do
12
- i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/DB24.DEMO4.bin")
13
- record = i2l.get_all('13.5.10.6')
14
- record.should_not be_nil
15
- record.country_short.should == 'KR'
16
- end
17
-
18
- it "work correctly with ipv6 with new library" do
19
- i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/DB24.DEMO6.bin")
20
- record = i2l.get_all('2a01:04f8:0d16:26c2::')
21
- record.should_not be_nil
22
- record.country_short.should == 'DE'
23
- end
24
-
25
- # it "profile ipv6 in IPV6.BIN" do
26
- # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
27
- # File.new(File.dirname(__FILE__) + "/assets/ipv6_ip.txt").readlines.each do |line|
28
- # record = i2l.get_all(line.split(' ').first)
29
- # end
30
- # end
31
-
32
- # it "profile ipv4 in IPV6.BIN" do
33
- # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
34
- # File.new(File.dirname(__FILE__) + "/assets/ipv4_ip.txt").readlines.each do |line|
35
- # record = i2l.get_all(line.split(' ').first)
36
- # end
37
- # end
38
-
39
- # it "profile ipv4 in IPV4.BIN" do
40
- # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
41
- # File.new(File.dirname(__FILE__) + "/assets/ipv4_ip.txt").readlines.each do |line|
42
- # record = i2l.get_all(line.split(' ').first)
43
- # end
44
- # end
45
-
46
- # this need spec/assets/IP2LOCATION-LITE-DB5.bin file which too big to include in this test.
47
-
48
- # it "should get float value of attitude" do
49
- # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP2LOCATION-LITE-DB5.bin")
50
- # record = i2l.get_all('192.110.164.88')
51
- # record['latitude'].should eq(33.44837951660156)
52
- # end
53
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ip2location" do
4
+ it "work correctly with ipv4" do
5
+ i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP-COUNTRY-SAMPLE.bin")
6
+ record = i2l.get_all('13.5.10.6')
7
+ record.should_not be_nil
8
+ record.country_short.should == 'US'
9
+ end
10
+
11
+ it "work correctly with ipv4 with new library" do
12
+ i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/DB24.DEMO4.bin")
13
+ record = i2l.get_all('13.5.10.6')
14
+ record.should_not be_nil
15
+ record.country_short.should == 'KR'
16
+ end
17
+
18
+ it "work correctly with ipv6 with new library" do
19
+ i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/DB24.DEMO6.bin")
20
+ record = i2l.get_all('2a01:04f8:0d16:26c2::')
21
+ record.should_not be_nil
22
+ record.country_short.should == 'DE'
23
+ end
24
+
25
+ # it "profile ipv6 in IPV6.BIN" do
26
+ # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
27
+ # File.new(File.dirname(__FILE__) + "/assets/ipv6_ip.txt").readlines.each do |line|
28
+ # record = i2l.get_all(line.split(' ').first)
29
+ # end
30
+ # end
31
+
32
+ # it "profile ipv4 in IPV6.BIN" do
33
+ # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
34
+ # File.new(File.dirname(__FILE__) + "/assets/ipv4_ip.txt").readlines.each do |line|
35
+ # record = i2l.get_all(line.split(' ').first)
36
+ # end
37
+ # end
38
+
39
+ # it "profile ipv4 in IPV4.BIN" do
40
+ # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN")
41
+ # File.new(File.dirname(__FILE__) + "/assets/ipv4_ip.txt").readlines.each do |line|
42
+ # record = i2l.get_all(line.split(' ').first)
43
+ # end
44
+ # end
45
+
46
+ # this need spec/assets/IP2LOCATION-LITE-DB5.bin file which too big to include in this test.
47
+
48
+ # it "should get float value of attitude" do
49
+ # i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP2LOCATION-LITE-DB5.bin")
50
+ # record = i2l.get_all('192.110.164.88')
51
+ # record['latitude'].should eq(33.44837951660156)
52
+ # end
53
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,13 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'ip2location_ruby'
5
-
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'ip2location_ruby'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
13
13
  require 'awesome_print'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip2location_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent.Z
@@ -108,20 +108,21 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: ip2location ruby library
111
+ description: The official IP2Location Ruby library to geolocate an IP address. You
112
+ can lookup for country, region, city, latitude, longitude, zip code, time zone,
113
+ ISP, domain, area code, usage type, mobile data, weather data and elevation from
114
+ an IP address. Supported both IPv4 and IPv6 lookup.
112
115
  email: support@ip2location.com
113
116
  executables: []
114
117
  extensions: []
115
118
  extra_rdoc_files:
116
119
  - LICENSE.txt
117
- - README.rdoc
118
120
  files:
119
121
  - ".document"
120
122
  - ".rspec"
121
123
  - Gemfile
122
124
  - Gemfile.lock
123
125
  - LICENSE.txt
124
- - README.rdoc
125
126
  - Rakefile
126
127
  - VERSION
127
128
  - ip2location_ruby.gemspec
@@ -140,7 +141,10 @@ files:
140
141
  homepage: https://github.com/ip2location/ip2location-ruby
141
142
  licenses:
142
143
  - MIT
143
- metadata: {}
144
+ metadata:
145
+ bug_tracker_uri: https://github.com/ip2location/ip2location-ruby/issues
146
+ homepage_uri: https://www.ip2location.com
147
+ source_code_uri: https://github.com/ip2location/ip2location-ruby
144
148
  post_install_message:
145
149
  rdoc_options: []
146
150
  require_paths:
@@ -157,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
161
  version: '0'
158
162
  requirements: []
159
163
  rubyforge_project:
160
- rubygems_version: 2.5.1
164
+ rubygems_version: 2.7.7
161
165
  signing_key:
162
166
  specification_version: 4
163
167
  summary: the ip2location ruby library
data/README.rdoc DELETED
@@ -1,35 +0,0 @@
1
- = IP2Location Ruby Library
2
- This is IP2Location Ruby library that enables the user to find the country, region or state, city, latitude and longitude, US ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, and usage type by IP address or hostname originates from. The library reads the geo location information
3
- from **IP2Location BIN data** file.
4
-
5
- Supported IPv4 and IPv6 address.
6
-
7
- For more details, please visit:
8
- [http://www.ip2location.com/developers/ruby](http://www.ip2location.com/developers/ruby)
9
-
10
- == Usage
11
-
12
- i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP-COUNTRY-SAMPLE.bin")
13
- record = i2l.get_all('13.5.10.6')
14
- record.should_not be_nil
15
- record.country_short.should == 'US'
16
-
17
- == Contributing to ip2location
18
-
19
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
20
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
21
- * Fork the project.
22
- * Start a feature/bugfix branch.
23
- * Commit and push until you are happy with your contribution.
24
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
25
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
26
-
27
- == Sample BIN Databases
28
-
29
- * Download free IP2Location LITE databases at [http://lite.ip2location.com](http://lite.ip2location.com)
30
- * Download IP2Location sample databases at [http://www.ip2location.com/developers](http://www.ip2location.com/developers)
31
-
32
- == Support
33
-
34
- Email: support@ip2location.com
35
- URL: [http://www.ip2location.com](http://www.ip2location.com)