mini_phone 1.0.0.beta.0 → 1.0.4

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: 98edc8a1bf120a002c013d80d48ea0bd55c2f1d2bcb2912c02721ee58140a8f7
4
- data.tar.gz: 52849767577cb45129bae6fb875f343316291da9600de16dbe406cc8c7705242
3
+ metadata.gz: ec6635c4a695331ec847d69f21e79578f5f9ebdddf2752a7f1074fabd33ccfac
4
+ data.tar.gz: 51aae23c0a2330a9599ee0336ad591e8fa4548c041b0a6aa1710f5834791b5f7
5
5
  SHA512:
6
- metadata.gz: a6ee4d57ff10389a45d0072b464098cee65fde3d7792127002e9a82879bd08077dec3182dcc243213510f4dd303c643202135f586c528463516f042dfae7c6cf
7
- data.tar.gz: 564fb760f1a5cdcb9b81835511dc3a382632fa93b8235abb6384a3aa85ce727eaaa9cff031bf377669a102208776179e1b08000dc72a6cfe7d83caa75bde96a7
6
+ metadata.gz: 19540acad836a3102e52aab746c530c8f78613e4d3ac98ba3844c24e156d1a994aa92c5dcfaa3fd831ffe7d0a8ba26aa036a8e23f982545a81a08fac2e0cab6c
7
+ data.tar.gz: 747484c1f84802be42523c762f213eaa5044257d78546ac8a30c554c101053d6764e264c892fe29df74f265b44afa7829172a697f23996d1443835203266705b
data/Gemfile CHANGED
@@ -5,11 +5,12 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in mini_phone.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 12.0'
8
+ gem 'rake', require: false
9
+ # https://github.com/rake-compiler/rake-compiler/pull/166
9
10
  gem 'rake-compiler', github: 'larskanis/rake-compiler', branch: 'fix-native-version'
10
- gem 'rspec', '~> 3.0'
11
+ gem 'rspec', '~> 3.0', require: false
11
12
  gem 'rspec-github', require: false
12
- gem 'rubocop'
13
+ gem 'rubocop', require: false
13
14
 
14
15
  group :bench do
15
16
  gem 'benchmark-ips'
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ RSpec::Core::RakeTask.new(:spec)
9
9
 
10
10
  task build: :compile
11
11
 
12
- task default: %i[clobber compile spec]
12
+ task default: %i[clobber compile spec lint]
13
13
 
14
14
  spec = Gem::Specification.load(File.expand_path('mini_phone.gemspec', __dir__))
15
15
 
@@ -28,7 +28,16 @@ task bench: %i[clobber compile] do
28
28
  end
29
29
  end
30
30
 
31
- task :deploy do
31
+ task :lint do
32
+ sh 'bundle exec rubocop'
33
+ end
34
+
35
+ task :format do
36
+ sh 'bundle exec rubocop -A'
37
+ sh 'clang-format -i ext/**/*.{h,cc}'
38
+ end
39
+
40
+ task deploy: :default do
32
41
  sh 'code -w ./lib/mini_phone/version.rb'
33
42
  version = `ruby -r ./lib/mini_phone/version.rb -e 'print MiniPhone::VERSION'`.strip
34
43
  sh "git commit -am 'Bump to v#{version} :confetti_ball:'"
@@ -63,11 +72,7 @@ namespace :publish do
63
72
  task non_native: [:gem] do
64
73
  g = "./pkg/mini_phone-#{MiniPhone::VERSION}.gem"
65
74
 
66
- results = []
67
-
68
- results << push_to_rubygems(g)
69
- results << push_to_github_registry(g)
70
-
71
- abort if results.all? { |r| r == true }
75
+ push_to_rubygems(g)
76
+ push_to_github_registry(g)
72
77
  end
73
78
  end
@@ -4,47 +4,6 @@
4
4
 
5
5
  require 'mkmf'
6
6
 
7
- LIBDIR = RbConfig::CONFIG['libdir']
8
-
9
- INCLUDEDIR = RbConfig::CONFIG['includedir']
10
-
11
- header_dirs = [
12
- # First search /opt/local for macports
13
- '/opt/local/include',
14
-
15
- # Then search /usr/local for people that installed from source
16
- '/usr/local/include',
17
-
18
- # Check the ruby install locations
19
- INCLUDEDIR,
20
-
21
- # Finally fall back to /usr
22
- '/usr/include'
23
- ]
24
-
25
- lib_dirs = [
26
- # First search /opt/local for macports
27
- '/opt/local/lib',
28
-
29
- # Then search /usr/local for people that installed from source
30
- '/usr/local/lib',
31
-
32
- # Check the ruby install locations
33
- LIBDIR,
34
-
35
- # Finally fall back to /usr
36
- '/usr/lib'
37
- ]
38
-
39
- # Detect homebrew installs
40
- if find_executable('brew')
41
- brew_prefix = `brew --prefix`.strip
42
- header_dirs.unshift "#{brew_prefix}/include"
43
- lib_dirs.unshift "#{brew_prefix}/lib"
44
- end
45
-
46
- dir_config('mini_phone', header_dirs, lib_dirs)
47
-
48
7
  unless have_library('phonenumber')
49
8
  abort <<~MSG
50
9
 
@@ -70,7 +29,9 @@ unless have_library('phonenumber')
70
29
  MSG
71
30
  end
72
31
 
73
- $CXXFLAGS += ' -std=c++11 '
32
+ dir_config('mini_phone')
33
+
34
+ $CXXFLAGS += ' -std=c++11 -ofast '
74
35
 
75
36
  create_makefile('mini_phone/mini_phone')
76
37
 
@@ -1,12 +1,18 @@
1
1
  #include "mini_phone.h"
2
+ #include "phonenumbers/phonemetadata.pb.h"
3
+ #include "phonenumbers/phonenumber.pb.h"
2
4
  #include "phonenumbers/phonenumberutil.h"
3
5
 
4
6
  using namespace ::i18n::phonenumbers;
5
7
 
8
+ using google::protobuf::RepeatedPtrField;
9
+
6
10
  static VALUE rb_mMiniPhone;
7
11
 
8
12
  static VALUE rb_cPhoneNumber;
9
13
 
