mini_phone 1.1.5 → 1.1.8

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: c3a42ec155de4fb7b2a8ea675ac0380274f23b38795c0eb0e73c0efb3ed4d8a5
4
- data.tar.gz: aaec470245e26e61d277a329340833eef93fa22939395273eabba719f977408e
3
+ metadata.gz: ebcb47083ca24a0f63795c4431ae65181ed25e6cca2b1a800603d36bd480fb98
4
+ data.tar.gz: 7bdd9504face792c9ac115132830bcef3a8427365c6fa44a078332175e5fad10
5
5
  SHA512:
6
- metadata.gz: 99128e918a87c4e875191b47177507da77be675aafb7a7bec430457ab420c4b5081872407b31d07de04fc24233e57d14e711a019f49939d3db89e757eeeab1a1
7
- data.tar.gz: a9676a2d17fd3a5e0d178159ed9b413ea73469790e5219040cfa80e5679fce578ac0e80e95b60366cdd23f4961744eba65740464e6bd05bb1549805547862b1f
6
+ metadata.gz: 55b46d7a81ac2e377addb268586a7f4b6b883803dddaa7aa6970bb868d598f91c8cd5933effadbda658a4cfb5b4caeb918f697709df129319b62b1db26139f90
7
+ data.tar.gz: 1361bf8922c55170646d6da8b163da65d13ad6e88cc5ee8621e68ed732d21adf03880d95a6d3db353b397e8ef6ecafcdca44ce5790185fb9ee52a1c8736fd7d6
checksums.yaml.gz.sig ADDED
Binary file
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem 'rake', require: false
9
9
  # https://github.com/rake-compiler/rake-compiler/pull/166
10
10
  gem 'get_process_mem', require: false
11
11
  gem 'pry', require: false
12
- gem 'rake-compiler', github: 'larskanis/rake-compiler', branch: 'fix-native-version'
12
+ gem 'rake-compiler'
13
13
  gem 'rspec', '~> 3.0', require: false
14
14
  gem 'rspec-github', require: false
15
15
  gem 'rubocop', require: false
@@ -17,4 +17,5 @@ gem 'rubocop', require: false
17
17
  group :bench do
18
18
  gem 'benchmark-ips'
19
19
  gem 'phonelib'
20
+ gem 'telephone_number'
20
21
  end
data/README.md CHANGED
@@ -77,16 +77,18 @@ an issue and we will try to support it.
77
77
  On average, most methods are 40x to 50x faster than other libraries. To run
78
78
  the benchmarks locally, execute: `bundle exec rake bench`
79
79
 
80
- ```
81
- # Results from my Linux (5.10.6-arch1-10)
80
+ ### Results from my Linux (5.10.6-arch1-10)
82
81
 
82
+ ```
83
83
  Comparison:
84
- Phonelib: valid?: 426.0 i/s
85
- MiniPhone: valid?: 34707.9 i/s - 81.47x faster
84
+ MiniPhone: valid?: 33382.0 i/s
85
+ Phonelib: valid?: 422.8 i/s - 78.95x (± 0.00) slower
86
+ TelephoneNumber: valid?: 164.3 i/s - 203.13x (± 0.00) slower
86
87
 
87
88
  Comparison:
