torasup 0.2.3 → 0.3.0
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/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 +6 -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/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: eda949d2ce20b1045480ea61d4c961cd2dc382d4642f3c0a6db6e1f1e5c24d4f
|
4
|
+
data.tar.gz: 65bb3f5b2db59ac77f15560b6bf750f7b3ec3dece345bad5f7fb055d48ed8aa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
[](https://codeclimate.com/github/somleng/torasup/test_coverage)
|
7
|
-
[](https://codeclimate.com/github/somleng/torasup/maintainability)
|
5
|
+

|
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
@@ -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
|
data/lib/torasup/phone_number.rb
CHANGED
data/lib/torasup/version.rb
CHANGED
@@ -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.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-
|
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.
|
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"'
|
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
|