torasup 0.2.3 → 0.3.0

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: e43252b18fcb1d7ec3f40b59c052070e6bd5a094a2f3c9fe6ab1664a5bcd4328
4
- data.tar.gz: a47786c4fb8572f59e0ebad7c7d56ce94ca1746b9e11b55fae917d7bf3eb57ec
3
+ metadata.gz: eda949d2ce20b1045480ea61d4c961cd2dc382d4642f3c0a6db6e1f1e5c24d4f
4
+ data.tar.gz: 65bb3f5b2db59ac77f15560b6bf750f7b3ec3dece345bad5f7fb055d48ed8aa5
5
5
  SHA512:
6
- metadata.gz: 7d6de732a9328ffef5548029bfe3e25c959a14ad8f77cd0e042e0bb8505aa92b8ea6d08e7dbd12a25b0803c1a4517112810a1800dfa9edd3b2c89aeac3c4790b
7
- data.tar.gz: bc703705251a160ab725d55c4c281502a5c0c5e528ba97d6d129dc7edc9087f57fe44226e3595a7502d59cbac61e4a83ae81bf5bbd5739834e97407a85ae6c1e
6
+ metadata.gz: 34c1fbddf8ee267a62216a9d609b9603a0ebac45937f372a6295d48f8226ed11b4c1df19a424b91e0a0253938b6c0fc6dcef8162e50580885a3d8527490c4ca9
7
+ data.tar.gz: d98791b3e7f302b79976efbcbe544a0af66f798a183cd98b75d34c37af45136b91389d2b8fd26430f58cf62cc524ae252e45f9ad3f34837116e2983d6c466de7
@@ -0,0 +1,35 @@
1
+ name: Build
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+
13
+ - name: Set up Ruby
14
+ uses: actions/setup-ruby@v1
15
+ with:
16
+ ruby-version: 2.7.x
17
+
18
+ - name: Install Dependencies
19
+ run: |
20
+ gem install bundler
21
+ bundle install --jobs 4 --retry 3
22
+
23
+ - name: Deploy
24
+ if: github.ref == 'refs/heads/master' && !contains(github.event.commits[0].message, '[skip deploy]')
25
+ env:
26
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27
+ GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
28
+
29
+ run: |
30
+ git config --global user.email "dwilkie@gmail.com"
31
+ git config --global user.name "David Wilkie"
32
+ mkdir -p ~/.gem
33
+ echo -e "---\r\n:rubygems_api_key: $GEM_HOST_API_KEY" > ~/.gem/credentials
34
+ chmod 0600 ~/.gem/credentials
35
+ bundle exec rake release
@@ -1 +1 @@
1
- ruby 2.6.4
1
+ ruby 2.7.1
data/Gemfile CHANGED
@@ -1,9 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github) do |repo_name|
4
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
- "https://github.com/#{repo_name}.git"
6
- end
1
+ source "https://rubygems.org"
7
2
 
8
3
  # Specify your gem's dependencies in torasup.gemspec
9
4
  gemspec
data/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  Retuns metadata about a phone number such as operator info, area code and more.
4
4
 
