phony 2.2.15 → 2.2.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDVjMDIxMGQ4ZTkyZGM3MWQ0YzAzNTAzMjM3OTA1OTc3MzU4Y2Q0ZA==
5
- data.tar.gz: !binary |-
6
- ZTU1MjQ2YWM2NGVjN2YxNTFjZjIyMmY4MjQ2MGUzYTMzMzRhNTQ3Yw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NDA4YjdhYTk0MGE4MTkxMzNhZWE5MDZiOWJlMTRkMGQ1YWJiZDVmZjdhNTc4
10
- ZDA2YjliYTYyMzc2NWEzYzljYWMyYWVjNjFmMjA2YmY5Y2ZkZjI3OTA2NWNl
11
- MmY3Y2UzODg3MWY2OGMwYTMxYzQ1NzAyZDdiMzk4MjRlMzFmMmU=
12
- data.tar.gz: !binary |-
13
- NDI1NGJjOWQ5MDgyZDhhZGRiMGI0MjE4OWZhNDAzYmViZGZlMTBjYTFjMmQx
14
- N2JlMzIyY2U3OTIxNDYxOTk4NDkxNmViZGJiZjFjNWM3ZDg4ODljZTJkNzVm
15
- ZjEyOWNiM2Y2Zjg0OGI3MThiOWRmMGY0YjI0MDIwODc5ZjZiYzk=
2
+ SHA1:
3
+ metadata.gz: 3d8710a24e82893cf992f1f78257fc8170f63b50
4
+ data.tar.gz: 14e5ee3227225b131fcfcf44dabf870cd19d0120
5
+ SHA512:
6
+ metadata.gz: 60b52b683503709334ac1c2f946b81d1715a567b27fd18d010fef5d01180979605821cf4d5c8dfdf2e65e437525668143f72ef0dbce251f047835214ade2d774
7
+ data.tar.gz: 2bd8cdb967fb9624b268f7bdd009652edc13aea73a979f669d81a52589fe19a9b4190074814366affa1ecdf91c4952990968fa51a3e8d744fcce5fecdc9a35d1
@@ -80,8 +80,14 @@ Phony.define do
80
80
 
81
81
  # Spain.
82
82
  #
83
+ # http://www.minetur.gob.es/telecomunicaciones/es-es/servicios/numeracion/paginas/plan.aspx
84
+ #
83
85
  country '34',
84
- fixed(2, :zero => false) >> split(3,4)
86
+ match(/^([67]\d{2})\d+$/) >> split(3,3) | # Mobile
87
+ match(/^([89]0\d)\d+$/) >> split(3,3) | # Special 80X & 90X numbers
88
+ one_of(%w(91 93)) >> split(3,2,2) | # Landline large regions
89
+ match(/^(9\d{2})\d+$/) >> split(2,2,2) | # Landline
90
+ fixed(3, :zero => false) >> split(3,3)
85
91
 
86
92
  # Hungary.
87
93
  #
