phonelib 0.8.5 → 0.8.7

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: c3f8e7fe24a6bafb1bbb3f6d1b816b119ac44843910766135e07ceca70113dba
4
- data.tar.gz: d9b3ae4e1d6c4831851e1772bdea89bc7cd546f0968e6fcb44e194fa73009a16
3
+ metadata.gz: ead15db333d3f8490017aef9004751e4944ba84689238cb2c2579cde56c3b751
4
+ data.tar.gz: ac6ff256e13409683825f984fb400e1eb85d6dfbfaec90dc10f163414d69eb8a
5
5
  SHA512:
6
- metadata.gz: e67a1c2d70a2d7f415677f8e5dc606cb295152fc0dc1429ea2526086d7465c4dbf7e37ebdae10f27e2683aea5ee1846099353b089f720b247857870f467c2ffa
7
- data.tar.gz: 67292dc389d84851d3ee89661a9f93e6d90514af538efebab4b9cae5c1789a9c44e0b797eec45102f4b6f8ecf5a1acfe4ee549cc0422c5d9758cebd3f30ee7a7
6
+ metadata.gz: 3e49e7edbe4835d24c76f393aa2a21f9bfd0cf2876536f4106e39def0bd3806b2099fc45a9a2fa8b71a8ecf6a47404c2938a26881fcd153548be396bac9977c5
7
+ data.tar.gz: 237714d47010cbb5258944d0cdadfb55f7df6d8facbf6fe0c13651b0f759ea8fd6cb3737d9e52a5c1244b0270616150214e580675148a73fa7c44494c42c1eed
Binary file
data/data/phone_data.dat CHANGED
Binary file
data/lib/phonelib/core.rb CHANGED
@@ -4,6 +4,19 @@ module Phonelib
4
4
  # @private variable will include hash with data for validation
5
5
  @@phone_data = nil
6
6
 
7
+ # eagerly initialize the gem, loads data into memory. not required, initialization is done lazily otherwise, but
8
+ # may be desirable in production enviroments to avoid initialization time on first use.
9
+ def eager_load!
10
+ return if @@skip_eager_loading
11
+ phone_data
12
+ phone_ext_data
13
+ end
14
+
15
+ @@skip_eager_loading = false
16
+ def skip_eager_loading!
17
+ @@skip_eager_loading = true
18
+ end
19
+
7
20
  # getter for phone data for other modules of gem, can be used outside
8
21
  # @return [Hash] all data for phone parsing
9
22
  def phone_data
@@ -197,7 +197,7 @@ module Phonelib
197
197
 
198
198
  require 'open-uri'
199
199
  require 'csv'
200
- io = open('http://api.geonames.org/countryInfoCSV?username=demo&style=full')
200
+ io = URI.open('http://download.geonames.org/export/dump/countryInfo.txt')
201
201
  csv = CSV.new(io, {col_sep: "\t"})
202
202
  csv.each do |row|
203
203
  next if row[0].nil? || row[0].start_with?('#') || row[0].empty? || row[0].size != 2
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.8.5'
3
+ VERSION = '0.8.7'
4
4
  end
data/lib/phonelib.rb CHANGED
@@ -17,4 +17,12 @@ if defined?(ActiveModel) || defined?(Rails)
17
17
  else
18
18
  autoload :PhoneValidator, 'validators/phone_validator'
19
19
  end
20
+
21
+ if defined?(Rails)
22
+ class Phonelib::Railtie < Rails::Railtie
23
+ initializer 'phonelib' do |app|
24
+ app.config.eager_load_namespaces << Phonelib
25
+ end
26
+ end
27
+ end
20
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonelib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Senderovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-05 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake