ip2location_ruby 8.2.0 → 8.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d40ddb96c3b68fc1ff4d851a0389f715e09c41c3b185d8936558686fa39ce2a4
4
- data.tar.gz: 1b0d493cddb9e69b692be6f3a84b4e178d1ad16a1c63641732638b6134cf51e1
3
+ metadata.gz: 87b2d8b319cb9e62e4d99875d0f01dc5043d9f3bbc7556488efcb9b7091d656e
4
+ data.tar.gz: b3166341ec4b79588c683611ca24b5019052258f2fab60a8d74029de52d6f5c0
5
5
  SHA512:
6
- metadata.gz: c21ffd658ec663cc61c726a77a907e56bb69114ac1a016ccea7568ccf0b6faa180a4efade585009dbed2c526880fddef1dce724f1e724f0592ec1b52174ae287
7
- data.tar.gz: 6337c61e5594a6e48bc2b2541afe9d0f944eeeabd6200091ac6f3b0459d60e31f216ac4ca5aaa51e5bc3c890eb17b1fd28fbdadce4d7b46c6308faa117a621de
6
+ metadata.gz: 888a244c319e9fb212cd0c1343261035e37c03e24bfe27e71940cf6673b8525661ac7e577159585f3abe78a2a566d10499826232cd6e960634b8dce8d64bc4ab
7
+ data.tar.gz: ef010901688b3d4da4fc161ad0a162f109bf0323f382542b2d7ab4afc4e522185b08d6fd1da93d51fef5f37631c9a74c2e9a56b0156b7651d489f8599eeea144
data/README.md CHANGED
@@ -19,7 +19,6 @@ Below is the description of the functions available in the **BIN Database** look
19
19
  |---|---|
20
20
  | open | Open the IP2Location BIN data for lookup. |
21
21
  | close | Close and clean up the file pointer. |
22
- | close | Close and clean up the file pointer. |
23
22
  | get_all | Return the geolocation information in array. |
24
23
  | get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
25
24
  | get_country_long | Return the ISO3166-1 country name of the IP address. |
@@ -48,7 +47,7 @@ Below is the description of the functions available in the **Web Service** looku
48
47
 
49
48
  | Function Name | Description |
50
49
  |---|---|
51
- | Constructor | Expect 2 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS24)</li></ol> |
50
+ | Constructor | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS24)</li></li><li>Use HTTPS or HTTP</li></ol> |
52
51
  | lookup | Return the IP information in array.<ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
53
52
  | get_credit | Return remaining credit of the web service account. |
54
53
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.2.0
1
+ 8.2.1
data/example.rb CHANGED
@@ -34,7 +34,7 @@ print 'Usage Type: ' + record['usagetype'] + "\n"
34
34
  i2l.close()
35
35
 
36
36
  # Web Service
37
- ws = Ip2locationWebService.new('demo', 'WS24')
37
+ ws = Ip2locationWebService.new('demo', 'WS24', true)
38
38
  record = ws.lookup('8.8.8.8', 'continent,country,region,city,geotargeting,country_groupings,time_zone_info', 'en')
39
39
  print record
40
40
  print "\n"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ip2location_ruby"
8
- s.version = "8.2.0"
8
+ s.version = "8.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.require_paths = ["lib"]
@@ -540,21 +540,29 @@ class Ip2location
540
540
  end
541
541
 
542
542
  class Ip2locationWebService
543
- attr_accessor :ws_api_key, :ws_package
543
+ attr_accessor :ws_api_key, :ws_package, :ws_use_ssl
544
544
 
545
- def initialize(api_key, package)
545
+ def initialize(api_key, package, use_ssl)
546
546
  if !api_key.match(/^[0-9A-Z]{10}$/) && api_key != 'demo'
547
547
  raise Exception.new "Please provide a valid IP2Location web service API key."
548
548
  end
549
549
  if !package.match(/^WS[0-9]+$/)
550
550
  package = 'WS1'
551
551
  end
552
+ if use_ssl == ''
553
+ use_ssl = true
554
+ end
552
555
  self.ws_api_key = api_key
553
556
  self.ws_package = package
557
+ self.ws_use_ssl = use_ssl
554
558
  end
555
559
 
556
560
  def lookup(ip, add_ons, language)
557
- response = Net::HTTP.get(URI("https://api.ip2location.com/v2/?key=" + self.ws_api_key + "&ip=" + ip + "&package=" + self.ws_package + "&format=json&addon=" + add_ons + "&lang=" + language))
561
+ if self.ws_use_ssl
562
+ response = Net::HTTP.get(URI("https://api.ip2location.com/v2/?key=" + self.ws_api_key + "&ip=" + ip + "&package=" + self.ws_package + "&format=json&addon=" + add_ons + "&lang=" + language))
563
+ else
564
+ response = Net::HTTP.get(URI("http://api.ip2location.com/v2/?key=" + self.ws_api_key + "&ip=" + ip + "&package=" + self.ws_package + "&format=json&addon=" + add_ons + "&lang=" + language))
565
+ end
558
566
  parsed_response = JSON.parse(response)
559
567
  if parsed_response.nil?
560
568
  return false
@@ -566,7 +574,11 @@ class Ip2locationWebService
566
574
  end
567
575
 
568
576
  def get_credit()
569
- response = Net::HTTP.get(URI("https://api.ip2location.com/v2/?key=" + self.ws_api_key + "&check=true"))
577
+ if self.ws_use_ssl
578
+ response = Net::HTTP.get(URI("https://api.ip2location.com/v2/?key=" + self.ws_api_key + "&check=true"))
579
+ else
580
+ response = Net::HTTP.get(URI("http://api.ip2location.com/v2/?key=" + self.ws_api_key + "&check=true"))
581
+ end
570
582
  parsed_response = JSON.parse(response)
571
583
  if parsed_response.nil?
572
584
  return 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip2location_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 8.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ip2location
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-30 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata