mini_phone 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.rubocop.yml +5 -0
- data/Gemfile +4 -3
- data/Rakefile +16 -5
- data/ext/mini_phone/mini_phone.cc +10 -10
- data/lib/mini_phone/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aeb4f877c1a92925416a7642c331cc9229233bdc070b877cb1b8801241dd6f8
|
4
|
+
data.tar.gz: 7262c82936a62c6d6e32123f23b2189a4eddc870cb708eb06784658785080e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6bf08052c013aa7bbd6a49ebbe47ab8ee356c32866e7b0a2048751ca16c407e9efc65593a400b5fe2440bbc9c5ea424f1489561d05e0e107064d068b1f02a8a
|
7
|
+
data.tar.gz: 121ef682de85616bf54075dd70246669b2228234795856fe12cc323a58fe7d89685a660084f3c7c5246e5a83bfdd55a4f17b4be08b44a12ae1ce5de21f3a7e21
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
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',
|
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
@@ -32,31 +32,42 @@ task :deploy do
|
|
32
32
|
sh 'code -w ./lib/mini_phone/version.rb'
|
33
33
|
version = `ruby -r ./lib/mini_phone/version.rb -e 'print MiniPhone::VERSION'`.strip
|
34
34
|
sh "git commit -am 'Bump to v#{version} :confetti_ball:'"
|
35
|
-
sh 'bundle exec rake release'
|
35
|
+
sh 'gem_push=no bundle exec rake release'
|
36
36
|
end
|
37
37
|
|
38
38
|
namespace :publish do
|
39
39
|
def push_to_github_registry(gem)
|
40
40
|
puts "Pushing #{gem} to GitHub Package Registry"
|
41
41
|
sh "gem push #{gem} --host https://rubygems.pkg.github.com/ianks --key github"
|
42
|
+
true
|
43
|
+
rescue StandardError
|
44
|
+
warn 'Could not publish to Github Package Registry'
|
45
|
+
false
|
42
46
|
end
|
43
47
|
|
44
48
|
def push_to_rubygems(gem)
|
45
|
-
puts "Pushing #{gem} to
|
49
|
+
puts "Pushing #{gem} to rubygems"
|
46
50
|
sh "gem push #{gem}"
|
51
|
+
true
|
52
|
+
rescue StandardError
|
53
|
+
warn 'Could not publish to rubygems'
|
54
|
+
false
|
47
55
|
end
|
48
56
|
|
49
57
|
task native: %i[native gem] do
|
50
58
|
g = "./pkg/mini_phone-#{MiniPhone::VERSION}-#{Gem::Platform.new(RUBY_PLATFORM)}.gem"
|
51
59
|
|
52
|
-
push_to_github_registry(g)
|
53
60
|
push_to_rubygems(g)
|
54
61
|
end
|
55
62
|
|
56
63
|
task non_native: [:gem] do
|
57
64
|
g = "./pkg/mini_phone-#{MiniPhone::VERSION}.gem"
|
58
65
|
|
59
|
-
|
60
|
-
|
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 }
|
61
72
|
end
|
62
73
|
end
|
@@ -30,7 +30,7 @@ static inline VALUE is_phone_number_valid(VALUE self, VALUE str, VALUE cc) {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
extern "C" VALUE rb_is_phone_number_valid(VALUE self, VALUE str) {
|
33
|
-
VALUE def_cc = rb_iv_get(rb_mMiniPhone, "@
|
33
|
+
VALUE def_cc = rb_iv_get(rb_mMiniPhone, "@default_country");
|
34
34
|
|
35
35
|
return is_phone_number_valid(self, str, def_cc);
|
36
36
|
}
|
@@ -51,7 +51,7 @@ extern "C" VALUE rb_is_phone_number_possible(VALUE self, VALUE str) {
|
|
51
51
|
PhoneNumber parsed_number;
|
52
52
|
PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance();
|
53
53
|
|
54
|
-
VALUE def_cc = rb_iv_get(rb_mMiniPhone, "@
|
54
|
+
VALUE def_cc = rb_iv_get(rb_mMiniPhone, "@default_country");
|
55
55
|
std::string phone_number(RSTRING_PTR(str), RSTRING_LEN(str));
|
56
56
|
std::string country_code(RSTRING_PTR(def_cc), RSTRING_LEN(def_cc));
|
57
57
|
|
@@ -68,11 +68,11 @@ extern "C" VALUE rb_is_phone_number_impossible(VALUE self, VALUE str) {
|
|
68
68
|
return rb_is_phone_number_possible(self, str) == Qtrue ? Qfalse : Qtrue;
|
69
69
|
}
|
70
70
|
|
71
|
-
extern "C" VALUE
|
72
|
-
return rb_iv_set(self, "@
|
71
|
+
extern "C" VALUE rb_set_default_country(VALUE self, VALUE str_code) {
|
72
|
+
return rb_iv_set(self, "@default_country", str_code);
|
73
73
|
}
|
74
74
|
|
75
|
-
extern "C" VALUE
|
75
|
+
extern "C" VALUE rb_get_default_country(VALUE self) { return rb_iv_get(self, "@default_country"); }
|
76
76
|
|
77
77
|
extern "C" void rb_phone_number_dealloc(PhoneNumberInfo *phone_number_info) { delete phone_number_info; }
|
78
78
|
|
@@ -108,7 +108,7 @@ extern "C" VALUE rb_phone_number_initialize(int argc, VALUE *argv, VALUE self) {
|
|
108
108
|
rb_scan_args(argc, argv, "11", &str, &def_cc);
|
109
109
|
|
110
110
|
if (NIL_P(def_cc)) {
|
111
|
-
def_cc = rb_iv_get(rb_mMiniPhone, "@
|
111
|
+
def_cc = rb_iv_get(rb_mMiniPhone, "@default_country");
|
112
112
|
}
|
113
113
|
|
114
114
|
rb_iv_set(self, "@input", str);
|
@@ -339,7 +339,7 @@ extern "C" void Init_mini_phone(void) {
|
|
339
339
|
rb_mMiniPhone = rb_define_module("MiniPhone");
|
340
340
|
|
341
341
|
// Unknown
|
342
|
-
rb_iv_set(rb_mMiniPhone, "@
|
342
|
+
rb_iv_set(rb_mMiniPhone, "@default_country", rb_str_new("ZZ", 2));
|
343
343
|
|
344
344
|
rb_define_module_function(rb_mMiniPhone, "valid?", reinterpret_cast<VALUE (*)(...)>(rb_is_phone_number_valid), 1);
|
345
345
|
rb_define_module_function(rb_mMiniPhone, "valid_for_country?",
|
@@ -351,9 +351,9 @@ extern "C" void Init_mini_phone(void) {
|
|
351
351
|
rb_define_module_function(rb_mMiniPhone, "impossible?", reinterpret_cast<VALUE (*)(...)>(rb_is_phone_number_invalid),
|
352
352
|
1);
|
353
353
|
rb_define_module_function(rb_mMiniPhone,
|
354
|
-
"
|
355
|
-
rb_define_module_function(rb_mMiniPhone, "
|
356
|
-
reinterpret_cast<VALUE (*)(...)>(
|
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);
|
357
357
|
rb_define_module_function(rb_mMiniPhone, "parse", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_parse), -1);
|
358
358
|
|
359
359
|
rb_cPhoneNumber = rb_define_class_under(rb_mMiniPhone, "PhoneNumber", rb_cObject);
|
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: 0.
|
4
|
+
version: 1.0.0
|
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-01-
|
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.
|
@@ -47,7 +47,7 @@ metadata:
|
|
47
47
|
homepage_uri: https://github.com/ianks/mini_phone
|
48
48
|
source_code_uri: https://github.com/ianks/mini_phone
|
49
49
|
changelog_uri: https://github.com/ianks/mini_phone/blob/master/CHANGELOG.md
|
50
|
-
post_install_message:
|
50
|
+
post_install_message:
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|
@@ -62,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
|
-
rubygems_version: 3.1.
|
66
|
-
signing_key:
|
65
|
+
rubygems_version: 3.1.4
|
66
|
+
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Uses the Google libphonenumber C lib to parse, validate, and format phone
|
69
69
|
numbers
|