5
- [![Build Status](https://travis-ci.org/somleng/torasup.png)](https://travis-ci.org/somleng/torasup)
6
- [![Test Coverage](https://api.codeclimate.com/v1/badges/5598e3554335eb385bd8/test_coverage)](https://codeclimate.com/github/somleng/torasup/test_coverage)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/5598e3554335eb385bd8/maintainability)](https://codeclimate.com/github/somleng/torasup/maintainability)
5
+ ![Build](https://github.com/somleng/torasup/workflows/Build/badge.svg)
8
6
 
9
7
  ## Installation
10
8
 
@@ -11,7 +11,8 @@ require "torasup/location"
11
11
 
12
12
  module Torasup
13
13
  ALL_PREFIXES_KEYS = ["*", "all"].freeze
14
- DEFAULT_PREFIXES = ("10".."99").to_a.freeze
14
+ DEFAULT_OPERATOR_PREFIX_MIN = "10".freeze
15
+ DEFAULT_OPERATOR_PREFIX_MAX = "99".freeze
15
16
 
16
17
  module Test
17
18
  autoload :Helpers, "torasup/test/helpers"
@@ -26,7 +27,9 @@ module Torasup
26
27
  @international_dialing_codes = {}
27
28
  ISO3166::Country.all.each do |country|
28
29
  dialing_code = country.country_code
29
- @international_dialing_codes[dialing_code] = country.alpha2 if !@international_dialing_codes[dialing_code] || configuration.default_countries.include?(country.alpha2)
30
+ if !@international_dialing_codes[dialing_code] || configuration.default_countries.include?(country.alpha2)
31
+ @international_dialing_codes[dialing_code] = country.alpha2
32
+ end
30
33
  end
31
34
  end
32
35
 
@@ -79,7 +82,9 @@ module Torasup
79
82
  ).merge(prefix_data)
80
83
 
81
84
  @pstn_prefixes[operator_prefix] = prefix_properties
82
- @registered_pstn_prefixes[operator_prefix] = prefix_properties if operator_registered?(country_id, operator)
85
+ if operator_registered?(country_id, operator)
86
+ @registered_pstn_prefixes[operator_prefix] = prefix_properties
87
+ end
83
88
  end
84
89
  end
85
90
  end
@@ -140,8 +145,13 @@ module Torasup
140
145
  def operator_mobile_prefixes(country_id, operator)
141
146
  full_prefixes = {}
142
147
  operator_data = operator_data(country_id, operator)
143
- prefixes = DEFAULT_PREFIXES if operator_data["prefixes"].is_a?(String) && ALL_PREFIXES_KEYS.include?(operator_data["prefixes"])
144
- prefixes ||= operator_data["prefixes"] || []
148
+ if operator_data["prefixes"].is_a?(String) && ALL_PREFIXES_KEYS.include?(operator_data["prefixes"])
149
+ operator_prefix_min = country_data(country_id).fetch("operator_prefix_min", DEFAULT_OPERATOR_PREFIX_MIN)
150
+ operator_prefix_max = country_data(country_id).fetch("operator_prefix_max", DEFAULT_OPERATOR_PREFIX_MAX)
151
+ prefixes = (operator_prefix_min.to_s..operator_prefix_max).to_a
152
+ end
153
+ prefixes ||= operator_data["prefixes"]
154
+ prefixes ||= []
145
155
  mobile_prefixes = array_to_hash(prefixes)
146
156
  mobile_prefixes.each do |mobile_prefix, prefix_metadata|
147
157
  full_prefixes[operator_full_prefix(country_id, mobile_prefix)] = {
@@ -233,6 +233,12 @@ br:
233
233
  # https://en.wikipedia.org/wiki/List_of_mobile_network_operators_of_the_Americas#Brazil
234
234
  international_dialing_code: "55"
235
235
 
236
+ in:
237
+ # https://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
238
+ international_dialing_code: "91"
239
+ operator_prefix_min: "6000"
240
+ operator_prefix_max: "9999"
241
+
236
242
  gh:
237
243
  international_dialing_code: "233"
238
244
  # https://en.m.wikipedia.org/wiki/Telephone_numbers_in_Ghana
@@ -17,6 +17,7 @@ module Torasup
17
17
 
18
18
  def parse_phone_number(number)
19
19
  raise "Not a vaild number" unless Phony.plausible?(number)
20
+
20
21
  @number = Phony.normalize(number)
21
22
  number_parts = split_number
22
23
  @country_code = number_parts.shift
@@ -1,3 +1,3 @@
1
1
  module Torasup
2
- VERSION = "0.2.3".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -17,6 +17,14 @@ kh:
17
17
  - '87'
18
18
  area_code_prefixes:
19
19
  - '45'
20
+
21
+ in:
22
+ operators:
23
+ imimobile:
24
+ metadata:
25
+ name: "IMImobile"
26
+ prefixes: "*"
27
+
20
28
  br:
21
29
  operators:
22
30
  mundivox:
@@ -91,11 +91,17 @@ module Torasup
91
91
 
92
92
  it_should_behave_like "an operator"
93
93
 
94
- it "should handle wildcard prefixes" do
94
+ it "handles default prefixes" do
95
95
  torasup_number = Torasup::PhoneNumber.new("5582999489999")
96
96
  operator = torasup_number.operator
97
97
  expect(operator.id).to eq("mundivox")
98
98
  end
99
+
100
+ it "handles long prefixes" do
101
+ torasup_number = Torasup::PhoneNumber.new("919560234567")
102
+ operator = torasup_number.operator
103
+ expect(operator.id).to eq("imimobile")
104
+ end
99
105
  end
100
106
 
101
107
  context "with multiple configuration files" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torasup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Wilkie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: countries
@@ -116,11 +116,11 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".github/workflows/build.yml"
119
120
  - ".gitignore"
120
121
  - ".rspec"
121
122
  - ".rubocop.yml"
122
123
  - ".tool-versions"
123
- - ".travis.yml"
124
124
  - Gemfile
125
125
  - LICENSE.txt
126
126
  - README.md
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 3.0.3
167
+ rubygems_version: 3.1.2
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: '"Retuns metadata about a phone number such as operator, area code and more"'
@@ -1,11 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- env:
4
- global:
5
- - START_SIMPLECOV=1
6
- addons:
7
- code_climate:
8
- repo_token:
9
- secure: "Xk7T8ZyorwO85WfXC7OB2HfIM9Z/GO85u97P1qwXukL1ZjjDffr3mzhh706AVA9JPpTQGDbLNU5aStxX6NVLjBXyflvEpSGmYLl0aHDVikcNvZA/jBGlIfJH/6/V5bJA11X3V2/9FeO5l2fPkusWxbcpAIowe7xclDXfujdoNGk="
10
- after_success:
11
- - bundle exec codeclimate-test-reporter