mini_phone 0.1.0 → 1.0.0.beta.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 +9 -9
- data/.github/workflows/release.yml +55 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +5 -0
- data/Rakefile +47 -2
- data/ext/mini_phone/mini_phone.cc +10 -10
- data/lib/mini_phone/version.rb +1 -1
- data/mini_phone.gemspec +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98edc8a1bf120a002c013d80d48ea0bd55c2f1d2bcb2912c02721ee58140a8f7
|
4
|
+
data.tar.gz: 52849767577cb45129bae6fb875f343316291da9600de16dbe406cc8c7705242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6ee4d57ff10389a45d0072b464098cee65fde3d7792127002e9a82879bd08077dec3182dcc243213510f4dd303c643202135f586c528463516f042dfae7c6cf
|
7
|
+
data.tar.gz: 564fb760f1a5cdcb9b81835511dc3a382632fa93b8235abb6384a3aa85ce727eaaa9cff031bf377669a102208776179e1b08000dc72a6cfe7d83caa75bde96a7
|
data/.github/workflows/ci.yml
CHANGED
@@ -5,21 +5,21 @@ on: push
|
|
5
5
|
|
6
6
|
jobs:
|
7
7
|
build:
|
8
|
-
runs-on: ubuntu-16.04
|
9
8
|
strategy:
|
10
9
|
fail-fast: false
|
11
10
|
matrix:
|
12
|
-
ruby: ["2.5", "2.6", "2.7"]
|
11
|
+
ruby: ["2.5", "2.6", "2.7", "3.0"]
|
13
12
|
os: [ubuntu-latest, macos-latest]
|
14
13
|
experimental: [false]
|
15
|
-
include:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
# include:
|
15
|
+
# - ruby: "truffleruby"
|
16
|
+
# os: ubuntu-latest
|
17
|
+
# experimental: true
|
18
|
+
# - ruby: "truffleruby"
|
19
|
+
# os: macos-latest
|
20
|
+
# experimental: true
|
22
21
|
name: ${{ matrix.ruby }} on ${{ matrix.os }}
|
22
|
+
runs-on: ${{ matrix.os }}
|
23
23
|
continue-on-error: ${{ matrix.experimental }}
|
24
24
|
env:
|
25
25
|
CI_EXPERIMENTAL: ${{ matrix.experimental }}
|
@@ -0,0 +1,55 @@
|
|
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
CHANGED
data/.rubocop.yml
CHANGED
data/Rakefile
CHANGED
@@ -5,16 +5,17 @@ require 'rspec/core/rake_task'
|
|
5
5
|
require 'rubygems/package_task'
|
6
6
|
require 'rake/extensiontask'
|
7
7
|
|
8
|
-
|
9
8
|
RSpec::Core::RakeTask.new(:spec)
|
10
9
|
|
11
10
|
task build: :compile
|
12
11
|
|
13
12
|
task default: %i[clobber compile spec]
|
14
13
|
|
15
|
-
spec = Gem::Specification
|
14
|
+
spec = Gem::Specification.load(File.expand_path('mini_phone.gemspec', __dir__))
|
16
15
|
|
17
16
|
Gem::PackageTask.new(spec) do |pkg|
|
17
|
+
pkg.need_zip = true
|
18
|
+
pkg.need_tar = true
|
18
19
|
end
|
19
20
|
|
20
21
|
Rake::ExtensionTask.new('mini_phone', spec) do |ext|
|
@@ -26,3 +27,47 @@ task bench: %i[clobber compile] do
|
|
26
27
|
require_relative f
|
27
28
|
end
|
28
29
|
end
|
30
|
+
|
31
|
+
task :deploy do
|
32
|
+
sh 'code -w ./lib/mini_phone/version.rb'
|
33
|
+
version = `ruby -r ./lib/mini_phone/version.rb -e 'print MiniPhone::VERSION'`.strip
|
34
|
+
sh "git commit -am 'Bump to v#{version} :confetti_ball:'"
|
35
|
+
sh 'gem_push=no bundle exec rake release'
|
36
|
+
end
|
37
|
+
|
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
|
+
|
48
|
+
def push_to_rubygems(gem)
|
49
|
+
puts "Pushing #{gem} to rubygems"
|
50
|
+
sh "gem push #{gem}"
|
51
|
+
true
|
52
|
+
rescue StandardError
|
53
|
+
warn 'Could not publish to rubygems'
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
task native: %i[native gem] do
|
58
|
+
g = "./pkg/mini_phone-#{MiniPhone::VERSION}-#{Gem::Platform.new(RUBY_PLATFORM)}.gem"
|
59
|
+
|
60
|
+
push_to_rubygems(g)
|
61
|
+
end
|
62
|
+
|
63
|
+
task non_native: [:gem] do
|
64
|
+
g = "./pkg/mini_phone-#{MiniPhone::VERSION}.gem"
|
65
|
+
|
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 }
|
72
|
+
end
|
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
data/mini_phone.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = 'MIT'
|
17
17
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
18
18
|
|
19
|
-
spec.platform
|
19
|
+
spec.platform = Gem::Platform::RUBY
|
20
20
|
|
21
21
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
22
22
|
|
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.beta.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-07 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.
|
@@ -22,6 +22,7 @@ extra_rdoc_files: []
|
|
22
22
|
files:
|
23
23
|
- ".clang-format"
|
24
24
|
- ".github/workflows/ci.yml"
|
25
|
+
- ".github/workflows/release.yml"
|
25
26
|
- ".gitignore"
|
26
27
|
- ".rspec"
|
27
28
|
- ".rubocop.yml"
|
@@ -46,7 +47,7 @@ metadata:
|
|
46
47
|
homepage_uri: https://github.com/ianks/mini_phone
|
47
48
|
source_code_uri: https://github.com/ianks/mini_phone
|
48
49
|
changelog_uri: https://github.com/ianks/mini_phone/blob/master/CHANGELOG.md
|
49
|
-
post_install_message:
|
50
|
+
post_install_message:
|
50
51
|
rdoc_options: []
|
51
52
|
require_paths:
|
52
53
|
- lib
|
@@ -57,12 +58,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
58
|
version: 2.5.0
|
58
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
|
-
- - "
|
61
|
+
- - ">"
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
63
|
+
version: 1.3.1
|
63
64
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
65
|
-
signing_key:
|
65
|
+
rubygems_version: 3.1.4
|
66
|
+
signing_key:
|
66
67
|
specification_version: 4
|
67
68
|
summary: Uses the Google libphonenumber C lib to parse, validate, and format phone
|
68
69
|
numbers
|