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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48fbcbb306ad72fdcbd33b68c46e1c3bc586d24a7ba931f8c4a059e22f65b3a7
4
- data.tar.gz: cbdc2cadfa4c1438312de09177b2c54d476f68e5fc585248eeb046212d71025a
3
+ metadata.gz: 4f3cfea7458b4c50503fd9b9786c3622c7018128ab2785cee254ed45b8da6008
4
+ data.tar.gz: 574028442c0b7bc1ce52ca558f2397b7a298fafaebc635b082bc211620235805
5
5
  SHA512:
6
- metadata.gz: 0cb7432992d4c61aaa8ccb0774e48aad98a61a575555dc6e4d509560938fd4fb4267bd62d90cdd2f589d93ed1eb5ded12503fe213023f10972ed399ded5f863c
7
- data.tar.gz: 4dd9e4ae33cde41d27e308fc1d5249cc7676274162ecc20d79e1088f029b6aab330bfe1dc424fb74515fbb42ab744c375fd60ef6078ad6c9ba6e315ca07a71f8
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
- PhoneNumberInfo *phone_number_info;
313
- std::string code;
314
- TypedData_Get_Struct(self, PhoneNumberInfo, &phone_number_info_type, phone_number_info);
315
- const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
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
- phone_util.GetRegionCodeForCountryCode(phone_number_info->phone_number->country_code(), &code);
319
+ phone_util.GetRegionCodeForCountryCode(phone_number_info->phone_number->country_code(), &code);
318
320
 
319
- VALUE result = rb_str_new(code.c_str(), code.size());
321
+ VALUE result = rb_str_new(code.c_str(), code.size());
320
322
 
321
- return rb_iv_set(self, "@region_code", result);
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
- !rb_str_equal(rb_phone_number_region_code(self), input_region_code)) {
476
- return rb_iv_set(self, "@valid", Qfalse);
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)) {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniPhone
4
- VERSION = '1.1.6'
4
+ VERSION = '1.1.7'
5
5
  end
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.6
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-02-18 00:00:00.000000000 Z
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