phonie 3.1.6 → 3.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbb6d7902284f4bf12daeb9345220012cc06a8f7
4
- data.tar.gz: 14f485bc407de6904c6c69c1a225ac3ed6af18b8
3
+ metadata.gz: 06bbfa37da7c3c35e3e79b70ca4128a52eb74063
4
+ data.tar.gz: d14a23a1c6e44267cfd576bc6054c81c57cd1bde
5
5
  SHA512:
6
- metadata.gz: 6f536a324f1137921560cc4f44dfa7225ff16a60bb694768e15f537632c00a4568d36a245c52229a27909a063529d5c4d57317ca8d551bd6412ced2b860cf2e6
7
- data.tar.gz: ce2f2c947262935e1d7c9526fd246ec20336bb040974ffcd6c0dd364d441872852e2174c7f4d3ded3faf97bdbce0ea5a801fa9f15bfd03bdb089577c540ec5d6
6
+ metadata.gz: a10e2fff7a3a6df19b71af58771e94c700bb08ef6ab03bb215e9093430b8ac34697f83a436a2ca68a354853ee1664ebd693fe9278f776d6042bd10d48ab8a506
7
+ data.tar.gz: a87707e27ff228cdd16cab2ca940a3ebb6118aa3b692e166d4851ceb499785294ce1dec53d3c357e863ee193dd0311965f7ddaa1cae04e203a652d32079dcfd1
data/Changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ 3.1.7
2
+ =====
3
+
4
+ * Fixes Brazilian number parsing (Thanks nofxx!)
5
+
1
6
  3.1.6
2
7
  =====
3
8
 
@@ -178,14 +178,14 @@
178
178
  :international_dialing_prefix: '00'
179
179
  -
180
180
  :country_code: '55'
181
- :national_dialing_prefix: '14'
182
- :char_2_code: '14'
181
+ :national_dialing_prefix: '0'
182
+ :international_dialing_prefix: '00'
183
+ :char_2_code: '55'
183
184
  :iso_3166_code: BR
184
185
  :name: Brazil
185
- :international_dialing_prefix: '00'
186
- :area_code: '[1-9][1-9]'
187
- :local_number_format: \d{7,9}
188
- :mobile_format: '((1[1-9]|21|22|24|27|28)[6789]\d{8})|((23|2[5-9]|[3-9][1-9])[6789]\d{7})'
186
+ :area_code: ((1[1-9]|2[147]|3[1-578]|4[1-9]|5[1-5]|6[1235-9]|7[134579]|8[1-8]|9[12568])|0[3589]00)
187
+ :local_number_format: ([2-5]\d{7}|9?[6-9]\d{7}|\d{7})
188
+ :mobile_format: ([129][1-9]9|[3-9][1-9])[6-9]\d{7}
189
189
  :number_format: \d{10,11}
190
190
  -
191
191
  :country_code: '253'
data/lib/phonie/phone.rb CHANGED
@@ -118,7 +118,7 @@ module Phonie
118
118
 
119
119
  def defaults
120
120
  { area_code: Phonie.configuration.default_area_code,
121
- country_code: Phonie.configuration.default_country_code }
121
+ country_code: Phonie.configuration.default_country_code }
122
122
  end
123
123
 
124
124
  def normalize_args(args)
@@ -1,3 +1,3 @@
1
1
  module Phonie
2
- VERSION = '3.1.6'
2
+ VERSION = '3.1.7'
3
3
  end
@@ -1,14 +1,88 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
3
  ## Brazil
4
+ # http://www.wisetel.com.br/acoes_de_regulacao/normas/n_96_28.htm
4
5
  class BRTest < Phonie::TestCase
6
+
5
7
  def test_local
