mini_phone 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/mini_phone/mini_phone.cc +20 -10
- data/lib/mini_phone/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3cfea7458b4c50503fd9b9786c3622c7018128ab2785cee254ed45b8da6008
|
4
|
+
data.tar.gz: 574028442c0b7bc1ce52ca558f2397b7a298fafaebc635b082bc211620235805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed571b1fd20e7fd99effc2a70b0f692e91962c0145bd47440b54ef374b60ef7705cf29952c2380ed491fa5fa8cb6df98a3460c3479014cbc4c510445b7b9f6fa
|
7
|
+
data.tar.gz: f56388c5750d5fc1446bdcae0dcfaf5b47edba6ffff33360c0dab2144088380bd9316fbc6ad7623005ec38ec9105dd94000ad7fd13f5540b0b4cb4d09d8159b3
|
@@ -308,17 +308,22 @@ extern "C" VALUE rb_phone_number_region_code(VALUE self) {
|
|
308
308
|
if (rb_ivar_defined(self, rb_intern("@region_code"))) {
|
309
309
|
return rb_iv_get(self, "@region_code");
|
310
310
|
}
|
311
|
+
VALUE input_region_code = rb_iv_get(self, "@input_region_code");
|
311
312
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
313
|
+
if (NIL_P(input_region_code)) {
|
314
|
+
PhoneNumberInfo *phone_number_info;
|
315
|
+
std::string code;
|
316
|
+
TypedData_Get_Struct(self, PhoneNumberInfo, &phone_number_info_type, phone_number_info);
|
317
|
+
const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
|
316
318
|
|
317
|
-
|
319
|
+
phone_util.GetRegionCodeForCountryCode(phone_number_info->phone_number->country_code(), &code);
|
318
320
|
|
319
|
-
|
321
|
+
VALUE result = rb_str_new(code.c_str(), code.size());
|
320
322
|
|
321
|
-
|
323
|
+
return rb_iv_set(self, "@region_code", result);
|
324
|
+
} else {
|
325
|
+
return rb_iv_set(self, "@region_code", input_region_code);
|
326
|
+
}
|
322
327
|
}
|
323
328
|
|
324
329
|
extern "C" VALUE rb_phone_number_match_eh(VALUE self, VALUE other) {
|
@@ -471,9 +476,14 @@ extern "C" VALUE rb_phone_number_valid_eh(VALUE self) {
|
|
471
476
|
|
472
477
|
const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
|
473
478
|
|
474
|
-
if (!rb_str_equal(input_region_code, rb_str_new_literal("ZZ"))
|
475
|
-
|
476
|
-
|
479
|
+
if (!rb_str_equal(input_region_code, rb_str_new_literal("ZZ"))) {
|
480
|
+
std::string country_code(RSTRING_PTR(input_region_code), RSTRING_LEN(input_region_code));
|
481
|
+
|
482
|
+
if (phone_util.IsValidNumberForRegion(*phone_number_info->phone_number, country_code)) {
|
483
|
+
return rb_iv_set(self, "@valid", Qtrue);
|
484
|
+
} else {
|
485
|
+
return rb_iv_set(self, "@valid", Qfalse);
|
486
|
+
}
|
477
487
|
}
|
478
488
|
|
479
489
|
if (phone_util.IsValidNumber(*phone_number_info->phone_number)) {
|
data/lib/mini_phone/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_phone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ker-Seymer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Plugs directly in the the Google's native C++ [libphonenumber](https://github.com/google/libphonenumber)
|
14
14
|
for extemely _fast_ and _robust_ phone number parsing, validation, and formatting.
|
@@ -43,7 +43,7 @@ metadata:
|
|
43
43
|
homepage_uri: https://github.com/ianks/mini_phone
|
44
44
|
source_code_uri: https://github.com/ianks/mini_phone
|
45
45
|
changelog_uri: https://github.com/ianks/mini_phone/blob/master/CHANGELOG.md
|
46
|
-
post_install_message:
|
46
|
+
post_install_message:
|
47
47
|
rdoc_options: []
|
48
48
|
require_paths:
|
49
49
|
- lib
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubygems_version: 3.1.4
|
62
|
-
signing_key:
|
62
|
+
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Uses the Google libphonenumber C lib to parse, validate, and format phone
|
65
65
|
numbers
|