14
+ static RepeatedPtrField<NumberFormat> raw_national_format;
15
+
10
16
  extern "C" struct PhoneNumberInfo {
11
17
  PhoneNumber phone_number;
12
18
  std::string raw_phone_number;
@@ -14,15 +20,19 @@ extern "C" struct PhoneNumberInfo {
14
20
  };
15
21
 
16
22
  static inline VALUE is_phone_number_valid(VALUE self, VALUE str, VALUE cc) {
23
+ if (NIL_P(str) || NIL_P(cc)) {
24
+ return Qfalse;
25
+ }
26
+
17
27
  PhoneNumber parsed_number;
18
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
28
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
19
29
 
20
30
  std::string phone_number(RSTRING_PTR(str), RSTRING_LEN(str));
21
31
  std::string country_code(RSTRING_PTR(cc), RSTRING_LEN(cc));
22
32
 
23
- auto result = phone_util->ParseAndKeepRawInput(phone_number, country_code, &parsed_number);
33
+ auto result = phone_util.ParseAndKeepRawInput(phone_number, country_code, &parsed_number);
24
34
 
25
- if (result == PhoneNumberUtil::NO_PARSING_ERROR && phone_util->IsValidNumber(parsed_number)) {
35
+ if (result == PhoneNumberUtil::NO_PARSING_ERROR && phone_util.IsValidNumber(parsed_number)) {
26
36
  return Qtrue;
27
37
  } else {
28
38
  return Qfalse;
@@ -35,6 +45,20 @@ extern "C" VALUE rb_is_phone_number_valid(VALUE self, VALUE str) {
35
45
  return is_phone_number_valid(self, str, def_cc);
36
46
  }
37
47
 
48
+ extern "C" VALUE rb_normalize_digits_only(VALUE self, VALUE str) {
49
+ if (NIL_P(str)) {
50
+ return Qnil;
51
+ }
52
+
53
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
54
+
55
+ std::string phone_number(RSTRING_PTR(str), RSTRING_LEN(str));
56
+
57
+ phone_util.NormalizeDigitsOnly(&phone_number);
58
+
59
+ return rb_str_new(phone_number.c_str(), phone_number.size());
60
+ }
61
+
38
62
  extern "C" VALUE rb_is_phone_number_valid_for_country(VALUE self, VALUE str, VALUE cc) {
39
63
  return is_phone_number_valid(self, str, cc);
40
64
  }
@@ -48,16 +72,20 @@ extern "C" VALUE rb_is_phone_number_invalid_for_country(VALUE self, VALUE str, V
48
72
  }
49
73
 
50
74
  extern "C" VALUE rb_is_phone_number_possible(VALUE self, VALUE str) {
75
+ if (NIL_P(str)) {
76
+ return Qnil;
77
+ }
78
+
51
79
  PhoneNumber parsed_number;
52
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
80
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
53
81
 
54
82
  VALUE def_cc = rb_iv_get(rb_mMiniPhone, "@default_country");
55
83
  std::string phone_number(RSTRING_PTR(str), RSTRING_LEN(str));
56
84
  std::string country_code(RSTRING_PTR(def_cc), RSTRING_LEN(def_cc));
57
85
 
58
- auto result = phone_util->Parse(phone_number, country_code, &parsed_number);
86
+ auto result = phone_util.Parse(phone_number, country_code, &parsed_number);
59
87
 
60
- if (result == PhoneNumberUtil::NO_PARSING_ERROR && phone_util->IsPossibleNumber(parsed_number)) {
88
+ if (result == PhoneNumberUtil::NO_PARSING_ERROR && phone_util.IsPossibleNumber(parsed_number)) {
61
89
  return Qtrue;
62
90
  } else {
63
91
  return Qfalse;
@@ -69,6 +97,10 @@ extern "C" VALUE rb_is_phone_number_impossible(VALUE self, VALUE str) {
69
97
  }
70
98
 
71
99
  extern "C" VALUE rb_set_default_country(VALUE self, VALUE str_code) {
100
+ if (NIL_P(str_code)) {
101
+ str_code = rb_str_new("ZZ", 2);
102
+ }
103
+
72
104
  return rb_iv_set(self, "@default_country", str_code);
73
105
  }
74
106
 
@@ -89,6 +121,7 @@ extern "C" VALUE rb_phone_number_alloc(VALUE self) {
89
121
 
90
122
  static inline VALUE rb_phone_number_nullify_ivars(VALUE self) {
91
123
  rb_iv_set(self, "@national", Qnil);
124
+ rb_iv_set(self, "@raw_national", Qnil);
92
125
  rb_iv_set(self, "@international", Qnil);
93
126
  rb_iv_set(self, "@e164", Qnil);
94
127
  rb_iv_set(self, "@country_code", Qnil);
@@ -97,6 +130,7 @@ static inline VALUE rb_phone_number_nullify_ivars(VALUE self) {
97
130
  rb_iv_set(self, "@type", Qnil);
98
131
  rb_iv_set(self, "@valid", Qfalse);
99
132
  rb_iv_set(self, "@possible", Qfalse);
133
+ rb_iv_set(self, "@area_code", Qnil);
100
134
 
101
135
  return Qtrue;
102
136
  }
@@ -124,12 +158,12 @@ extern "C" VALUE rb_phone_number_initialize(int argc, VALUE *argv, VALUE self) {
124
158
 
125
159
  Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
126
160
 
127
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
161
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
128
162
 
129
163
  std::string phone_number(RSTRING_PTR(str), RSTRING_LEN(str));
130
164
  std::string country_code(RSTRING_PTR(def_cc), RSTRING_LEN(def_cc));
131
165
 
132
- auto result = phone_util->Parse(phone_number, country_code, &parsed_number);
166
+ auto result = phone_util.Parse(phone_number, country_code, &parsed_number);
133
167
 
134
168
  if (result != PhoneNumberUtil::NO_PARSING_ERROR) {
135
169
  rb_phone_number_nullify_ivars(self);
@@ -145,9 +179,9 @@ static inline VALUE rb_phone_number_format(VALUE self, PhoneNumberUtil::PhoneNum
145
179
  PhoneNumberInfo *phone_number_info;
146
180
  Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
147
181
 
148
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
182
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
149
183
  PhoneNumber parsed_number = phone_number_info->phone_number;
150
- phone_util->Format(parsed_number, fmt, &formatted_number);
184
+ phone_util.Format(parsed_number, fmt, &formatted_number);
151
185
 
152
186
  return rb_str_new(formatted_number.c_str(), formatted_number.size());
153
187
  }
@@ -185,6 +219,24 @@ extern "C" VALUE rb_phone_number_rfc3966(VALUE self) {
185
219
  return rb_iv_set(self, "@rfc3966", rb_phone_number_format(self, PhoneNumberUtil::PhoneNumberFormat::RFC3966));
186
220
  }
187
221
 
222
+ extern "C" VALUE rb_phone_number_raw_national(VALUE self) {
223
+ if (rb_ivar_defined(self, rb_intern("@raw_national"))) {
224
+ return rb_iv_get(self, "@raw_national");
225
+ }
226
+
227
+ std::string formatted_number;
228
+ PhoneNumberInfo *phone_number_info;
229
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
230
+ Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
231
+
232
+ phone_util.FormatByPattern(phone_number_info->phone_number, PhoneNumberUtil::NATIONAL, raw_national_format,
233
+ &formatted_number);
234
+
235
+ VALUE result = rb_str_new(formatted_number.c_str(), formatted_number.size());
236
+
237
+ return rb_iv_set(self, "@raw_national", result);
238
+ }
239
+
188
240
  extern "C" VALUE rb_phone_number_valid_eh(VALUE self) {
189
241
  if (rb_ivar_defined(self, rb_intern("@valid"))) {
190
242
  return rb_iv_get(self, "@valid");
@@ -194,9 +246,9 @@ extern "C" VALUE rb_phone_number_valid_eh(VALUE self) {
194
246
  PhoneNumberInfo *phone_number_info;
195
247
  Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
196
248
 
197
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
249
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
198
250
 
199
- if (phone_util->IsValidNumber(phone_number_info->phone_number)) {
251
+ if (phone_util.IsValidNumber(phone_number_info->phone_number)) {
200
252
  return rb_iv_set(self, "@valid", Qtrue);
201
253
  } else {
202
254
  return rb_iv_set(self, "@valid", Qfalse);
@@ -216,9 +268,9 @@ extern "C" VALUE rb_phone_number_possible_eh(VALUE self) {
216
268
  PhoneNumberInfo *phone_number_info;
217
269
  Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
218
270
 
219
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
271
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
220
272
 
221
- if (phone_util->IsPossibleNumber(phone_number_info->phone_number)) {
273
+ if (phone_util.IsPossibleNumber(phone_number_info->phone_number)) {
222
274
  return rb_iv_set(self, "@possible", Qtrue);
223
275
  } else {
224
276
  return rb_iv_set(self, "@possible", Qfalse);
@@ -237,9 +289,9 @@ extern "C" VALUE rb_phone_number_region_code(VALUE self) {
237
289
  PhoneNumberInfo *phone_number_info;
238
290
  std::string code;
239
291
  Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
240
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
292
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
241
293
 
242
- phone_util->GetRegionCodeForCountryCode(phone_number_info->phone_number.country_code(), &code);
294
+ phone_util.GetRegionCodeForCountryCode(phone_number_info->phone_number.country_code(), &code);
243
295
 
244
296
  VALUE result = rb_str_new(code.c_str(), code.size());
245
297
 
@@ -266,14 +318,14 @@ extern "C" VALUE rb_phone_number_eql_eh(VALUE self, VALUE other) {
266
318
  return Qfalse;
267
319
  }
268
320
 
269
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
321
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
270
322
 
271
323
  PhoneNumberInfo *self_phone_number_info;
272
324
  Data_Get_Struct(self, PhoneNumberInfo, self_phone_number_info);
273
325
 
274
326
  PhoneNumberInfo *other_phone_number_info;
275
327
  Data_Get_Struct(other, PhoneNumberInfo, other_phone_number_info);
276
- if (phone_util->IsNumberMatch(other_phone_number_info->phone_number, self_phone_number_info->phone_number)) {
328
+ if (phone_util.IsNumberMatch(other_phone_number_info->phone_number, self_phone_number_info->phone_number)) {
277
329
  return Qtrue;
278
330
  } else {
279
331
  return Qfalse;
@@ -287,13 +339,13 @@ extern "C" VALUE rb_phone_number_type(VALUE self) {
287
339
 
288
340
  PhoneNumberInfo *phone_number_info;
289
341
  Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
290
- PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
342
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
291
343
 
292
344
  VALUE result;
293
345
 
294
346
  // @see
295
347
  // https://github.com/google/libphonenumber/blob/4e9954edea7cf263532c5dd3861a801104c3f012/cpp/src/phonenumbers/phonenumberutil.h#L91
296
- switch (phone_util->GetNumberType(phone_number_info->phone_number)) {
348
+ switch (phone_util.GetNumberType(phone_number_info->phone_number)) {
297
349
  case PhoneNumberUtil::PREMIUM_RATE:
298
350
  result = rb_intern("premium_rate");
299
351
  break;
@@ -335,6 +387,35 @@ extern "C" VALUE rb_phone_number_type(VALUE self) {
335
387
  return rb_iv_set(self, "@type", ID2SYM(result));
336
388
  }
337
389
 
390
+ extern "C" VALUE rb_phone_number_area_code(VALUE self) {
391
+ if (rb_ivar_defined(self, rb_intern("@area_code"))) {
392
+ return rb_iv_get(self, "@area_code");
393
+ }
394
+
395
+ const PhoneNumberUtil &phone_util(*PhoneNumberUtil::GetInstance());
396
+ PhoneNumberInfo *phone_number_info;
397
+ Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
398
+
399
+ PhoneNumber number = phone_number_info->phone_number;
400
+ string national_significant_number;
401
+ phone_util.GetNationalSignificantNumber(number, &national_significant_number);
402
+ string area_code;
403
+ string subscriber_number;
404
+
405
+ int area_code_length = phone_util.GetLengthOfGeographicalAreaCode(number);
406
+ if (area_code_length > 0) {
407
+ area_code = national_significant_number.substr(0, area_code_length);
408
+ subscriber_number = national_significant_number.substr(area_code_length, string::npos);
409
+ } else {
410
+ area_code = "";
411
+ subscriber_number = national_significant_number;
412
+ }
413
+
414
+ VALUE result = rb_str_new(area_code.c_str(), area_code.size());
415
+
416
+ return rb_iv_set(self, "@area_code", result);
417
+ }
418
+
338
419
  extern "C" void Init_mini_phone(void) {
339
420
  rb_mMiniPhone = rb_define_module("MiniPhone");
340
421
 
@@ -350,11 +431,13 @@ extern "C" void Init_mini_phone(void) {
350
431
  rb_define_module_function(rb_mMiniPhone, "possible?", reinterpret_cast<VALUE (*)(...)>(rb_is_phone_number_valid), 1);
351
432
  rb_define_module_function(rb_mMiniPhone, "impossible?", reinterpret_cast<VALUE (*)(...)>(rb_is_phone_number_invalid),
352
433
  1);
353
- rb_define_module_function(rb_mMiniPhone,
354
- "default_country=", reinterpret_cast<VALUE (*)(...)>(rb_set_default_country), 1);
355
- rb_define_module_function(rb_mMiniPhone, "default_country",
356
- reinterpret_cast<VALUE (*)(...)>(rb_get_default_country), 0);
434
+ rb_define_module_function(rb_mMiniPhone, "default_country=", reinterpret_cast<VALUE (*)(...)>(rb_set_default_country),
435
+ 1);
436
+ rb_define_module_function(rb_mMiniPhone, "default_country", reinterpret_cast<VALUE (*)(...)>(rb_get_default_country),
437
+ 0);
357
438
  rb_define_module_function(rb_mMiniPhone, "parse", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_parse), -1);
439
+ rb_define_module_function(rb_mMiniPhone, "normalize_digits_only",
440
+ reinterpret_cast<VALUE (*)(...)>(rb_normalize_digits_only), 1);
358
441
 
359
442
  rb_cPhoneNumber = rb_define_class_under(rb_mMiniPhone, "PhoneNumber", rb_cObject);
360
443
 
@@ -367,11 +450,18 @@ extern "C" void Init_mini_phone(void) {
367
450
  rb_define_method(rb_cPhoneNumber, "impossible?", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_impossible_eh), 0);
368
451
  rb_define_method(rb_cPhoneNumber, "e164", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_e164), 0);
369
452
  rb_define_method(rb_cPhoneNumber, "national", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_national), 0);
453
+
454
+ // Raw National
455
+ raw_national_format.Add()->set_format("$1$2$3");
456
+
457
+ rb_define_method(rb_cPhoneNumber, "raw_national", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_raw_national), 0);
370
458
  rb_define_method(rb_cPhoneNumber, "international", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_international),
371
459
  0);
372
460
  rb_define_method(rb_cPhoneNumber, "rfc3966", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_rfc3966), 0);
373
461
  rb_define_method(rb_cPhoneNumber, "region_code", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_region_code), 0);
462
+ rb_define_method(rb_cPhoneNumber, "country", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_region_code), 0);
374
463
  rb_define_method(rb_cPhoneNumber, "country_code", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_country_code), 0);
375
464
  rb_define_method(rb_cPhoneNumber, "type", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_type), 0);
465
+ rb_define_method(rb_cPhoneNumber, "area_code", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_area_code), 0);
376
466
  rb_define_method(rb_cPhoneNumber, "eql?", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_eql_eh), 1);
377
467
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniPhone
4
- VERSION = '1.0.0.beta.0'
4
+ VERSION = '1.0.4'
5
5
  end
@@ -27,7 +27,10 @@ Gem::Specification.new do |spec|
27
27
  # Specify which files should be added to the gem when it is released.
28
28
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
29
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|spec|bench)/}) }
30
+ `git ls-files -z`
31
+ .split("\x0")
32
+ .reject { |f| f.match(%r{^(bin|spec|bench)/}) }
33
+ .reject { |f| f.start_with?('.') }
31
34
  end
32
35
  spec.bindir = 'exe'
33
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.0.0.beta.0
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-08 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.
@@ -20,13 +20,6 @@ extensions:
20
20
  - ext/mini_phone/extconf.rb
21
21
  extra_rdoc_files: []
22
22
  files:
23
- - ".clang-format"
24
- - ".github/workflows/ci.yml"
25
- - ".github/workflows/release.yml"
26
- - ".gitignore"
27
- - ".rspec"
28
- - ".rubocop.yml"
29
- - ".travis.yml"
30
23
  - CHANGELOG.md
31
24
  - CODE_OF_CONDUCT.md
32
25
  - Gemfile
@@ -58,9 +51,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
51
  version: 2.5.0
59
52
  required_rubygems_version: !ruby/object:Gem::Requirement
60
53
  requirements:
61
- - - ">"
54
+ - - ">="
62
55
  - !ruby/object:Gem::Version
63
- version: 1.3.1
56
+ version: '0'
64
57
  requirements: []
65
58
  rubygems_version: 3.1.4
66
59
  signing_key:
@@ -1,3 +0,0 @@
1
- ---
2
- BasedOnStyle: LLVM
3
- ColumnLimit: 120
@@ -1,51 +0,0 @@
1
- ---
2
- name: CI
3
-
4
- on: push
5
-
6
- jobs:
7
- build:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: ["2.5", "2.6", "2.7", "3.0"]
12
- os: [ubuntu-latest, macos-latest]
13
- experimental: [false]
14
- # include:
15
- # - ruby: "truffleruby"
16
- # os: ubuntu-latest
17
- # experimental: true
18
- # - ruby: "truffleruby"
19
- # os: macos-latest
20
- # experimental: true
21
- name: ${{ matrix.ruby }} on ${{ matrix.os }}
22
- runs-on: ${{ matrix.os }}
23
- continue-on-error: ${{ matrix.experimental }}
24
- env:
25
- CI_EXPERIMENTAL: ${{ matrix.experimental }}
26
- steps:
27
- - uses: actions/checkout@v2
28
-
29
- - uses: ruby/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
-
33
- - name: Install dependencies (system)
34
- if: ${{ matrix.os == 'ubuntu-latest' }}
35
- run: sudo apt-get -yqq install libphonenumber-dev
36
-
37
- - name: Install dependencies (system)
38
- if: ${{ matrix.os == 'macos-latest' }}
39
- run: brew install --build-from-source libphonenumber && brew link libphonenumber
40
-
41
- - name: Install dependencies (ruby)
42
- run: gem install bundler && bundle install --jobs 4 --retry 3
43
-
44
- - name: Compile
45
- run: bundle exec rake compile
46
-
47
- - name: RSpec
48
- run: bundle exec rspec --format RSpec::Github::Formatter --format documentation
49
-
50
- - name: Rubocop
51
- run: bundle exec rubocop --format github
@@ -1,55 +0,0 @@
1
- ---
2
- name: Release
3
-
4
- on:
5
- push:
6
- tags:
7
- - "v*"
8
-
9
- jobs:
10
- build:
11
- strategy:
12
- fail-fast: false
13
- matrix:
14
- ruby: ["2.7"]
15
- os: [ubuntu-latest, macos-latest]
16
- name: ${{ matrix.os }}
17
- runs-on: ${{ matrix.os }}
18
- steps:
19
- - uses: actions/checkout@v2
20
-
21
- - uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby }}
24
-
25
- - name: Install dependencies (system)
26
- if: ${{ matrix.os == 'ubuntu-latest' }}
27
- run: sudo apt-get -yqq install libphonenumber-dev
28
-
29
- - name: Install dependencies (system)
30
- if: ${{ matrix.os == 'macos-latest' }}
31
- run: brew install --build-from-source libphonenumber && brew link libphonenumber
32
-
33
- - name: Install dependencies (ruby)
34
- run: gem install bundler && bundle install --jobs 4 --retry 3
35
-
36
- - name: Login
37
- run: |
38
- mkdir -p ~/.gem
39
-
40
- cat << EOF > ~/.gem/credentials
41
- ---
42
- :github: ${GITHUB_AUTH_TOKEN}
43
- :rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}
44
- EOF
45
-
46
- chmod 0600 ~/.gem/credentials
47
- env:
48
- GITHUB_AUTH_TOKEN: "Bearer ${{secrets.GITHUB_TOKEN}}"
49
- RUBYGEMS_AUTH_TOKEN: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
50
- OWNER: ${{ github.repository_owner }}
51
-
52
- - name: 🛳 Ship it
53
- run: |
54
- bundle exec rake publish:native
55
- bundle exec rake publish:non_native || true
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- .bundle/
2
- .yardoc
3
- _yardoc/
4
- coverage/
5
- doc/
6
- pkg/
7
- spec/reports/
8
- tmp/
9
- *.bundle
10
- *.so
11
- *.o
12
- *.a
13
- mkmf.log
14
-
15
- # rspec failure tracking
16
- .rspec_status
17
- Gemfile.lock
18
- vendor/cache/
19
- *.gem
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1,23 +0,0 @@
1
- # The behavior of RuboCop can be controlled via the .rubocop.yml
2
- # configuration file. It makes it possible to enable/disable
3
- # certain cops (checks) and to alter their behavior if they accept
4
- # any parameters. The file can be placed either in your home
5
- # directory or in some project directory.
6
- #
7
- # RuboCop will start looking for the configuration file in the directory
8
- # where the inspected file is and continue its way up to the root directory.
9
- #
10
- # See https://docs.rubocop.org/rubocop/configuration
11
- AllCops:
12
- TargetRubyVersion: 2.5
13
- NewCops: enable
14
- SuggestExtensions: false
15
- Exclude:
16
- - pkg/**/*
17
- - tmp/**/*
18
-
19
- Metrics/BlockLength:
20
- Exclude:
21
- - spec/**/*
22
- - Rakefile
23
- - Gemfile
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4