@@ -83,12 +83,12 @@ service = [
83
83
  # TODO Add more details.
84
84
  #
85
85
  Phony.define do
86
- country '43', one_of('1') >> split(4..4) | # Vienna
86
+ country '43', one_of('1') >> split(3..12) | # Vienna
87
87
  one_of(service) >> split(9..9) |
88
88
  one_of(corporate) >> split(5..5) |
89
89
  one_of(ndcs) >> split(6..6) |
90
90
  one_of('663') >> split(6..6) | # 6 digit mobile.
91
- one_of(mobile) >> split(7..7) |
91
+ one_of(mobile) >> split(4,3..4) |
92
92
  one_of(mobile_2digit) >> split(7..7) | # Separate as mobile contains 676 - 67 violates the prefix rule.
93
93
  fixed(4) >> split(7..7)
94
94
  end
@@ -166,18 +166,18 @@ module Phony
166
166
 
167
167
  def plausible? number, hints = {}
168
168
  normalized = clean number
169
-
169
+
170
170
  # False if it fails the basic check.
171
171
  #
172
172
  return false unless (4..15) === normalized.size
173
173
 
174
174
  country, cc, rest = split_cc normalized
175
-
175
+
176
176
  # Country code plausible?
177
177
  #
178
178
  cc_needed = hints[:cc]
179
179
  return false if cc_needed && !(cc_needed === cc)
180
-
180
+
181
181
  # Country specific tests.
182
182
  #
183
183
  country.plausible? rest, hints
@@ -113,7 +113,13 @@ describe 'plausibility' do
113
113
  end
114
114
 
115
115
  context 'specific countries' do
116
+ it "" do
117
+ Phony.plausible?('+43 699 00000000').should be_true
118
+ end
119
+
116
120
  it "is correct for Austria" do
121
+ Phony.plausible?('+43 1 000000').should be_true
122
+ Phony.plausible?('+43 1 0000000').should be_true
117
123
  Phony.plausible?('+43 501 12345').should be_true
118
124
  Phony.plausible?('+43 501 1234').should be_false # too short
119
125
  Phony.plausible?('+43 501 123456').should be_false # too long
@@ -121,6 +127,9 @@ describe 'plausibility' do
121
127
 
122
128
  # Mobile
123
129
  Phony.plausible?('+43 676 0000000').should be_true
130
+ Phony.plausible?('+43 681 00000000').should be_true
131
+ Phony.plausible?('+43 688 0000000').should be_true
132
+ Phony.plausible?('+43 699 00000000').should be_true
124
133
  # 663 mobile numbers have 6 digits
125
134
  Phony.plausible?('+43 663 000000').should be_true
126
135
  end
@@ -16,13 +16,16 @@ describe 'country descriptions' do
16
16
  describe 'Ascension Island' do
17
17
  it_splits '2473551', ['247', false, '3551']
18
18
  end
19
+
19
20
  describe 'Afghanistan' do
20
21
  it_splits '93201234567', ['93', '20', '1234567'] # Kabul
21
22
  end
23
+
22
24
  describe 'Algeria' do
23
25
  it_splits '213211231234', ['213', '21', '123', '1234'] # Algiers
24
26
  it_splits '213331231234', ['213', '33', '123', '1234'] # Batna
25
27
  end
28
+
26
29
  describe 'Argentina' do
27
30
  it_splits '541112345678', ['54', '11', '1234', '5678']
28
31
  it_splits '542911234567', ['54', '291', '123', '4567']
@@ -32,13 +35,18 @@ describe 'country descriptions' do
32
35
  it_splits '5492221123456', ['54', '92221', '12', '3456']
33
36
  it_splits '548001234567', ['54', '800', '123', '4567']
34
37
  end
38
+
35
39
  describe 'Austria' do
36
- it_splits '43198110', ['43', '1', '98110'] # Vienna
37
- it_splits '43800123456789', ['43', '800', '123456789'] # Free
38
- it_splits '4366914093902', ['43', '669', '14093902'] # Mobile
39
- it_splits '433161234567891', ['43', '316', '1234567891'] # Graz
40
- it_splits '432164123456789', ['43', '2164', '123456789'] # Rohrau
40
+ it_splits '43198110', %w( 43 1 98110 ) # Vienna
41
+ it_splits '4310000000', %w( 43 1 0000000 ) # Vienna
42
+ it_splits '43800123456789', %w( 43 800 123456789 ) # Free
43
+ it_splits '4368100000000', %w( 43 681 0000 0000 ) # Mobile
44
+ it_splits '436880000000', %w( 43 688 0000 000 ) # Mobile
45
+ it_splits '4366900000000', %w( 43 669 0000 0000 ) # Mobile
46
+ it_splits '433161234567891', %w( 43 316 1234567891 ) # Graz
47
+ it_splits '432164123456789', %w( 43 2164 123456789 ) # Rohrau
41
48
  end
49
+
42
50
  describe 'Australia' do
43
51
  it_splits '61512341234', ['61', '5', '1234', '1234'] # Landline
44
52
  it_splits '61423123123', ['61', '423', '123', '123'] # Mobile
@@ -554,7 +562,15 @@ describe 'country descriptions' do
554
562
  it { Phony.split('421212345678').should == ['421', '2', '12345678'] } # Bratislava
555
563
  it { Phony.split('421371234567').should == ['421', '37', '1234567'] } # Nitra / Other
556
564
  end
557
-
565
+
566
+ describe 'Spain' do
567
+ it_splits '34600123456', ['34', '600', '123', '456'] # Mobile
568
+ it_splits '34900123456', ['34', '900', '123', '456'] # Special
569
+ it_splits '34931234567', ['34', '93', '123', '45', '67'] # Landline large regions
570
+ it_splits '34975123456', ['34', '975', '12', '34', '56'] # Landline
571
+ it_splits '34123456789', ['34', '123', '456', '789'] # Default
572
+ end
573
+
558
574
  describe 'Sri Lanka' do
559
575
  it { Phony.split('94711231212').should == ['94', '71', '123', '12', '12'] } # Mobile
560
576
  end
@@ -70,7 +70,7 @@ describe Phony::CountryCodes do
70
70
  @countries.formatted("353411231234", :format => :national).should eql '041 123 1234'
71
71
  end
72
72
  it 'formats spain correctly' do
73
- @countries.formatted("34123456789", :format => :national).should eql '12 345 6789'
73
+ @countries.formatted("34123456789", :format => :national).should eql '123 456 789'
74
74
  end
75
75
  end
76
76
  context 'default' do
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.15
4
+ version: 2.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: ! 'Fast international phone number (E164 standard) normalizing, splitting
13
+ description: 'Fast international phone number (E164 standard) normalizing, splitting
14
14
  and formatting. Lots of formatting options: International (+.., 00..), national
15
15
  (0..), and local.'
16
16
  email: florian.hanke+phony@gmail.com
@@ -19,6 +19,9 @@ extensions: []
19
19
  extra_rdoc_files:
20
20
  - README.textile
21
21
  files:
22
+ - README.textile
23
+ - lib/phony.rb
24
+ - lib/phony/countries.rb
22
25
  - lib/phony/countries/austria.rb
23
26
  - lib/phony/countries/bangladesh.rb
24
27
  - lib/phony/countries/belarus.rb
@@ -56,7 +59,6 @@ files:
56
59
  - lib/phony/countries/united_kingdom.rb
57
60
  - lib/phony/countries/uruguay.rb
58
61
  - lib/phony/countries/zimbabwe.rb
59
- - lib/phony/countries.rb
60
62
  - lib/phony/country.rb
61
63
  - lib/phony/country_codes.rb
62
64
  - lib/phony/dsl.rb
@@ -71,8 +73,6 @@ files:
71
73
  - lib/phony/national_splitters/variable.rb
72
74
  - lib/phony/trunk_code.rb
73
75
  - lib/phony/vanity.rb
74
- - lib/phony.rb
75
- - README.textile
76
76
  - spec/functional/error_spec.rb
77
77
  - spec/functional/normalize_spec.rb
78
78
  - spec/functional/plausibility_spec.rb
@@ -99,17 +99,17 @@ require_paths:
99
99
  - lib
100
100
  required_ruby_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ! '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ! '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.0.3
112
+ rubygems_version: 2.2.0
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Fast international phone number (E164 standard) normalizing, splitting and