6
- parse_test('+559112345678', '55', "91", '12345678', 'Brazil', false)
7
- #parse_failure('+5591123456789') # only mobile numebrs can be 11 digits
8
+ parse_test('+55 91 22345678', '55', '91', '22345678', 'Brazil', false)
9
+ end
10
+
11
+ def test_sao_paulo
12
+ parse_test('+55 11 22345678', '55', '11', '22345678', 'Brazil', false)
13
+ end
14
+
15
+ def test_minas_gerais
16
+ parse_test('+55 35 22345678', '55', '35', '22345678', 'Brazil', false)
17
+ end
18
+
19
+ def test_area_max
20
+ parse_test('+55 98 59995678', '55', '98', '59995678', 'Brazil', false)
21
+ end
22
+
23
+ def test_area_max_fail
24
+ parse_failure('+55 99 59995678')
8
25
  end
9
26
 
27
+ def test_paid_toll
28
+ parse_test('+55 0300 12 345 67', '55', '0300', '1234567', 'Brazil', false)
29
+ end
30
+
31
+ def test_donation_service
32
+ parse_test('+55 0500 12 345 67', '55', '0500', '1234567', 'Brazil', false)
33
+ end
34
+
35
+ def test_toll_free
36
+ parse_test('+55 0800 12 345 67', '55', '0800', '1234567', 'Brazil', false)
37
+ end
38
+
39
+ def test_paid_service
40
+ parse_test('+55 0900 123 4567', '55', '0900', '1234567', 'Brazil', false)
41
+ end
42
+
43
+ #
44
+ # Parse should fail
45
+ #
46
+ def test_area_validation_min
47
+ parse_failure('+55 10 1234 5678') # no area '10'
48
+ end
49
+
50
+ def test_area_cant_have_9
51
+ parse_failure('55 31 95101 4567')
52
+ end
53
+
54
+ def test_only_mobile_has_11_digits
55
+ parse_failure('+5591223456789') # only mobile numebrs can be 11 digits
56
+ end
57
+
58
+ #
59
+ # Mobile
60
+ #
10
61
  def test_mobile
11
- parse_test('553161234567', '55', '31', '61234567', 'Brazil', true)
12
- parse_test('5512612345678', '55', '12', '612345678', 'Brazil', true)
62
+ parse_test('+55 91 9786 5678', '55', "91", '97865678', 'Brazil', true)
63
+ end
64
+
65
+ def test_mobile_low_range
66
+ parse_test('55 35 6101 4567', '55', '35', '61014567', 'Brazil', true)
67
+ end
68
+
69
+ def test_mobile_high_range
70
+ parse_test('55 35 9991 4567', '55', '35', '99914567', 'Brazil', true)
71
+ end
72
+
73
+ def test_mobile_area_11_with_9
74
+ parse_test('55 11 99765 5678', '55', '11', '997655678', 'Brazil', true)
75
+ end
76
+
77
+ def test_mobile_area_16_with_9
78
+ parse_test('55 16 98765 5678', '55', '16', '987655678', 'Brazil', true)
79
+ end
80
+
81
+ def test_mobile_area_19_with_9
82
+ parse_test('55 19 98765 5678', '55', '19', '987655678', 'Brazil', true)
83
+ end
84
+
85
+ def test_mobile_area_21_with_9
86
+ parse_test('55 21 98765 5678', '55', '21', '987655678', 'Brazil', true)
13
87
  end
14
88
  end
data/test/test_helper.rb CHANGED
@@ -15,16 +15,16 @@ def parse_test(raw, country_code, area_code, number, country_name = nil, is_mobi
15
15
  end
16
16
 
17
17
  unless is_mobile.nil?
18
- assert_equal is_mobile, pn.is_mobile?
18
+ text = pn.is_mobile? ? :mobile : :local
19
+ assert_equal is_mobile ? :mobile : :local, text
19
20
  end
20
21
  end
21
22
 
22
23
  def parse_failure(raw)
23
- pn = Phonie::Phone.parse!(raw)
24
+ pn = Phonie::Phone.parse(raw)
24
25
  assert_equal pn, nil
25
26
  end
26
27
 
27
-
28
28
  class Phonie::TestCase < Test::Unit::TestCase
29
29
 
30
30
  def setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonie
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.6
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomislav Car
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-12-16 00:00:00.000000000 Z
15
+ date: 2015-01-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activemodel