mini_phone 0.1.5 → 1.0.1

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: e912300b4f76db0e62e401bfb92baf1591f2c84ad79ea4a5f01a184e55d45269
4
- data.tar.gz: ad34125da6539853d30f8b6fe846130e6895d7f67188d14a5cd8006ccee7f1b0
3
+ metadata.gz: d580b7173d240a4922cdee2385d61330427a60de326d3438b8746aa2656b4946
4
+ data.tar.gz: ed18b90ce3412d534e80703b9f95574a629fd9a214ec38476424a23a38cebeb5
5
5
  SHA512:
6
- metadata.gz: 7c01a16d10ca9ec1e26202500af5f5e6415f7808a15713542ecf6a83cafb42c70b40d0041efb63027f7523a4d1e61581efc87c2efa6b7cc252123e538894ebab
7
- data.tar.gz: 0d67e790bf60c2ca2108e1f62f9022bb51dfbda3e82b63fa4fc5d27edc1de936c2c2984c887588c7a7a8b1d8e947023f2100010050ddc9a0f41634d94822b2a9
6
+ metadata.gz: b0b758fce7c61229b6dd32c24f62cec09d972c16a1db73531e4ed504fe6275a35aaa7dae0c9d1d38c918bdbfd741189b85f1f4b6b589460be69404cc0662787b
7
+ data.tar.gz: 9d9fb2335ff906834231c7dd23669a6faf9550ec9419d8473933d92d4c12d4f2d751b8f12358be77e204889126f9962236f6c0c60cf7c1c7b5cbe4cc6bc9fe84
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: ["2.5", "2.6", "2.7"]
11
+ ruby: ["2.5", "2.6", "2.7", "3.0"]
12
12
  os: [ubuntu-latest, macos-latest]
13
13
  experimental: [false]
14
14
  # include:
@@ -12,9 +12,7 @@ jobs:
12
12
  fail-fast: false
13
13
  matrix:
14
14
  ruby: ["2.7"]
15
- os: [ubuntu-latest, macos-latest]
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:native
55
- bundle exec rake publish:non_native || true
47
+ bundle exec rake publish:non_native
@@ -12,7 +12,12 @@ AllCops:
12
12
  TargetRubyVersion: 2.5
13
13
  NewCops: enable
14
14
  SuggestExtensions: false
15
+ Exclude:
16
+ - pkg/**/*
17
+ - tmp/**/*
15
18
 
16
19
  Metrics/BlockLength:
17
20
  Exclude:
18
21
  - spec/**/*
22
+ - Rakefile
23
+ - Gemfile
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
@@ -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 Rubygems"
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
- push_to_rubygems(g)
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
@@ -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
 
@@ -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, "@default_country_code");
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, "@default_country_code");
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 rb_set_default_country_code(VALUE self, VALUE str_code) {
72
- return rb_iv_set(self, "@default_country_code", str_code);
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 rb_get_default_country_code(VALUE self) { return rb_iv_get(self, "@default_country_code"); }
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, "@default_country_code");
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, "@default_country_code", rb_str_new("ZZ", 2));
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
- "default_country_code=", reinterpret_cast<VALUE (*)(...)>(rb_set_default_country_code), 1);
355
- rb_define_module_function(rb_mMiniPhone, "default_country_code",
356
- reinterpret_cast<VALUE (*)(...)>(rb_get_default_country_code), 0);
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);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniPhone
4
- VERSION = '0.1.5'
4
+ VERSION = '1.0.1'
5
5
  end
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.5
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-05 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.