mobile-subscriber 1.0.0.alpha1 → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mobile-subscriber.rb +2 -0
- data/lib/mobile_subscriber/detection/from_msisdn_http_request_header.rb +4 -22
- data/lib/mobile_subscriber/detection/from_x_nokia_msisdn_http_request_header.rb +10 -0
- data/lib/mobile_subscriber/detection/from_x_up_calling_line_id_http_request_header.rb +3 -5
- data/lib/mobile_subscriber/detection/from_x_up_subno_http_request_header.rb +12 -3
- data/lib/mobile_subscriber/detection/from_x_wap_msisdn_http_request_header.rb +37 -0
- data/lib/mobile_subscriber/detection/from_x_ztgo_beareraddress_http_request_header.rb +36 -0
- data/lib/mobile_subscriber/dictionaries/dialing_and_country_codes.rb +4 -1
- data/lib/mobile_subscriber/isdn.rb +3 -0
- data/lib/mobile_subscriber/version.rb +1 -1
- data/spec/detection/from_msisdn_http_request_header_spec.rb +10 -20
- data/spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb +30 -0
- data/spec/detection/from_x_up_subno_http_request_header_spec.rb +43 -0
- data/spec/detection/from_x_wap_msisdn_http_request_header_spec.rb +32 -0
- data/spec/factories/requests.rb +52 -2
- data/spec/models/isdn_spec.rb +18 -166
- data/spec/shared_examples/of_msisdn_detection_from_http_request.rb +55 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80a1f00c8af97774375ce292825d1ccd16125ea2
|
4
|
+
data.tar.gz: 53b1c2b1cf5fa8d65665abd9c59be800d71d702e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ef14f604142edb0243bb764e09ab3da9bc36a938175dd10dae93c9be72977bd7f68a5db57db4c076efd0150fedc28ab5f5ef1a83ef8bcc93315bd3a0b650a4
|
7
|
+
data.tar.gz: 00eee445ece94fa6445e270ba1902645669cc0e8d096a57199e9dc501be9eac3bb60f119093f43a9e4c5233d2fa9463b6d38300ed08d224269dcea7feb0ddcdd
|
data/lib/mobile-subscriber.rb
CHANGED
@@ -13,7 +13,9 @@ module MobileSubscriber
|
|
13
13
|
autoload :FromXUpCallingLineIdHttpRequestHeader
|
14
14
|
autoload :FromXUpChMsisdnHttpRequestHeader
|
15
15
|
autoload :FromXUpSubnoHttpRequestHeader
|
16
|
+
autoload :FromXWapMsisdnHttpRequestHeader
|
16
17
|
autoload :FromXWapSesiones3gMdnHttpRequestHeader
|
18
|
+
autoload :FromXZtgoBeareraddressHttpRequestHeader
|
17
19
|
autoload :HttpRequestInfo
|
18
20
|
end
|
19
21
|
end
|
@@ -5,14 +5,8 @@ module MobileSubscriber::Detection
|
|
5
5
|
# Módulo que provee métodos de detección y validacion para MSISDN por el
|
6
6
|
# header de HTTP 'Msisdn':
|
7
7
|
# - Claro Brasil
|
8
|
-
# - Claro Chile
|
9
|
-
# - Claro Colombia
|
10
|
-
# - Claro Costa Rica
|
11
8
|
# - Claro República Dominicana
|
12
9
|
# - Claro Ecuador
|
13
|
-
# - Claro El Salvador
|
14
|
-
# - Claro Nicaragua
|
15
|
-
# - Claro Panamá
|
16
10
|
# - Claro Paraguay
|
17
11
|
module FromMsisdnHttpRequestHeader
|
18
12
|
|
@@ -30,25 +24,13 @@ module MobileSubscriber::Detection
|
|
30
24
|
network_id_tuple = case country_code
|
31
25
|
when 'BR' # Claro Brasil
|
32
26
|
# TODO: Determine (if possible) the MNC (05, 38)
|
33
|
-
{ mcc: "724", mnc: "05"
|
34
|
-
when 'CL' # Claro Chile
|
35
|
-
{ mcc: "730", mnc: "03" }
|
36
|
-
when 'CO' # Claro Colombia
|
37
|
-
{ mcc: "732", mnc: "101" }
|
38
|
-
when 'CR' # Claro Costa Rica
|
39
|
-
{ mcc: "712", mnc: "03" }
|
27
|
+
{ mcc: "724", mnc: "05" }
|
40
28
|
when 'DO' # Claro Dominicana:
|
41
|
-
{ mcc: "370", mnc: "02"
|
29
|
+
{ mcc: "370", mnc: "02" }
|
42
30
|
when 'EC' # Claro Ecuador:
|
43
|
-
{ mcc: "740", mnc: "01"
|
44
|
-
when 'SV' # Claro El Salvador:
|
45
|
-
{ mcc: "706", mnc: "01" }
|
46
|
-
when 'NI' # Claro Nicaragua:
|
47
|
-
{ mcc: "710", mnc: "21" }
|
48
|
-
when 'PA' # Claro Panamá:
|
49
|
-
{ mcc: "714", mnc: "03" }
|
31
|
+
{ mcc: "740", mnc: "01" }
|
50
32
|
when 'PY' # Claro Paraguay:
|
51
|
-
{ mcc: "744", mnc: "02"
|
33
|
+
{ mcc: "744", mnc: "02" }
|
52
34
|
end
|
53
35
|
|
54
36
|
# Return only if we identified the network:
|
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
|
2
3
|
module MobileSubscriber::Detection
|
3
4
|
|
4
5
|
# Módulo que provee métodos de deteccion y validacion para MSISDN's de:
|
5
6
|
# - Telcel México
|
6
7
|
# - Claro Argentina
|
8
|
+
# - Claro Costa Rica
|
7
9
|
# - Claro Guatemala
|
8
10
|
# - Claro Honduras
|
11
|
+
# - Claro Nicaragua
|
12
|
+
# - Claro El Salvador
|
9
13
|
module FromXNokiaMsisdnHttpRequestHeader
|
10
14
|
|
11
15
|
def extract_from_x_nokia_msisdn_http_request_header(http_request_info)
|
@@ -23,8 +27,14 @@ module MobileSubscriber::Detection
|
|
23
27
|
{ mcc: "334", mnc: "020" }
|
24
28
|
when 'GT' # Claro Guatemala:
|
25
29
|
{ mcc: "704", mnc: "01" }
|
30
|
+
when 'SV' # Claro El Salvador:
|
31
|
+
{ mcc: "706", mnc: "01" }
|
26
32
|
when 'HN' # Claro Honduras:
|
27
33
|
{ mcc: "708", mnc: "001" }
|
34
|
+
when 'NI' # Claro Nicaragua:
|
35
|
+
{ mcc: "710", mnc: "21" }
|
36
|
+
when 'CR' # Claro Costa Rica
|
37
|
+
{ mcc: "712", mnc: "03" }
|
28
38
|
when 'AR' # Claro Argentina:
|
29
39
|
{ mcc: "722", mnc: "330" }
|
30
40
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
|
2
3
|
module MobileSubscriber::Detection
|
3
4
|
|
4
5
|
# Módulo que provee métodos de deteccion y validacion para MSISDN por el
|
@@ -8,7 +9,6 @@ module MobileSubscriber::Detection
|
|
8
9
|
# - OI Brasil
|
9
10
|
# - Movistar México
|
10
11
|
# - Movistar Argentina
|
11
|
-
# - Movistar Ecuador
|
12
12
|
# - Movistar Perú
|
13
13
|
module FromXUpCallingLineIdHttpRequestHeader
|
14
14
|
|
@@ -25,10 +25,10 @@ module MobileSubscriber::Detection
|
|
25
25
|
network_id_tuple = case country_code
|
26
26
|
when 'PE'
|
27
27
|
if (via_header = http_request_info.headers['Via']).present? and via_header =~ /Comverse/i
|
28
|
-
# Claro Peru:
|
28
|
+
# Claro Peru: (IP's 190.113.x)
|
29
29
|
{ mcc: "716", mnc: "10" }
|
30
30
|
else
|
31
|
-
# Movistar Peru:
|
31
|
+
# Movistar Peru: (IP's 190.238.x)
|
32
32
|
{ mcc: "716", mnc: "06" }
|
33
33
|
end
|
34
34
|
when 'BR'
|
@@ -46,8 +46,6 @@ module MobileSubscriber::Detection
|
|
46
46
|
when 'AR' # Movistar Argentina:
|
47
47
|
# TODO: Determine (if possible) the MNC (010 or 070)
|
48
48
|
{ mcc: "722", mnc: "010" }
|
49
|
-
when 'EC' # Movistar Ecuador:
|
50
|
-
{ mcc: "740", mnc: "00" }
|
51
49
|
end
|
52
50
|
|
53
51
|
# Return only if we identified the network:
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
|
2
3
|
module MobileSubscriber::Detection
|
3
4
|
# Módulo que provee métodos de deteccion y validacion para MSISDN por el
|
4
|
-
# header de HTTP '
|
5
|
-
#
|
5
|
+
# header de HTTP 'X-Up-Subno':
|
6
|
+
# - Claro Colombia
|
7
|
+
# - Claro Panamá
|
8
|
+
# - Comcel Colombia
|
6
9
|
module FromXUpSubnoHttpRequestHeader
|
7
10
|
|
8
11
|
def extract_from_x_up_subno_http_request_header(http_request_info)
|
@@ -16,8 +19,14 @@ module MobileSubscriber::Detection
|
|
16
19
|
# Determine the Network Operator tuple (MCC + MNC):
|
17
20
|
# TODO: Validate IP ranges, additional headers, etc.
|
18
21
|
network_id_tuple = case country_code
|
19
|
-
when 'CO'
|
22
|
+
when 'CO'
|
23
|
+
# TODO: Discernir por ip/hostname
|
24
|
+
#{ mcc: "732", mnc: "101" } # Comcel Colombia
|
25
|
+
|
26
|
+
# Claro Colombia
|
20
27
|
{ mcc: "732", mnc: "101" }
|
28
|
+
when 'PA' # Claro Panamá:
|
29
|
+
{ mcc: "714", mnc: "03" }
|
21
30
|
end
|
22
31
|
|
23
32
|
# Return only if we identified the network:
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
|
3
|
+
module MobileSubscriber::Detection
|
4
|
+
|
5
|
+
# Módulo que provee métodos de detección y validacion para MSISDN por el
|
6
|
+
# header de HTTP 'X-Wap-Msisdn':
|
7
|
+
# - Claro Chile
|
8
|
+
module FromXWapMsisdnHttpRequestHeader
|
9
|
+
|
10
|
+
def extract_from_x_wap_msisdn_http_request_header(http_request_info)
|
11
|
+
if msisdn = http_request_info.headers['X-Wap-Msisdn'] and msisdn.length >= 8
|
12
|
+
|
13
|
+
country_code = (
|
14
|
+
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,2]] ||
|
15
|
+
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,3]]
|
16
|
+
)
|
17
|
+
|
18
|
+
# Determine the Network Operator tuple (MCC + MNC):
|
19
|
+
# TODO: Validate IP ranges, additional headers, etc.
|
20
|
+
network_id_tuple = case country_code
|
21
|
+
when 'CL' # Claro Chile
|
22
|
+
{ mcc: "730", mnc: "03" }
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return only if we identified the network:
|
26
|
+
if network_id_tuple.present?
|
27
|
+
{
|
28
|
+
id: msisdn,
|
29
|
+
mobile_country_code: network_id_tuple[:mcc],
|
30
|
+
mobile_network_code: network_id_tuple[:mnc],
|
31
|
+
http_request_info: http_request_info
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'mobile_subscriber/dictionaries/dialing_and_country_codes'
|
2
|
+
|
3
|
+
module MobileSubscriber::Detection
|
4
|
+
# Módulo que provee métodos de detección y validacion para MSISDN por el
|
5
|
+
# header de HTTP 'X-Ztgo-Beareraddress':
|
6
|
+
# - Movistar Ecuador
|
7
|
+
module FromXZtgoBeareraddressHttpRequestHeader
|
8
|
+
|
9
|
+
def extract_from_x_ztgo_beareraddress_http_request_header(http_request_info)
|
10
|
+
if msisdn = http_request_info.headers['X-Ztgo-Beareraddress'] and msisdn.length >= 8
|
11
|
+
|
12
|
+
country_code = (
|
13
|
+
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,2]] ||
|
14
|
+
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,3]]
|
15
|
+
)
|
16
|
+
|
17
|
+
# Determine the Network Operator tuple (MCC + MNC):
|
18
|
+
# TODO: Validate IP ranges, additional headers, etc.
|
19
|
+
network_id_tuple = case country_code
|
20
|
+
when 'EC' # Movistar Ecuador:
|
21
|
+
{ mcc: "740", mnc: "00" }
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return only if we identified the network:
|
25
|
+
if network_id_tuple.present?
|
26
|
+
{
|
27
|
+
id: msisdn,
|
28
|
+
mobile_country_code: network_id_tuple[:mcc],
|
29
|
+
mobile_network_code: network_id_tuple[:mnc],
|
30
|
+
http_request_info: http_request_info
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module MobileSubscriber
|
2
|
+
# See: http://countrycode.org/
|
2
3
|
# Diccionario de Dialing Country Codes => ISO country codes:
|
3
4
|
DIALING_COUNTRY_CODES = {
|
4
5
|
# Caribbean Islands' country codes are a mess!
|
@@ -6,13 +7,15 @@ module MobileSubscriber
|
|
6
7
|
'1829' => 'DO', # Dominican Republic Overlay 1
|
7
8
|
'1849' => 'DO', # Dominican Republic Overlay 2
|
8
9
|
|
10
|
+
'225' => 'CI', # Costa de Marfil
|
11
|
+
|
9
12
|
'501' => 'BZ', # Belize
|
10
13
|
'502' => 'GT', # Guatemala
|
11
14
|
'503' => 'SV', # El Salvador
|
12
15
|
'504' => 'HN', # Honduras
|
13
16
|
'505' => 'NI', # Nicaragua
|
14
17
|
'506' => 'CR', # Costa Rica
|
15
|
-
'507' => '
|
18
|
+
'507' => 'PA', # Panamá
|
16
19
|
'509' => 'HT', # Haití
|
17
20
|
'51' => 'PE', # Perú
|
18
21
|
'52' => 'MX', # México
|
@@ -14,6 +14,9 @@ module MobileSubscriber
|
|
14
14
|
extend MobileSubscriber::Detection::FromXUpCallingLineIdHttpRequestHeader
|
15
15
|
extend MobileSubscriber::Detection::FromXUpChMsisdnHttpRequestHeader
|
16
16
|
extend MobileSubscriber::Detection::FromXUpSubnoHttpRequestHeader
|
17
|
+
extend MobileSubscriber::Detection::FromXWapMsisdnHttpRequestHeader
|
18
|
+
extend MobileSubscriber::Detection::FromXWapSesiones3gMdnHttpRequestHeader
|
19
|
+
extend MobileSubscriber::Detection::FromXZtgoBeareraddressHttpRequestHeader
|
17
20
|
|
18
21
|
def initialize(attributes={})
|
19
22
|
@id = attributes.delete :id
|
@@ -28,26 +28,6 @@ describe MobileSubscriber::Detection::FromMsisdnHttpRequestHeader do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context "when given a request made from Claro Chile" do
|
32
|
-
let(:test_request) { build :mobile_request_from_claro_chile }
|
33
|
-
|
34
|
-
include_examples "of detection of msisdn from a valid chilean mobile network http request"
|
35
|
-
|
36
|
-
it "has a :mobile_network_code value of '03'" do
|
37
|
-
expect(subject[:mobile_network_code]).to eq '03'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when given a request made from Claro Colombia" do
|
42
|
-
let(:test_request) { build :mobile_request_from_claro_colombia }
|
43
|
-
|
44
|
-
include_examples "of detection of msisdn from a valid colombian mobile network http request"
|
45
|
-
|
46
|
-
it "has a :mobile_network_code value of '101'" do
|
47
|
-
expect(subject[:mobile_network_code]).to eq '101'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
31
|
context "when given a request made from Claro Ecuador" do
|
52
32
|
let(:test_request) { build :mobile_request_from_claro_ecuador }
|
53
33
|
|
@@ -58,6 +38,16 @@ describe MobileSubscriber::Detection::FromMsisdnHttpRequestHeader do
|
|
58
38
|
end
|
59
39
|
end
|
60
40
|
|
41
|
+
context "when given a request made from Claro República Dominicana" do
|
42
|
+
let(:test_request) { build :mobile_request_from_claro_dominican_republic }
|
43
|
+
|
44
|
+
include_examples "of detection of msisdn from a valid dominican mobile network http request"
|
45
|
+
|
46
|
+
it "has a :mobile_network_code value of '02'" do
|
47
|
+
expect(subject[:mobile_network_code]).to eq '02'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
61
51
|
end
|
62
52
|
|
63
53
|
end
|
@@ -35,6 +35,16 @@ describe MobileSubscriber::Detection::FromXNokiaMsisdnHttpRequestHeader do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
context "when given a request made from Claro Costa Rica" do
|
39
|
+
let(:test_request) { build :mobile_request_from_claro_costa_rica }
|
40
|
+
|
41
|
+
include_examples "of detection of msisdn from a valid costa rican mobile network http request"
|
42
|
+
|
43
|
+
it "has a :mobile_network_code value of '03'" do
|
44
|
+
expect(subject[:mobile_network_code]).to eq '03'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
38
48
|
context "when given a request made from Claro Guatemala" do
|
39
49
|
let(:test_request) { build :mobile_request_from_claro_guatemala }
|
40
50
|
|
@@ -54,6 +64,26 @@ describe MobileSubscriber::Detection::FromXNokiaMsisdnHttpRequestHeader do
|
|
54
64
|
expect(subject[:mobile_network_code]).to eq '001'
|
55
65
|
end
|
56
66
|
end
|
67
|
+
|
68
|
+
context "when given a request made from Claro Nicaragua" do
|
69
|
+
let(:test_request) { build :mobile_request_from_claro_nicaragua }
|
70
|
+
|
71
|
+
include_examples "of detection of msisdn from a valid nicaraguan mobile network http request"
|
72
|
+
|
73
|
+
it "has a :mobile_network_code value of '21'" do
|
74
|
+
expect(subject[:mobile_network_code]).to eq '21'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when given a request made from Claro El Salvador" do
|
79
|
+
let(:test_request) { build :mobile_request_from_claro_el_salvador }
|
80
|
+
|
81
|
+
include_examples "of detection of msisdn from a valid salvadoran mobile network http request"
|
82
|
+
|
83
|
+
it "has a :mobile_network_code value of '01'" do
|
84
|
+
expect(subject[:mobile_network_code]).to eq '01'
|
85
|
+
end
|
86
|
+
end
|
57
87
|
end
|
58
88
|
|
59
89
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MobileSubscriber::Detection::FromXUpSubnoHttpRequestHeader do
|
4
|
+
|
5
|
+
include described_class
|
6
|
+
|
7
|
+
let :test_request do
|
8
|
+
build :mobile_request_from_claro_colombia
|
9
|
+
end
|
10
|
+
|
11
|
+
let :test_request_info do
|
12
|
+
MobileSubscriber::Detection::HttpRequestInfo.new test_request.env
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "the returned object of self.extract_from_msisdn_http_request_header" do
|
16
|
+
|
17
|
+
subject do
|
18
|
+
extract_from_x_up_subno_http_request_header test_request_info
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when given a request made from Claro Colombia" do
|
22
|
+
|
23
|
+
include_examples "of detection of msisdn from a valid colombian mobile network http request"
|
24
|
+
|
25
|
+
it "has a :mobile_network_code value of '101'" do
|
26
|
+
expect(subject[:mobile_network_code]).to eq '101'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when given a request made from Claro Panamá" do
|
31
|
+
|
32
|
+
let(:test_request) { build :mobile_request_from_claro_panama }
|
33
|
+
|
34
|
+
include_examples "of detection of msisdn from a valid panamanian mobile network http request"
|
35
|
+
|
36
|
+
it "has a :mobile_network_code value of '03'" do
|
37
|
+
expect(subject[:mobile_network_code]).to eq '03'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MobileSubscriber::Detection::FromXWapMsisdnHttpRequestHeader do
|
4
|
+
|
5
|
+
include described_class
|
6
|
+
|
7
|
+
let :test_request do
|
8
|
+
build :mobile_request_from_claro_chile
|
9
|
+
end
|
10
|
+
|
11
|
+
let :test_request_info do
|
12
|
+
MobileSubscriber::Detection::HttpRequestInfo.new test_request.env
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "the returned object of self.extract_from_msisdn_http_request_header" do
|
16
|
+
|
17
|
+
subject do
|
18
|
+
extract_from_x_wap_msisdn_http_request_header test_request_info
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when given a request made from Claro Chile" do
|
22
|
+
|
23
|
+
include_examples "of detection of msisdn from a valid chilean mobile network http request"
|
24
|
+
|
25
|
+
it "has a :mobile_network_code value of '03'" do
|
26
|
+
expect(subject[:mobile_network_code]).to eq '03'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/factories/requests.rb
CHANGED
@@ -61,12 +61,22 @@ FactoryGirl.define do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
# TODO: Replace with a real example:
|
65
|
+
factory :mobile_request_from_claro_dominican_republic do
|
66
|
+
initialize_with do
|
67
|
+
new build(:common_mobile_request_env).merge(
|
68
|
+
"REMOTE_ADDR" => "181.37.104.3",
|
69
|
+
"HTTP_MSISDN" => "18098591800"
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
64
74
|
# http://ns.myip.ms/view/ip_owners/181034/Claro_Chile_S_a.html
|
65
75
|
factory :mobile_request_from_claro_chile do
|
66
76
|
initialize_with do
|
67
77
|
new build(:common_mobile_request_env).merge(
|
68
78
|
"REMOTE_ADDR" => "191.116.39.114",
|
69
|
-
"
|
79
|
+
"HTTP_X_WAP_MSISDN" => "56024440000"
|
70
80
|
)
|
71
81
|
end
|
72
82
|
end
|
@@ -75,7 +85,17 @@ FactoryGirl.define do
|
|
75
85
|
initialize_with do
|
76
86
|
new build(:common_mobile_request_env).merge(
|
77
87
|
"REMOTE_ADDR" => "200.26.137.100",
|
78
|
-
"
|
88
|
+
"HTTP_X_UP_SUBNO" => "57000000000"
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# TODO: Replace with a real example request:
|
94
|
+
factory :mobile_request_from_claro_costa_rica do
|
95
|
+
initialize_with do
|
96
|
+
new build(:common_mobile_request_env).merge(
|
97
|
+
"REMOTE_ADDR" => "186.26.126.37",
|
98
|
+
"HTTP_X_NOKIA_MSISDN" => "50600000000"
|
79
99
|
)
|
80
100
|
end
|
81
101
|
end
|
@@ -113,6 +133,26 @@ FactoryGirl.define do
|
|
113
133
|
end
|
114
134
|
end
|
115
135
|
|
136
|
+
# TODO: Replace with a real example request:
|
137
|
+
factory :mobile_request_from_claro_nicaragua do
|
138
|
+
initialize_with do
|
139
|
+
new build(:common_mobile_request_env).merge(
|
140
|
+
"REMOTE_ADDR" => "190.212.88.8",
|
141
|
+
"HTTP_X_NOKIA_MSISDN" => "50500000000"
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# TODO: Replace with a real example request:
|
147
|
+
factory :mobile_request_from_claro_el_salvador do
|
148
|
+
initialize_with do
|
149
|
+
new build(:common_mobile_request_env).merge(
|
150
|
+
"REMOTE_ADDR" => "190.86.139.225",
|
151
|
+
"HTTP_X_NOKIA_MSISDN" => "50300000000"
|
152
|
+
)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
116
156
|
# http://myip.ms/view/ip_owners/90291/America_Movil_Peru_S_a_c.html
|
117
157
|
factory :mobile_request_from_claro_peru do
|
118
158
|
initialize_with do
|
@@ -133,6 +173,16 @@ FactoryGirl.define do
|
|
133
173
|
end
|
134
174
|
end
|
135
175
|
|
176
|
+
# TODO: Replace with a real example:
|
177
|
+
factory :mobile_request_from_claro_panama do
|
178
|
+
initialize_with do
|
179
|
+
new build(:common_mobile_request_env).merge(
|
180
|
+
"REMOTE_ADDR" => "181.178.231.8",
|
181
|
+
"HTTP_X_UP_SUBNO" => "5070000000"
|
182
|
+
)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
136
186
|
# http://myip.ms/view/ip_owners/7424/Telefonica_Del_Peru_Saa.html
|
137
187
|
factory :mobile_request_from_movistar_peru do
|
138
188
|
initialize_with do
|
data/spec/models/isdn_spec.rb
CHANGED
@@ -44,7 +44,12 @@ describe MobileSubscriber::ISDN do
|
|
44
44
|
|
45
45
|
describe "detection from request headers" do
|
46
46
|
|
47
|
-
|
47
|
+
context "from a request made from a valid mobile network" do
|
48
|
+
|
49
|
+
subject do
|
50
|
+
described_class.new_from_request(build :mobile_request_from_telcel_mexico)
|
51
|
+
end
|
52
|
+
|
48
53
|
it "is not nil" do
|
49
54
|
expect(subject).not_to be_nil
|
50
55
|
end
|
@@ -56,186 +61,33 @@ describe MobileSubscriber::ISDN do
|
|
56
61
|
it "responds to #inspect with a string containing '(validated by HTTP)'" do
|
57
62
|
expect(subject.inspect).to match /\(validated by HTTP\)>\z/
|
58
63
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# of detection from a request made from a {Demonym} mobile network:
|
62
|
-
shared_examples "of detection from a request made from a mexican mobile network" do
|
63
|
-
it "responds to #id with a string starting with '52'" do
|
64
|
-
expect(subject.id).to match /\A52/
|
65
|
-
end
|
66
|
-
|
67
|
-
it "responds to #mobile_country_code with '334'" do
|
68
|
-
expect(subject.mobile_country_code).to eq '334'
|
69
|
-
end
|
70
|
-
|
71
|
-
it "responds to #dialing_code with '52'" do
|
72
|
-
expect(subject.dialing_code).to eq '52'
|
73
|
-
end
|
74
|
-
|
75
|
-
it "responds to #iso_3166_country_code with 'MX'" do
|
76
|
-
expect(subject.iso_3166_country_code).to eq 'MX'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
shared_examples "of detection from a request made from an argentinian mobile network" do
|
81
|
-
it "responds to #id with a string starting with '54'" do
|
82
|
-
expect(subject.id).to match /\A54/
|
83
|
-
end
|
84
|
-
|
85
|
-
it "responds to #mobile_country_code with '722'" do
|
86
|
-
expect(subject.mobile_country_code).to eq '722'
|
87
|
-
end
|
88
|
-
|
89
|
-
it "responds to #dialing_code with '54'" do
|
90
|
-
expect(subject.dialing_code).to eq '54'
|
91
|
-
end
|
92
|
-
|
93
|
-
it "responds to #iso_3166_country_code with 'AR'" do
|
94
|
-
expect(subject.iso_3166_country_code).to eq 'AR'
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
shared_examples "of detection from a request made from a brazilian mobile network" do
|
99
|
-
it "responds to #id with a string starting with '55'" do
|
100
|
-
expect(subject.id).to match /\A55/
|
101
|
-
end
|
102
|
-
|
103
|
-
it "responds to #mobile_country_code with '724'" do
|
104
|
-
expect(subject.mobile_country_code).to eq '724'
|
105
|
-
end
|
106
|
-
|
107
|
-
it "responds to #dialing_code with '55'" do
|
108
|
-
expect(subject.dialing_code).to eq '55'
|
109
|
-
end
|
110
|
-
|
111
|
-
it "responds to #iso_3166_country_code with 'BR'" do
|
112
|
-
expect(subject.iso_3166_country_code).to eq 'BR'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
shared_examples "of detection from a request made from a chilean mobile network" do
|
117
|
-
it "responds to #id with a string starting with '56'" do
|
118
|
-
expect(subject.id).to match /\A56/
|
119
|
-
end
|
120
|
-
|
121
|
-
it "responds to #mobile_country_code with '730'" do
|
122
|
-
expect(subject.mobile_country_code).to eq '730'
|
123
|
-
end
|
124
|
-
|
125
|
-
it "responds to #dialing_code with '56'" do
|
126
|
-
expect(subject.dialing_code).to eq '56'
|
127
|
-
end
|
128
|
-
|
129
|
-
it "responds to #iso_3166_country_code with 'CL'" do
|
130
|
-
expect(subject.iso_3166_country_code).to eq 'CL'
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
shared_examples "of detection from a request made from a peruvian mobile network" do
|
135
|
-
it "responds to #id with a string starting with '51'" do
|
136
|
-
expect(subject.id).to match /\A51/
|
137
|
-
end
|
138
|
-
|
139
|
-
it "responds to #mobile_country_code with '716'" do
|
140
|
-
expect(subject.mobile_country_code).to eq '716'
|
141
|
-
end
|
142
64
|
|
143
|
-
it "
|
144
|
-
expect(subject.
|
65
|
+
it "#id is present" do
|
66
|
+
expect(subject.id).to be_present
|
145
67
|
end
|
146
68
|
|
147
|
-
it "
|
148
|
-
expect(subject.
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
shared_examples "of detection from a request made from a Claro network" do
|
153
|
-
it "responds to #mobile_network_brand with a string containing 'Claro'" do
|
154
|
-
expect(subject.mobile_network_brand).to match /\AClaro/
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
context "from a request made from Telcel México" do
|
159
|
-
|
160
|
-
subject do
|
161
|
-
described_class.new_from_request(build :mobile_request_from_telcel_mexico)
|
69
|
+
it "#mobile_country_code is present" do
|
70
|
+
expect(subject.mobile_country_code).to be_present
|
162
71
|
end
|
163
72
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
it "responds to #mobile_network_brand with 'Telcel'" do
|
168
|
-
expect(subject.mobile_network_brand).to eq 'Telcel'
|
73
|
+
it "#dialing_code is present" do
|
74
|
+
expect(subject.dialing_code).to be_present
|
169
75
|
end
|
170
76
|
|
171
|
-
it "
|
172
|
-
expect(subject.
|
77
|
+
it "#iso_3166_country_code is present" do
|
78
|
+
expect(subject.iso_3166_country_code).to be_present
|
173
79
|
end
|
174
80
|
|
175
|
-
|
176
|
-
|
177
|
-
context "from a request made from Claro Argentina" do
|
178
|
-
|
179
|
-
subject do
|
180
|
-
described_class.new_from_request(build :mobile_request_from_claro_argentina)
|
81
|
+
it "#mobile_network_brand is present" do
|
82
|
+
expect(subject.mobile_network_brand).to be_present
|
181
83
|
end
|
182
84
|
|
183
|
-
|
184
|
-
|
185
|
-
include_examples "of detection from a request made from a Claro network"
|
186
|
-
|
187
|
-
it "responds to #mobile_network_operator with 'AMX Argentina S.A.'" do
|
188
|
-
expect(subject.mobile_network_operator).to eq 'AMX Argentina S.A.'
|
85
|
+
it "#mobile_network_operator is present" do
|
86
|
+
expect(subject.mobile_network_operator).to be_present
|
189
87
|
end
|
190
88
|
|
191
89
|
end
|
192
90
|
|
193
|
-
context "from a request made from Claro Perú" do
|
194
|
-
|
195
|
-
subject do
|
196
|
-
described_class.new_from_request(build :mobile_request_from_claro_peru)
|
197
|
-
end
|
198
|
-
|
199
|
-
include_examples "of detection from a valid request"
|
200
|
-
include_examples "of detection from a request made from a peruvian mobile network"
|
201
|
-
include_examples "of detection from a request made from a Claro network"
|
202
|
-
|
203
|
-
it "responds to #mobile_network_operator with 'América Móvil Perú'" do
|
204
|
-
expect(subject.mobile_network_operator).to eq 'América Móvil Perú'
|
205
|
-
end
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
context "from a request made from Claro Brasil" do
|
210
|
-
|
211
|
-
subject do
|
212
|
-
described_class.new_from_request(build :mobile_request_from_claro_brasil)
|
213
|
-
end
|
214
|
-
|
215
|
-
include_examples "of detection from a valid request"
|
216
|
-
include_examples "of detection from a request made from a brazilian mobile network"
|
217
|
-
include_examples "of detection from a request made from a Claro network"
|
218
|
-
|
219
|
-
it "responds to #mobile_network_operator with 'Claro'" do
|
220
|
-
expect(subject.mobile_network_operator).to eq 'Claro'
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
context "from a request made from Claro Chile" do
|
225
|
-
|
226
|
-
subject do
|
227
|
-
described_class.new_from_request(build :mobile_request_from_claro_chile)
|
228
|
-
end
|
229
|
-
|
230
|
-
include_examples "of detection from a valid request"
|
231
|
-
include_examples "of detection from a request made from a chilean mobile network"
|
232
|
-
include_examples "of detection from a request made from a Claro network"
|
233
|
-
|
234
|
-
it "responds to #mobile_network_operator with 'Claro Chile S.A.'" do
|
235
|
-
expect(subject.mobile_network_operator).to eq 'Claro Chile S.A.'
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
91
|
end
|
240
92
|
|
241
93
|
end
|
@@ -92,6 +92,28 @@ shared_examples "of detection of msisdn from a valid chilean mobile network http
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
shared_examples "of detection of msisdn from a valid salvadoran mobile network http request" do
|
96
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
97
|
+
it "has an :id value that starts with '503'" do
|
98
|
+
expect(subject[:id]).to match /\A503/
|
99
|
+
end
|
100
|
+
|
101
|
+
it "has a :mobile_country_code value of '706'" do
|
102
|
+
expect(subject[:mobile_country_code]).to eq '706'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
shared_examples "of detection of msisdn from a valid costa rican mobile network http request" do
|
107
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
108
|
+
it "has an :id value that starts with '506'" do
|
109
|
+
expect(subject[:id]).to match /\A506/
|
110
|
+
end
|
111
|
+
|
112
|
+
it "has a :mobile_country_code value of '712'" do
|
113
|
+
expect(subject[:mobile_country_code]).to eq '712'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
95
117
|
shared_examples "of detection of msisdn from a valid colombian mobile network http request" do
|
96
118
|
include_examples "of detection of msisdn from a valid mobile network http request"
|
97
119
|
it "has an :id value that starts with '57'" do
|
@@ -114,6 +136,39 @@ shared_examples "of detection of msisdn from a valid ecuadorian mobile network h
|
|
114
136
|
end
|
115
137
|
end
|
116
138
|
|
139
|
+
shared_examples "of detection of msisdn from a valid dominican mobile network http request" do
|
140
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
141
|
+
it "has an :id value that starts with '1809'" do
|
142
|
+
expect(subject[:id]).to match /\A1809/
|
143
|
+
end
|
144
|
+
|
145
|
+
it "has a :mobile_country_code value of '370'" do
|
146
|
+
expect(subject[:mobile_country_code]).to eq '370'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
shared_examples "of detection of msisdn from a valid nicaraguan mobile network http request" do
|
151
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
152
|
+
it "has an :id value that starts with '505'" do
|
153
|
+
expect(subject[:id]).to match /\A505/
|
154
|
+
end
|
155
|
+
|
156
|
+
it "has a :mobile_country_code value of '710'" do
|
157
|
+
expect(subject[:mobile_country_code]).to eq '710'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
shared_examples "of detection of msisdn from a valid panamanian mobile network http request" do
|
162
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
163
|
+
it "has an :id value that starts with '507'" do
|
164
|
+
expect(subject[:id]).to match /\A507/
|
165
|
+
end
|
166
|
+
|
167
|
+
it "has a :mobile_country_code value of '714'" do
|
168
|
+
expect(subject[:mobile_country_code]).to eq '714'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
117
172
|
shared_examples "of detection of msisdn from a valid peruvian mobile network http request" do
|
118
173
|
include_examples "of detection of msisdn from a valid mobile network http request"
|
119
174
|
it "has an :id value that starts with '51'" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobile-subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -118,7 +118,9 @@ files:
|
|
118
118
|
- lib/mobile_subscriber/detection/from_x_up_calling_line_id_http_request_header.rb
|
119
119
|
- lib/mobile_subscriber/detection/from_x_up_ch_msisdn_http_request_header.rb
|
120
120
|
- lib/mobile_subscriber/detection/from_x_up_subno_http_request_header.rb
|
121
|
+
- lib/mobile_subscriber/detection/from_x_wap_msisdn_http_request_header.rb
|
121
122
|
- lib/mobile_subscriber/detection/from_x_wap_sesiones3g_mdn_http_request_header.rb
|
123
|
+
- lib/mobile_subscriber/detection/from_x_ztgo_beareraddress_http_request_header.rb
|
122
124
|
- lib/mobile_subscriber/detection/http_request_info.rb
|
123
125
|
- lib/mobile_subscriber/dictionaries/dialing_and_country_codes.rb
|
124
126
|
- lib/mobile_subscriber/dictionaries/mobile_and_iso_country_codes.rb
|
@@ -130,6 +132,8 @@ files:
|
|
130
132
|
- spec/detection/from_msisdn_http_request_header_spec.rb
|
131
133
|
- spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb
|
132
134
|
- spec/detection/from_x_up_calling_line_id_http_request_header_spec.rb
|
135
|
+
- spec/detection/from_x_up_subno_http_request_header_spec.rb
|
136
|
+
- spec/detection/from_x_wap_msisdn_http_request_header_spec.rb
|
133
137
|
- spec/detection/from_x_wap_sesiones3g_mdn_http_request_header_spec.rb
|
134
138
|
- spec/factories/requests.rb
|
135
139
|
- spec/mobile_subscriber_spec.rb
|
@@ -166,6 +170,8 @@ test_files:
|
|
166
170
|
- spec/detection/from_msisdn_http_request_header_spec.rb
|
167
171
|
- spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb
|
168
172
|
- spec/detection/from_x_up_calling_line_id_http_request_header_spec.rb
|
173
|
+
- spec/detection/from_x_up_subno_http_request_header_spec.rb
|
174
|
+
- spec/detection/from_x_wap_msisdn_http_request_header_spec.rb
|
169
175
|
- spec/detection/from_x_wap_sesiones3g_mdn_http_request_header_spec.rb
|
170
176
|
- spec/factories/requests.rb
|
171
177
|
- spec/mobile_subscriber_spec.rb
|