torasup 0.2.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +35 -0
- data/.tool-versions +1 -1
- data/Gemfile +1 -6
- data/README.md +1 -3
- data/lib/torasup.rb +15 -5
- data/lib/torasup/data/pstn.yaml +57 -0
- data/lib/torasup/phone_number.rb +1 -0
- data/lib/torasup/version.rb +1 -1
- data/spec/support/custom_pstn.yaml +8 -0
- data/spec/support/pstn_spec.yaml +42 -0
- data/spec/torasup/operator_spec.rb +7 -1
- metadata +4 -4
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ba98d228690a351f83d4043aab01f347db1ff2ef8f42ae9a7467450380db748
|
4
|
+
data.tar.gz: 0233b6c5b8a0fbeccc2a5c2aaa3634efd93c6a77f06364a79f67664947fac7f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a65786279683a36c75a4ad7349612b60085bc91c046f529fe6ff5ddf0c0b782c2e5a7b4a84621cd7605695d4e5dfbda53de2a3911f3c4ef70137776374442f8
|
7
|
+
data.tar.gz: 07f0dbbf53c4bf63316f1c27e3776401efcf314feb6aaa4ef7b84ee90fba7fe31674bb78a18df3295ad00be177fe09ba9454f5da9ba7d7bfb3b6549a827145e1
|
@@ -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
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 2.7.1
|
data/Gemfile
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
source
|
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
|
-
|
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
|
|
data/lib/torasup.rb
CHANGED
@@ -11,7 +11,8 @@ require "torasup/location"
|
|
11
11
|
|
12
12
|
module Torasup
|
13
13
|
ALL_PREFIXES_KEYS = ["*", "all"].freeze
|
14
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
144
|
-
|
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)] = {
|
data/lib/torasup/data/pstn.yaml
CHANGED
@@ -232,3 +232,60 @@ br:
|
|
232
232
|
# https://en.wikipedia.org/wiki/Telecommunications_in_Brazil
|
233
233
|
# https://en.wikipedia.org/wiki/List_of_mobile_network_operators_of_the_Americas#Brazil
|
234
234
|
international_dialing_code: "55"
|
235
|
+
|
236
|
+
mx:
|
237
|
+
international_dialing_code: "52"
|
238
|
+
|
239
|
+
gl:
|
240
|
+
international_dialing_code: "299"
|
241
|
+
|
242
|
+
gt:
|
243
|
+
international_dialing_code: "502"
|
244
|
+
|
245
|
+
in:
|
246
|
+
# https://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
|
247
|
+
international_dialing_code: "91"
|
248
|
+
operator_prefix_min: "6000"
|
249
|
+
operator_prefix_max: "9999"
|
250
|
+
|
251
|
+
gh:
|
252
|
+
international_dialing_code: "233"
|
253
|
+
# https://en.m.wikipedia.org/wiki/Telephone_numbers_in_Ghana
|
254
|
+
operators:
|
255
|
+
globacom:
|
256
|
+
# https://en.wikipedia.org/wiki/Glo_(company)
|
257
|
+
metadata:
|
258
|
+
name: "Globacom"
|
259
|
+
prefixes:
|
260
|
+
- '23'
|
261
|
+
mtn:
|
262
|
+
# https://en.wikipedia.org/wiki/MTN_Group
|
263
|
+
metadata:
|
264
|
+
name: "MTN"
|
265
|
+
prefixes:
|
266
|
+
- '24'
|
267
|
+
- '54'
|
268
|
+
- '55'
|
269
|
+
- '59'
|
270
|
+
airtel_tigo:
|
271
|
+
# https://en.wikipedia.org/wiki/Airtel_Africa#Tigo_Ghana_merger
|
272
|
+
metadata:
|
273
|
+
name: "AirtelTigo"
|
274
|
+
prefixes:
|
275
|
+
- '27'
|
276
|
+
- '57'
|
277
|
+
- '26'
|
278
|
+
- '56'
|
279
|
+
expresso:
|
280
|
+
# https://en.wikipedia.org/wiki/Expresso_Telecom
|
281
|
+
metadata:
|
282
|
+
name: "Expresso"
|
283
|
+
prefixes:
|
284
|
+
- '28'
|
285
|
+
vodafone:
|
286
|
+
# https://en.wikipedia.org/wiki/Vodafone_Ghana
|
287
|
+
metadata:
|
288
|
+
name: "Vodafone"
|
289
|
+
prefixes:
|
290
|
+
- '20'
|
291
|
+
- '50'
|
data/lib/torasup/phone_number.rb
CHANGED
data/lib/torasup/version.rb
CHANGED
data/spec/support/pstn_spec.yaml
CHANGED
@@ -187,3 +187,45 @@ sl:
|
|
187
187
|
- '30'
|
188
188
|
- '77'
|
189
189
|
- '88'
|
190
|
+
|
191
|
+
gh:
|
192
|
+
prefix: "233"
|
193
|
+
local_number: "2437103"
|
194
|
+
operators:
|
195
|
+
# https://en.m.wikipedia.org/wiki/Telephone_numbers_in_Ghana
|
196
|
+
globacom:
|
197
|
+
# https://en.wikipedia.org/wiki/Glo_(company)
|
198
|
+
assertions:
|
199
|
+
name: "Globacom"
|
200
|
+
prefixes:
|
201
|
+
- '23'
|
202
|
+
mtn:
|
203
|
+
# https://en.wikipedia.org/wiki/MTN_Group
|
204
|
+
assertions:
|
205
|
+
name: "MTN"
|
206
|
+
prefixes:
|
207
|
+
- '24'
|
208
|
+
- '54'
|
209
|
+
- '55'
|
210
|
+
airtel_tigo:
|
211
|
+
# https://en.wikipedia.org/wiki/Airtel_Africa#Tigo_Ghana_merger
|
212
|
+
assertions:
|
213
|
+
name: "AirtelTigo"
|
214
|
+
prefixes:
|
215
|
+
- '27'
|
216
|
+
- '57'
|
217
|
+
- '26'
|
218
|
+
- '56'
|
219
|
+
expresso:
|
220
|
+
# https://en.wikipedia.org/wiki/Expresso_Telecom
|
221
|
+
assertions:
|
222
|
+
name: "Expresso"
|
223
|
+
prefixes:
|
224
|
+
- '28'
|
225
|
+
vodafone:
|
226
|
+
# https://en.wikipedia.org/wiki/Vodafone_Ghana
|
227
|
+
assertions:
|
228
|
+
name: "Vodafone"
|
229
|
+
prefixes:
|
230
|
+
- '20'
|
231
|
+
- '50'
|
@@ -91,11 +91,17 @@ module Torasup
|
|
91
91
|
|
92
92
|
it_should_behave_like "an operator"
|
93
93
|
|
94
|
-
it "
|
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.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Wilkie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-06 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.
|
167
|
+
rubygems_version: 3.1.4
|
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"'
|
data/.travis.yml
DELETED
@@ -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
|