88
- Phonelib: e164: 580.3 i/s
89
- MiniPhone: e164: 43385.9 i/s - 74.76x faster
89
+ MiniPhone: e164: 41187.5 i/s
90
+ Phonelib: e164: 579.0 i/s - 71.14x (± 0.00) slower
91
+ TelephoneNumber: e164: 228.8 i/s - 179.99x (± 0.00) slower
90
92
  ```
91
93
 
92
94
  ## Installation
data/Rakefile CHANGED
@@ -7,8 +7,6 @@ require 'rake/extensiontask'
7
7
 
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
- task build: :compile
11
-
12
10
  task default: %i[clobber compile spec lint]
13
11
 
14
12
  spec = Gem::Specification.load(File.expand_path('mini_phone.gemspec', __dir__))
@@ -23,7 +21,7 @@ Rake::ExtensionTask.new('mini_phone', spec) do |ext|
23
21
  end
24
22
 
25
23
  task bench: %i[clobber compile] do
26
- Dir['bench/**/*'].each do |f|
24
+ Dir['bench/**/*'].sort.each do |f|
27
25
  require_relative f
28
26
  end
29
27
  end
@@ -41,50 +39,16 @@ task deploy: :default do
41
39
  sh 'code -w ./lib/mini_phone/version.rb'
42
40
  version = `ruby -r ./lib/mini_phone/version.rb -e 'print MiniPhone::VERSION'`.strip
43
41
  sh "git commit -am 'Bump to v#{version} :confetti_ball:'"
44
- sh 'gem_push=no bundle exec rake release'
42
+ sh 'bundle exec rake release'
45
43
  end
46
44
 
47
- namespace :publish do
48
- def push_to_github_registry(gem)
49
- puts "Pushing #{gem} to GitHub Package Registry"
50
- sh "gem push #{gem} --host https://rubygems.pkg.github.com/ianks --key github"
51
- true
52
- rescue StandardError
53
- warn 'Could not publish to Github Package Registry'
54
- false
55
- end
56
-
57
- def push_to_rubygems(gem)
58
- puts "Pushing #{gem} to rubygems"
59
- sh "gem push #{gem}"
60
- true
61
- rescue StandardError
62
- warn 'Could not publish to rubygems'
63
- false
64
- end
65
-
66
- task native: %i[native gem] do
67
- g = "./pkg/mini_phone-#{MiniPhone::VERSION}-#{Gem::Platform.new(RUBY_PLATFORM)}.gem"
68
-
69
- push_to_rubygems(g)
70
- end
71
-
72
- task non_native: [:gem] do
73
- g = "./pkg/mini_phone-#{MiniPhone::VERSION}.gem"
74
-
75
- push_to_rubygems(g)
76
- push_to_github_registry(g)
77
- end
78
- end
79
-
80
- desc 'Run valgrind test'
81
-
82
45
  namespace :debug do
83
46
  desc 'Plot memory'
84
47
  task :memory do
85
48
  sh 'debug/memory_plot/plot.sh'
86
49
  end
87
50
 
51
+ desc 'Run valgrind test'
88
52
  task :valgrind do
89
53
  sh 'docker build --tag mini_phone_dev -f Dockerfile.dev .'
90
54
  args = '--tool=memcheck --num-callers=15 --partial-loads-ok=yes --undef-value-errors=no'
data/certs/ianks.pem ADDED
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtpLmtl
3
+ cnNleW1lcjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD
4
+ Y29tMB4XDTIyMDQxMzE5NTY1MVoXDTIzMDQxMzE5NTY1MVowQjEUMBIGA1UEAwwL
5
+ aS5rZXJzZXltZXIxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixk
6
+ ARkWA2NvbTCCASI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f = RbConfig::MAKEFILE_CONFIG
8
+
9
+ if conf['target_cpu'] == 'arm64' && conf['target_os'].start_with?('darwin')
10
+ $LIBPATH << '/opt/homebrew/lib'
11
+ $INCFLAGS << ' -I/opt/homebrew/include '
12
+ $CXXFLAGS << ' -I/opt/homebrew/include '
13
+ end
14
+
7
15
  unless have_library('phonenumber')
8
16
  abort <<~MSG
9
17
 
@@ -31,7 +39,7 @@ end
31
39
 
32
40
  dir_config('mini_phone')
33
41
 
34
- $CXXFLAGS += ' -std=c++11 -ofast '
42
+ $CXXFLAGS += ' -std=c++14 -ofast '
35
43
 
36
44
  create_makefile('mini_phone/mini_phone')
37
45
 
@@ -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) {
@@ -433,13 +438,14 @@ extern "C" VALUE rb_phone_number_to_s(VALUE self) {
433
438
  PhoneNumberInfo *phone_number_info;
434
439
  TypedData_Get_Struct(self, PhoneNumberInfo, &phone_number_info_type, phone_number_info);
435
440
  PhoneNumber *phone_number = phone_number_info->phone_number;
436
- std::string raw_input = phone_number->raw_input();
437
441
 
438
- if (raw_input == "") {
442
+ if (phone_number == NULL) {
439
443
  return Qnil;
440
- } else {
441
- return rb_str_new(raw_input.c_str(), raw_input.size());
442
444
  }
445
+
446
+ std::string raw_input = phone_number->raw_input();
447
+
448
+ return rb_str_new(raw_input.c_str(), raw_input.size());
443
449
  }
444
450
 
445
451
  static inline void setup_formats() {
@@ -470,9 +476,14 @@ extern "C" VALUE rb_phone_number_valid_eh(VALUE self) {
470
476
 
471
477
  const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
472
478
 
473
- if (!rb_str_equal(input_region_code, rb_str_new_literal("ZZ")) &&
474
- !rb_str_equal(rb_phone_number_region_code(self), input_region_code)) {
475
- 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
+ }
476
487
  }
477
488
 
478
489
  if (phone_util.IsValidNumber(*phone_number_info->phone_number)) {
@@ -517,10 +528,10 @@ extern "C" VALUE rb_phone_number_initialize(int argc, VALUE *argv, VALUE self) {
517
528
 
518
529
  if (result != PhoneNumberUtil::NO_PARSING_ERROR) {
519
530
  rb_phone_number_nullify_ivars(self);
520
- } else {
521
- phone_number_info->phone_number->Swap(&parsed_number);
522
531
  }
523
532
 
533
+ phone_number_info->phone_number->Swap(&parsed_number);
534
+
524
535
  return self;
525
536
  }
526
537
 
@@ -577,6 +588,5 @@ extern "C" void Init_mini_phone(void) {
577
588
  rb_define_method(rb_cPhoneNumber, "type", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_type), 0);
578
589
  rb_define_method(rb_cPhoneNumber, "area_code", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_area_code), 0);
579
590
  rb_define_method(rb_cPhoneNumber, "to_s", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_to_s), 0);
580
- rb_define_method(rb_cPhoneNumber, "raw_input", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_to_s), 0);
581
591
  rb_define_method(rb_cPhoneNumber, "==", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_match_eh), 1);
582
592
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniPhone
4
- VERSION = '1.1.5'
4
+ VERSION = '1.1.8'
5
5
  end
data/mini_phone.gemspec CHANGED
@@ -36,4 +36,9 @@ Gem::Specification.new do |spec|
36
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
37
  spec.require_paths = ['lib']
38
38
  spec.extensions = ['ext/mini_phone/extconf.rb']
39
+
40
+ # Security
41
+ spec.metadata['rubygems_mfa_required'] = 'true'
42
+ spec.cert_chain = ['certs/ianks.pem']
43
+ spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME.end_with?('gem')
39
44
  end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_phone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
- cert_chain: []
11
- date: 2021-02-11 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTI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cdfcv0RHBlmBHwBOoQ+hXMlInjssjfIX4BS39mTYefclE
29
+ zxOFntl+vb4kluo0j9/BGzdnGCo7iE+GfGSENFdOn2J38RCDLUzgOCmCtxzSvldq
30
+ Rl+ASkq2/1i07TkBpCf+2hq66+h/hx+/Y/KrUzXfe0jtvil0WESkJT2kqRqHWNhD
31
+ 9GKBxaQlXokNDtWCm1/gl6cD8WRZ0N5S4ZGJT1FLLsA=
32
+ -----END CERTIFICATE-----
33
+ date: 2022-07-16 00:00:00.000000000 Z
12
34
  dependencies: []
13
35
  description: Plugs directly in the the Google's native C++ [libphonenumber](https://github.com/google/libphonenumber)
14
36
  for extemely _fast_ and _robust_ phone number parsing, validation, and formatting.
@@ -27,6 +49,7 @@ files:
27
49
  - LICENSE.txt
28
50
  - README.md
29
51
  - Rakefile
52
+ - certs/ianks.pem
30
53
  - debug/memory_plot/memory.rb
31
54
  - debug/memory_plot/plot.sh
32
55
  - ext/mini_phone/extconf.rb
@@ -43,7 +66,8 @@ metadata:
43
66
  homepage_uri: https://github.com/ianks/mini_phone
44
67
  source_code_uri: https://github.com/ianks/mini_phone
45
68
  changelog_uri: https://github.com/ianks/mini_phone/blob/master/CHANGELOG.md
46
- post_install_message:
69
+ rubygems_mfa_required: 'true'
70
+ post_install_message:
47
71
  rdoc_options: []
48
72
  require_paths:
49
73
  - lib
@@ -58,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
82
  - !ruby/object:Gem::Version
59
83
  version: '0'
60
84
  requirements: []
61
- rubygems_version: 3.1.4
62
- signing_key:
85
+ rubygems_version: 3.3.7
86
+ signing_key:
63
87
  specification_version: 4
64
88
  summary: Uses the Google libphonenumber C lib to parse, validate, and format phone
65
89
  numbers
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ 9��I��,.��j���l˽`&҂p���>�x�w��!�:
2
+ b�"(,Ӕw ��af��h�3 �B�?�wG����u�m_G�Ee�*T�������T���7�.��}@\~�3�"��x�5n��)�� ��
3
+ ǭ铹�������i2�<���qiuΦ��L�a�E��@��U�@\qz����֗_i���~yW��mXǘG��z˧�bGv����P+�+ԲRMZ] �ן0�|ȗ�����螉