torasup 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/Gemfile +5 -0
- data/README.md +16 -0
- data/lib/torasup/data/pstn.yaml +38 -1
- data/lib/torasup/version.rb +1 -1
- data/spec/support/pstn_spec.yaml +36 -1
- data/spec/torasup/location_spec.rb +1 -1
- data/spec/torasup_spec.rb +12 -3
- data/torasup.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a859f5d8854bd2f0529cffaeb722f2b21321c06
|
4
|
+
data.tar.gz: 4ce0d87b60165ce4823c6362f94e173d1c004287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2de767f9311bf72be0ca50a982278eb1877761620b92d9c8698b5bb476c336b5f480fbe1b6c28760ddc0e2f313a6adbaba0602b83fc19b08119601f3452483c5
|
7
|
+
data.tar.gz: f335bbc17621224b0a3a14f285ee8fabfe7d1a38882d302ecdcfca5d7bd7784e6d1ac72f047a777f6a9f59fe8d7957071cc71b898a4cd7dfff89c48ec04e3fb4
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -137,6 +137,22 @@ op.my_custom_boolean_property
|
|
137
137
|
=> true
|
138
138
|
```
|
139
139
|
|
140
|
+
It's also possible to specify multiple custom pstn files independently of each other.
|
141
|
+
|
142
|
+
E.g.
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
Torasup.configure do |config|
|
146
|
+
config.custom_pstn_data_file = "my_pstn_data.yaml"
|
147
|
+
end
|
148
|
+
|
149
|
+
Torasup.configure do |config|
|
150
|
+
config.custom_pstn_data_file = "my_pstn_data_2.yaml"
|
151
|
+
end
|
152
|
+
```
|
153
|
+
|
154
|
+
This will merge `my_pstn_data.yaml` and `my_pstn_data_2.yaml` together.
|
155
|
+
|
140
156
|
### Registering Operators
|
141
157
|
|
142
158
|
Sometimes you may only be interested in certain prefixes. For example let's say you want to match phone numbers from a certain operator from the database. You can register operators for this purpose. e.g.
|
data/lib/torasup/data/pstn.yaml
CHANGED
@@ -61,7 +61,10 @@ kh:
|
|
61
61
|
name: "Mobitel"
|
62
62
|
prefixes:
|
63
63
|
- '11'
|
64
|
-
- '12'
|
64
|
+
- '12':
|
65
|
+
subscriber_number_min: 1000000
|
66
|
+
subscriber_number_max: 9999999
|
67
|
+
subscriber_number_pattern: "([2-9]\\d{5})|(1\\d{6})"
|
65
68
|
- '14'
|
66
69
|
- '17'
|
67
70
|
- '61'
|
@@ -165,3 +168,37 @@ kh:
|
|
165
168
|
- '4'
|
166
169
|
- '7'
|
167
170
|
- '8'
|
171
|
+
so:
|
172
|
+
# https://en.wikipedia.org/wiki/Telecommunications_in_Somaliland
|
173
|
+
international_dialing_code: "252"
|
174
|
+
operators:
|
175
|
+
telesom:
|
176
|
+
# https://en.wikipedia.org/wiki/Telecommunications_in_Somaliland
|
177
|
+
metadata:
|
178
|
+
name: "Telesom"
|
179
|
+
prefixes:
|
180
|
+
- '63'
|
181
|
+
golis:
|
182
|
+
# https://en.wikipedia.org/wiki/Golis_Telecom_Somalia
|
183
|
+
metadata:
|
184
|
+
name: "Golis"
|
185
|
+
prefixes:
|
186
|
+
- '90'
|
187
|
+
nationlink:
|
188
|
+
# https://en.wikipedia.org/wiki/NationLink_Telecom
|
189
|
+
metadata:
|
190
|
+
name: "NationLink"
|
191
|
+
prefixes:
|
192
|
+
- '69'
|
193
|
+
somtel:
|
194
|
+
# https://en.wikipedia.org/wiki/Somtel
|
195
|
+
metadata:
|
196
|
+
name: "Somtel"
|
197
|
+
prefixes:
|
198
|
+
- '65'
|
199
|
+
hormuud:
|
200
|
+
# https://en.wikipedia.org/wiki/Hormuud_Telecom
|
201
|
+
metadata:
|
202
|
+
name: "Hormuud"
|
203
|
+
prefixes:
|
204
|
+
- '61'
|
data/lib/torasup/version.rb
CHANGED
data/spec/support/pstn_spec.yaml
CHANGED
@@ -55,7 +55,7 @@ kh:
|
|
55
55
|
name: Mobitel
|
56
56
|
prefixes:
|
57
57
|
- '11'
|
58
|
-
- '12'
|
58
|
+
- '12': "1234567"
|
59
59
|
- '14'
|
60
60
|
- '17'
|
61
61
|
- '61'
|
@@ -133,3 +133,38 @@ kh:
|
|
133
133
|
- '4'
|
134
134
|
- '7'
|
135
135
|
- '8'
|
136
|
+
so:
|
137
|
+
prefix: "252"
|
138
|
+
local_number: "2345678"
|
139
|
+
operators:
|
140
|
+
# https://en.wikipedia.org/wiki/Telecommunications_in_Somaliland
|
141
|
+
telesom:
|
142
|
+
# https://en.wikipedia.org/wiki/Telesom
|
143
|
+
assertions:
|
144
|
+
name: "Telesom"
|
145
|
+
prefixes:
|
146
|
+
- '63'
|
147
|
+
golis:
|
148
|
+
# https://en.wikipedia.org/wiki/Golis_Telecom_Somalia
|
149
|
+
assertions:
|
150
|
+
name: "Golis"
|
151
|
+
prefixes:
|
152
|
+
- '90'
|
153
|
+
nationlink:
|
154
|
+
# https://en.wikipedia.org/wiki/NationLink_Telecom
|
155
|
+
assertions:
|
156
|
+
name: "NationLink"
|
157
|
+
prefixes:
|
158
|
+
- '69'
|
159
|
+
somtel:
|
160
|
+
# https://en.wikipedia.org/wiki/Somtel
|
161
|
+
assertions:
|
162
|
+
name: "Somtel"
|
163
|
+
prefixes:
|
164
|
+
- '65'
|
165
|
+
hormuud:
|
166
|
+
# https://en.wikipedia.org/wiki/Hormuud_Telecom
|
167
|
+
assertions:
|
168
|
+
name: "Hormuud"
|
169
|
+
prefixes:
|
170
|
+
- '61'
|
@@ -7,7 +7,7 @@ module Torasup
|
|
7
7
|
with_pstn_data(options) do |country_id, country_data|
|
8
8
|
default_assertions = {"country_id" => country_id}
|
9
9
|
location_assertions[country_id] = {}
|
10
|
-
country_data["area_codes"].each do |area_code, area|
|
10
|
+
(country_data["area_codes"] || []).each do |area_code, area|
|
11
11
|
location_assertions[country_id][area_code] = default_assertions.merge("area_code" => area_code, "area" => area)
|
12
12
|
end
|
13
13
|
end
|
data/spec/torasup_spec.rb
CHANGED
@@ -10,9 +10,18 @@ describe Torasup do
|
|
10
10
|
prefix = assertions["country_code"].to_s + assertions["area_code"].to_s + assertions["prefix"].to_s
|
11
11
|
prefix_metadata = prefixes[prefix]
|
12
12
|
local_number = assertions["local_number"]
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
if subscriber_number_min = prefix_metadata["subscriber_number_min"]
|
15
|
+
expect(local_number.to_i).to be >= subscriber_number_min
|
16
|
+
end
|
17
|
+
|
18
|
+
if subscriber_number_max = prefix_metadata["subscriber_number_max"]
|
19
|
+
expect(local_number.to_i).to be <= subscriber_number_max
|
20
|
+
end
|
21
|
+
|
22
|
+
if subscriber_number_pattern = prefix_metadata["subscriber_number_pattern"]
|
23
|
+
expect(local_number).to match(Regexp.new(subscriber_number_pattern))
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
data/torasup.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
21
|
gem.add_runtime_dependency "countries", '>= 1.1.0'
|
22
|
-
gem.add_runtime_dependency "phony", '>= 2.
|
22
|
+
gem.add_runtime_dependency "phony", '>= 2.15.43'
|
23
23
|
gem.add_runtime_dependency "deep_merge"
|
24
24
|
|
25
25
|
gem.add_development_dependency "rspec"
|
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.1.
|
4
|
+
version: 0.1.1
|
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: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.15.43
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.15.43
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: deep_merge
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.8
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: '"Retuns metadata about a phone number such as operator, area code and more"'
|