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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b642cc5d3f7aefc9425b2ae5325d4356fda5d9f265bf60427a2c296ba07e1352
4
- data.tar.gz: b1a3ab552287ee888afbc929920d7297954dcc100f67a11e9cbd13465f9ecdc7
3
+ metadata.gz: 1ba98d228690a351f83d4043aab01f347db1ff2ef8f42ae9a7467450380db748
4
+ data.tar.gz: 0233b6c5b8a0fbeccc2a5c2aaa3634efd93c6a77f06364a79f67664947fac7f7
5
5
  SHA512:
6
- metadata.gz: 38c53dd03121910869e9220e5222c5ea28a518106d6bb00ae1c11b9798b2503ba55622d23ccfbd4fb99a3d87db77f78f77644bc9bce453ead8249d2400d3ec9a
7
- data.tar.gz: d656aec662265ffaaa6342b1383867459725cf52b8af5f86fe6189970e434d5701ca438301a2eee6df012a66d6a486406e4652cfe8002c97364ef1cb166720f6
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.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
 
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
- 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)] = {
@@ -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'
@@ -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.2".freeze
2
+ VERSION = "0.3.3".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:
@@ -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 "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.2
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: 2019-09-17 00:00:00.000000000 Z
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.0.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