phonelib 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/extended_data.dat +0 -0
- data/data/libphonenumber/CONTRIBUTING.md +3 -2
- data/data/libphonenumber/FAQ.md +8 -0
- data/data/libphonenumber/README.md +1 -1
- data/data/libphonenumber/cpp/src/phonenumbers/lite_metadata.cc +10065 -9904
- data/data/libphonenumber/cpp/src/phonenumbers/metadata.cc +11648 -11485
- data/data/libphonenumber/cpp/src/phonenumbers/regexp_adapter_re2.cc +8 -14
- data/data/libphonenumber/cpp/src/phonenumbers/short_metadata.cc +2316 -2308
- data/data/libphonenumber/cpp/test/phonenumbers/shortnumberinfo_test.cc +1 -1
- data/data/libphonenumber/java/carrier/pom.xml +4 -4
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/1671_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/223_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/251_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/61_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/677_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/855_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/91_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/971_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/972_en +0 -0
- data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/992_en +0 -0
- data/data/libphonenumber/java/demo/pom.xml +5 -5
- data/data/libphonenumber/java/geocoder/pom.xml +4 -4
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1548_en +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1743_en +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/223_en +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/27_en +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/501_en +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/55_en +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/55_pt +0 -0
- data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/config +0 -0
- data/data/libphonenumber/java/internal/prefixmapper/pom.xml +3 -3
- data/data/libphonenumber/java/libphonenumber/pom.xml +12 -2
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AE +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AU +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BR +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DE +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DJ +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FR +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GU +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IL +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KR +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ML +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NO +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SB +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TJ +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_BR +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_CA +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_ML +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_US +0 -0
- data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/SingleFilePhoneNumberMetadataProto +0 -0
- data/data/libphonenumber/java/libphonenumber/test/com/google/i18n/phonenumbers/ShortNumberInfoTest.java +1 -1
- data/data/libphonenumber/java/pom.xml +1 -1
- data/data/libphonenumber/java/release_notes.txt +40 -0
- data/data/libphonenumber/javascript/i18n/phonenumbers/demo-compiled.js +85 -82
- data/data/libphonenumber/javascript/i18n/phonenumbers/metadata.js +75 -46
- data/data/libphonenumber/javascript/i18n/phonenumbers/metadatalite.js +75 -46
- data/data/libphonenumber/resources/PhoneNumberMetadata.xml +367 -142
- data/data/libphonenumber/resources/ShortNumberMetadata.xml +108 -461
- data/data/libphonenumber/resources/carrier/en/1.txt +1 -0
- data/data/libphonenumber/resources/carrier/en/223.txt +16 -0
- data/data/libphonenumber/resources/carrier/en/251.txt +1 -1
- data/data/libphonenumber/resources/carrier/en/61.txt +1 -0
- data/data/libphonenumber/resources/carrier/en/677.txt +1 -0
- data/data/libphonenumber/resources/carrier/en/855.txt +1 -0
- data/data/libphonenumber/resources/carrier/en/91.txt +148 -9
- data/data/libphonenumber/resources/carrier/en/971.txt +1 -0
- data/data/libphonenumber/resources/carrier/en/972.txt +2 -0
- data/data/libphonenumber/resources/carrier/en/992.txt +3 -0
- data/data/libphonenumber/resources/geocoding/en/1.txt +2 -0
- data/data/libphonenumber/resources/geocoding/en/223.txt +37 -0
- data/data/libphonenumber/resources/geocoding/en/27.txt +1 -1
- data/data/libphonenumber/resources/geocoding/en/501.txt +23 -0
- data/data/libphonenumber/resources/geocoding/en/55.txt +15239 -52
- data/data/libphonenumber/resources/geocoding/pt/55.txt +15236 -53
- data/data/libphonenumber/tools/cpp/src/cpp-build/generate_geocoding_data.cc +3 -2
- data/data/phone_data.dat +0 -0
- data/lib/phonelib/phone.rb +9 -4
- data/lib/phonelib/phone_analyzer_helper.rb +16 -0
- data/lib/phonelib/version.rb +1 -1
- metadata +9 -2
@@ -20,6 +20,7 @@
|
|
20
20
|
#include <locale>
|
21
21
|
#include <sys/stat.h>
|
22
22
|
#include <algorithm>
|
23
|
+
#include <cctype>
|
23
24
|
#include <cmath>
|
24
25
|
#include <cstdio>
|
25
26
|
#include <cstring>
|
@@ -141,7 +142,7 @@ bool StrToInt(const string& s, int32* n) {
|
|
141
142
|
std::stringstream stream;
|
142
143
|
stream << s;
|
143
144
|
stream >> *n;
|
144
|
-
return stream;
|
145
|
+
return !stream.fail();
|
145
146
|
}
|
146
147
|
|
147
148
|
// Converts integer to string, returns true on success.
|
@@ -149,7 +150,7 @@ bool IntToStr(int32 n, string* s) {
|
|
149
150
|
std::stringstream stream;
|
150
151
|
stream << n;
|
151
152
|
stream >> *s;
|
152
|
-
return stream;
|
153
|
+
return !stream.fail();
|
153
154
|
}
|
154
155
|
|
155
156
|
// Parses the prefix descriptions file at path, clears and fills the output
|
data/data/phone_data.dat
CHANGED
Binary file
|
data/lib/phonelib/phone.rb
CHANGED
@@ -26,7 +26,7 @@ module Phonelib
|
|
26
26
|
if sanitized.empty?
|
27
27
|
@data = {}
|
28
28
|
else
|
29
|
-
@data = analyze(sanitized,
|
29
|
+
@data = analyze(sanitized, passed_country(country))
|
30
30
|
first = @data.values.first
|
31
31
|
@national_number = first ? first[:national] : sanitized
|
32
32
|
end
|
@@ -154,7 +154,7 @@ module Phonelib
|
|
154
154
|
# Returns e164 formatted phone number
|
155
155
|
def international(formatted = true)
|
156
156
|
return nil if sanitized.nil? || sanitized.empty?
|
157
|
-
return "+#{sanitized}" unless valid?
|
157
|
+
return "+#{sanitized.start_with?(country_code) ? '' : country_code}#{sanitized}" unless valid?
|
158
158
|
return "#{@data[country][Core::COUNTRY_CODE]}#{@national_number}" unless formatted
|
159
159
|
|
160
160
|
format = @data[country][:format]
|
@@ -165,7 +165,12 @@ module Phonelib
|
|
165
165
|
national = @national_number
|
166
166
|
end
|
167
167
|
|
168
|
-
"+#{
|
168
|
+
"+#{country_code} #{national}"
|
169
|
+
end
|
170
|
+
|
171
|
+
# returns national formatted number with extension added
|
172
|
+
def full_national
|
173
|
+
"#{national}#{formatted_extension}"
|
169
174
|
end
|
170
175
|
|
171
176
|
# returns international formatted number with extension added
|
@@ -215,7 +220,7 @@ module Phonelib
|
|
215
220
|
|
216
221
|
# returns extension with separator defined
|
217
222
|
def formatted_extension
|
218
|
-
return ''
|
223
|
+
return '' if @extension.nil? || @extension.empty?
|
219
224
|
|
220
225
|
"#{Phonelib.extension_separator}#{@extension}"
|
221
226
|
end
|
@@ -3,6 +3,22 @@ module Phonelib
|
|
3
3
|
module PhoneAnalyzerHelper
|
4
4
|
private
|
5
5
|
|
6
|
+
# defines if to validate against single country or not
|
7
|
+
def passed_country(country)
|
8
|
+
country_code = country_prefix(country)
|
9
|
+
if @original.start_with?('+') && country_code && !sanitized.start_with?(country_code)
|
10
|
+
# in case number passed with + but it doesn't start with passed country prefix
|
11
|
+
country = nil
|
12
|
+
end
|
13
|
+
country
|
14
|
+
end
|
15
|
+
|
16
|
+
# returns country prefix for provided country or nil
|
17
|
+
def country_prefix(country)
|
18
|
+
country = country.to_s.upcase
|
19
|
+
Phonelib.phone_data[country] && Phonelib.phone_data[country][Core::COUNTRY_CODE]
|
20
|
+
end
|
21
|
+
|
6
22
|
# caches regular expression, reusing it for later lookups
|
7
23
|
def cr(regexp)
|
8
24
|
Phonelib.phone_regexp_cache[regexp] ||= Regexp.new(regexp)
|
data/lib/phonelib/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Senderovich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04
|
11
|
+
date: 2016-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -586,6 +586,7 @@ files:
|
|
586
586
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1530_en
|
587
587
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1540_en
|
588
588
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1541_en
|
589
|
+
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1548_en
|
589
590
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1551_en
|
590
591
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1559_en
|
591
592
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1561_en
|
@@ -669,6 +670,7 @@ files:
|
|
669
670
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1734_en
|
670
671
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1737_en
|
671
672
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1740_en
|
673
|
+
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1743_en
|
672
674
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1754_en
|
673
675
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1757_en
|
674
676
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1760_en
|
@@ -786,6 +788,7 @@ files:
|
|
786
788
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/221_en
|
787
789
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/222_en
|
788
790
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/222_fr
|
791
|
+
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/223_en
|
789
792
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/224_en
|
790
793
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/225_en
|
791
794
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/226_en
|
@@ -895,11 +898,13 @@ files:
|
|
895
898
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/48_pl
|
896
899
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/49_de
|
897
900
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/49_en
|
901
|
+
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/501_en
|
898
902
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/51_en
|
899
903
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/53_en
|
900
904
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/54_en
|
901
905
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/54_es
|
902
906
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/55_en
|
907
|
+
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/55_pt
|
903
908
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/56_en
|
904
909
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/56_es
|
905
910
|
- data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/57_en
|
@@ -1817,6 +1822,7 @@ files:
|
|
1817
1822
|
- data/libphonenumber/resources/geocoding/en/220.txt
|
1818
1823
|
- data/libphonenumber/resources/geocoding/en/221.txt
|
1819
1824
|
- data/libphonenumber/resources/geocoding/en/222.txt
|
1825
|
+
- data/libphonenumber/resources/geocoding/en/223.txt
|
1820
1826
|
- data/libphonenumber/resources/geocoding/en/224.txt
|
1821
1827
|
- data/libphonenumber/resources/geocoding/en/225.txt
|
1822
1828
|
- data/libphonenumber/resources/geocoding/en/226.txt
|
@@ -1885,6 +1891,7 @@ files:
|
|
1885
1891
|
- data/libphonenumber/resources/geocoding/en/47.txt
|
1886
1892
|
- data/libphonenumber/resources/geocoding/en/48.txt
|
1887
1893
|
- data/libphonenumber/resources/geocoding/en/49.txt
|
1894
|
+
- data/libphonenumber/resources/geocoding/en/501.txt
|
1888
1895
|
- data/libphonenumber/resources/geocoding/en/51.txt
|
1889
1896
|
- data/libphonenumber/resources/geocoding/en/53.txt
|
1890
1897
|
- data/libphonenumber/resources/geocoding/en/54.txt
|