ip_lookup 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaa5df884d47523f33521ec34772a86cd97bfc85a763c753e6515f9504814747
4
- data.tar.gz: fd4380b93580ce2584422e8de11dec66846bc482e226c331905e5ad54a9d63a7
3
+ metadata.gz: da2edd11ee6ec57de8ceb5b4309c2f44b9d87c74e0a6641d3c655cf37e1b8476
4
+ data.tar.gz: fd1d398f16e05338bee0d187b5cd581cf59f656a0b5908619df149fbbf49958b
5
5
  SHA512:
6
- metadata.gz: 465b2b6aa0b688e784e9a7121d37267d4185447bf71b9264ff859ae5f10a29947ac6403644f007ea71f98fb9695f55e98e1c6d90fe3a5b4c949b67d0fdaa6e7f
7
- data.tar.gz: 7c39c309ceb2ef5505cd47deff2895b67c20ff5261b7051166d52b5e9b494f267b2a0fe8f429dc0aa6dd982a0afbd8fe15c8e04c33f3822b63139884348085dd
6
+ metadata.gz: 6b7b082909b9d9627e003f2038bcb5a587a205b895ecd9b0555833c29d2f6647ca4ff00667acc25da99d6e4628f86ba7dfcf00aa7ab7e43a6abbec56cb85a6ac
7
+ data.tar.gz: 4596ce4113b386871de1910891b3553ce4b98daf41457f9d98a8fc007b5dbbaa7a0610e819debfde8bc16f6bc258d00a8b3c38f98ec5fb4764f752772b2cf87b
@@ -29,7 +29,7 @@ class IPLookup
29
29
  def db
30
30
  self.class.mutex.synchronize do
31
31
  @db ||= begin
32
- MaxMindDB.new self.class.db_path
32
+ MaxMindDB.new self.class.full_db_path
33
33
  end
34
34
  end
35
35
  end
@@ -52,7 +52,9 @@ class IPLookup
52
52
  end
53
53
 
54
54
  def save_db(result)
55
- File.open(db_path, 'w') do |file|
55
+ Dir.mkdir(db_path) unless File.exist?(db_path)
56
+
57
+ File.open(full_db_path, 'w') do |file|
56
58
  flock(file) do |f|
57
59
  f.write(result)
58
60
  end
@@ -77,18 +79,26 @@ class IPLookup
77
79
  end
78
80
 
79
81
  def db_exists?
80
- File.file? db_path
82
+ File.file? full_db_path
81
83
  end
82
84
 
83
85
  def db_age
84
- (Time.now - File.mtime(db_path)) / (24 * 60 * 60)
86
+ (Time.now - File.mtime(full_db_path)) / (24 * 60 * 60)
87
+ end
88
+
89
+ def full_db_path
90
+ File.join(db_path, db_filename)
91
+ end
92
+
93
+ def db_filename
94
+ "/geolite-city.mmdb"
85
95
  end
86
96
 
87
97
  def db_path
88
98
  if Gem.loaded_specs["ip_lookup"]
89
- File.join(Gem.loaded_specs["ip_lookup"].full_gem_path, "/support/geolite-city.mmdb")
99
+ File.join(Gem.loaded_specs["ip_lookup"].full_gem_path, "/support")
90
100
  else
91
- File.join(File.expand_path("../..", File.dirname(__FILE__)), "/support/geolite-city.mmdb")
101
+ File.join(File.expand_path("../..", File.dirname(__FILE__)), "/support")
92
102
  end
93
103
  end
94
104
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class IPLookup
4
- VERSION = "1.0.5"
4
+ VERSION = "1.0.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip_lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ole Richter