mini_phone 0.1.5 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.github/workflows/release.yml +2 -10
- data/.rubocop.yml +5 -0
- data/Gemfile +4 -3
- data/Rakefile +20 -2
- data/ext/mini_phone/extconf.rb +3 -42
- data/ext/mini_phone/mini_phone.cc +10 -10
- data/lib/mini_phone/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d580b7173d240a4922cdee2385d61330427a60de326d3438b8746aa2656b4946
|
4
|
+
data.tar.gz: ed18b90ce3412d534e80703b9f95574a629fd9a214ec38476424a23a38cebeb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b758fce7c61229b6dd32c24f62cec09d972c16a1db73531e4ed504fe6275a35aaa7dae0c9d1d38c918bdbfd741189b85f1f4b6b589460be69404cc0662787b
|
7
|
+
data.tar.gz: 9d9fb2335ff906834231c7dd23669a6faf9550ec9419d8473933d92d4c12d4f2d751b8f12358be77e204889126f9962236f6c0c60cf7c1c7b5cbe4cc6bc9fe84
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,9 +12,7 @@ jobs:
|
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
14
|
ruby: ["2.7"]
|
15
|
-
|
16
|
-
name: ${{ matrix.os }}
|
17
|
-
runs-on: ${{ matrix.os }}
|
15
|
+
runs-on: ubuntu-latest
|
18
16
|
steps:
|
19
17
|
- uses: actions/checkout@v2
|
20
18
|
|
@@ -23,13 +21,8 @@ jobs:
|
|
23
21
|
ruby-version: ${{ matrix.ruby }}
|
24
22
|
|
25
23
|
- name: Install dependencies (system)
|
26
|
-
if: ${{ matrix.os == 'ubuntu-latest' }}
|
27
24
|
run: sudo apt-get -yqq install libphonenumber-dev
|
28
25
|
|
29
|
-
- name: Install dependencies (system)
|
30
|
-
if: ${{ matrix.os == 'macos-latest' }}
|
31
|
-
run: brew install --build-from-source libphonenumber && brew link libphonenumber
|
32
|
-
|
33
26
|
- name: Install dependencies (ruby)
|
34
27
|
run: gem install bundler && bundle install --jobs 4 --retry 3
|
35
28
|
|
@@ -51,5 +44,4 @@ jobs:
|
|
51
44
|
|
52
45
|
- name: 🛳 Ship it
|
53
46
|
run: |
|
54
|
-
bundle exec rake publish:
|
55
|
-
bundle exec rake publish:non_native || true
|
47
|
+
bundle exec rake publish:non_native
|
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
@@ -36,9 +36,22 @@ task :deploy do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
namespace :publish do
|
39
|
+
def push_to_github_registry(gem)
|
40
|
+
puts "Pushing #{gem} to GitHub Package Registry"
|
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
|
46
|
+
end
|
47
|
+
|
39
48
|
def push_to_rubygems(gem)
|
40
|
-
puts "Pushing #{gem} to
|
49
|
+
puts "Pushing #{gem} to rubygems"
|
41
50
|
sh "gem push #{gem}"
|
51
|
+
true
|
52
|
+
rescue StandardError
|
53
|
+
warn 'Could not publish to rubygems'
|
54
|
+
false
|
42
55
|
end
|
43
56
|
|
44
57
|
task native: %i[native gem] do
|
@@ -50,6 +63,11 @@ namespace :publish do
|
|
50
63
|
task non_native: [:gem] do
|
51
64
|
g = "./pkg/mini_phone-#{MiniPhone::VERSION}.gem"
|
52
65
|
|
53
|
-
|
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 }
|
54
72
|
end
|
55
73
|
end
|
data/ext/mini_phone/extconf.rb
CHANGED
@@ -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
|
-
|
32
|
+
dir_config('mini_phone')
|
33
|
+
|
34
|
+
$CXXFLAGS += ' -std=c++11 -ofast '
|
74
35
|
|
75
36
|
create_makefile('mini_phone/mini_phone')
|
76
37
|
|
@@ -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.1
|
4
|
+
version: 1.0.1
|
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-
|
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.
|