phony 1.1.1 → 1.1.2

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.
@@ -5,7 +5,7 @@ h2. Description
5
5
  This gem can normalize, format and split E164 numbers.
6
6
  "More about E164 numbers in this Wiki":http://en.wikipedia.org/wiki/E.164.
7
7
 
8
- Currently handles Austrian, Australian, Belgian, Czech, Egyptian, French, German, Greek, Hungarian, Italian, New Zealand, Norwegian, Polish, Russian, South African, Spanish, Swiss, Liechtenstein, US numbers.
8
+ Currently handles Austrian, Australian, Belgian, Czech, Egyptian, French, German, Greek, Hungarian, Italian, (The) Netherlands, New Zealand, Norwegian, Polish, Russian, South African, Spanish, Swiss, Liechtenstein, US numbers.
9
9
  And to some extend, all others. Just try if it works for you.
10
10
 
11
11
  h2. Installation
@@ -27,6 +27,7 @@ require File.expand_path '../phony/countries/greece', __FILE__
27
27
  require File.expand_path '../phony/countries/hungary', __FILE__
28
28
  require File.expand_path '../phony/countries/italy', __FILE__
29
29
  require File.expand_path '../phony/countries/netherlands', __FILE__
30
+ require File.expand_path '../phony/countries/sweden', __FILE__
30
31
 
31
32
  require File.expand_path '../phony/country_codes', __FILE__
32
33
 
@@ -76,7 +76,7 @@ module Phony
76
76
  '43' => Countries::Austria,
77
77
  '44' => fixed(2), # United Kingdom of Great Britain and Northern Ireland
78
78
  '45' => fixed(2), # Denmark
79
- '46' => fixed(2), # Sweden
79
+ '46' => Countries::Sweden,
80
80
  '47' => fixed(4, # Norway
81
81
  :local_format => [4]
82
82
  ),
@@ -1,6 +1,6 @@
1
1
  # The Netherlands use a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
2
2
  #
3
- # Note: Greece uses a variable ndc format from length 2 to 3.
3
+ # Note: The netherlands use a variable ndc format from length 2 to 3.
4
4
  # To save space, we only use ndcs of length 2 (and use the fallback of 3 to handle the rest).
5
5
  #
6
6
  Phony::Countries::Netherlands = Phony::Country.configured :local_format => [8], # 8 is for mobile numbers, other numbers will work as well (they use 7).
@@ -0,0 +1,57 @@
1
+ # Sweden uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
2
+ #
3
+ # Note: Sweden use a variable ndc format from length 2 to 3.
4
+ # To save space, we only use ndcs of length 1 and 2 (and use the fallback of 3 to handle the rest).
5
+ #
6
+ # Taken from: http://en.wikipedia.org/wiki/Telephone_numbers_in_Sweden
7
+ # http://www.pts.se/upload/Ovrigt/Tele/Nummerfragor/bilaga-2b.pdf
8
+ #
9
+ Phony::Countries::Sweden = Phony::Country.configured :local_format => [8],
10
+ :ndc_fallback_length => 3,
11
+ :ndc_mapping => {
12
+ :landline => [
13
+ '7', # Non-geographical
14
+ '8', # Stockholm
15
+ '10', # VOIP
16
+ '11', # Norrköping
17
+ '13', # Linköping
18
+ '16', # Eskilstuna-Torshälla
19
+ '18', # Uppsala
20
+ '19', # Örebro-Kumla
21
+ '20', # toll-free
22
+ '21', # Västerås
23
+ '23', # Falun
24
+ '26', # Gävle-Sandviken
25
+ '31', # Göteborg
26
+ '33', # Borås
27
+ '35', # Halmstad
28
+ '36', # Jönköping-Huskvarna
29
+ '40', # Malmö
30
+ '42', # Helsingborg-Höganäs
31
+ '44', # Kristianstad
32
+ '46', # Lund
33
+ '54', # Karlstad
34
+ '60', # Sundsvall-Timrå
35
+ '63', # Östersund
36
+ '90', # Umeå
37
+ ],
38
+ :mobile => [
39
+ '70', # Mobile
40
+ '71', # Telematics
41
+ '72', # Mobile
42
+ '73', # Mobile
43
+ '74', # Pagers
44
+ '76', # Mobile
45
+ ],
46
+ :service => [
47
+ '99', # Premium Rate
48
+ '112', # Emergency Service
49
+ '116', # Psychological Help
50
+ '118', # Number enquiries
51
+ '900', # Premium Rate
52
+ '939', # Premium Rate
53
+ '944', # Premium Rate
54
+ '1177', # Health Care Advice
55
+ '11414', # Police
56
+ ]
57
+ }
@@ -9,11 +9,10 @@ describe Phony do
9
9
  Phony.split('43198110').should == ['43', '1', '98110']
10
10
  end
11
11
  it "should handle dutch numbers" do
12
+ Phony.split('31612345678').should == ['31', '6', '12345678'] # mobile
12
13
  Phony.split('31201234567').should == ['31', '20', '1234567']
14
+ Phony.split('31222123456').should == ['31', '222', '123456']
13
15
  end
14
- it "should handle dutch mobile numbers" do
15
- Phony.split('31612345678').should == ['31', '6', '12345678']
16
- end
17
16
  it "should handle egyptian numbers" do
18
17
  Phony.split('20233453756').should == ['20', '2', '33453756']
19
18
  end
@@ -35,6 +34,14 @@ describe Phony do
35
34
  it "should handle polish numbers" do
36
35
  Phony.split('48121123123').should == ['48', '12', '1', '123', '123']
37
36
  end
37
+ it "should handle swedish numbers" do
38
+ Phony.split('46812345678').should == ['46', '8', '12345678']
39
+ Phony.split('46111234567').should == ['46', '11', '1234567']
40
+ Phony.split('46125123456').should == ['46', '125', '123456']
41
+ end
42
+ it 'handles russian numbers' do
43
+ Phony.split('78122345678').should == ['7', '812', '234', '56', '78']
44
+ end
38
45
  it "should handle swiss numbers" do
39
46
  Phony.split('41443643532').should == ['41', '44', '364', '35', '32']
40
47
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-29 00:00:00 +01:00
17
+ date: 2010-11-30 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -35,6 +35,7 @@ files:
35
35
  - lib/phony/countries/hungary.rb
36
36
  - lib/phony/countries/italy.rb
37
37
  - lib/phony/countries/netherlands.rb
38
+ - lib/phony/countries/sweden.rb
38
39
  - lib/phony/country.rb
39
40
  - lib/phony/country_codes.rb
40
41
  - lib/phony/local_splitter.rb