Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (88 sloc) 3.478 kb
cedc4c2 Florian R. Hanke + phony rename
authored
1 # Framework.
2 #
147134d Florian R. Hanke + vanity number rewrite
authored
3 require File.expand_path '../phony/vanity', __FILE__
fc827a4 Florian R. Hanke + introduced countries without area code, + regexp formatter
authored
4 require File.expand_path '../phony/local_splitters/fixed', __FILE__
5 require File.expand_path '../phony/local_splitters/regex', __FILE__
a84d745 Florian R. Hanke + DSL rewrite
authored
6 require File.expand_path '../phony/national_splitters/dsl', __FILE__
e0ae1c3 Florian R. Hanke + rename, + first vestiges of service/mobile/landline recognition
authored
7 require File.expand_path '../phony/national_splitters/fixed', __FILE__
8 require File.expand_path '../phony/national_splitters/variable', __FILE__
a84d745 Florian R. Hanke + DSL rewrite
authored
9 require File.expand_path '../phony/national_splitters/regex', __FILE__
fc827a4 Florian R. Hanke + introduced countries without area code, + regexp formatter
authored
10 require File.expand_path '../phony/national_splitters/none', __FILE__
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
11 require File.expand_path '../phony/national_code', __FILE__
40e77a8 Florian R. Hanke + intermediate commit
authored
12 require File.expand_path '../phony/country', __FILE__
43eed69 Florian R. Hanke + DSL rewrite almost finished
authored
13 require File.expand_path '../phony/country_codes', __FILE__
a84d745 Florian R. Hanke + DSL rewrite
authored
14 require File.expand_path '../phony/dsl', __FILE__
15
98cc263 Florian R. Hanke + vanity, normalize
authored
16 # Countries.
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
17 #
18 # Note: See country_codes.rb for a complete mapping.
cedc4c2 Florian R. Hanke + phony rename
authored
19 #
a84d745 Florian R. Hanke + DSL rewrite
authored
20 require File.expand_path '../phony/countries', __FILE__
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
21 require File.expand_path '../phony/countries/austria', __FILE__
1dacbab Keith Bingman belgian mobile numbers failing
kbingman authored
22 require File.expand_path '../phony/countries/belgium', __FILE__
67a03da Florian R. Hanke + buen día Chile!
authored
23 require File.expand_path '../phony/countries/chile', __FILE__
885869c Florian R. Hanke + Ni hao, China.
authored
24 require File.expand_path '../phony/countries/china', __FILE__
a4db5e8 Florian R. Hanke + egypt
authored
25 require File.expand_path '../phony/countries/egypt', __FILE__
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
26 require File.expand_path '../phony/countries/germany', __FILE__
29ea6bb Florian R. Hanke + greece
authored
27 require File.expand_path '../phony/countries/greece', __FILE__
7a40c1c Florian R. Hanke + hungarian numbers, swiss specs
authored
28 require File.expand_path '../phony/countries/hungary', __FILE__
9b37d4c Florian R. Hanke + italian phone numbers
authored
29 require File.expand_path '../phony/countries/italy', __FILE__
0fb354a Florian R. Hanke + 1.2.4, Malaysia
authored
30 require File.expand_path '../phony/countries/malaysia', __FILE__
fc827a4 Florian R. Hanke + introduced countries without area code, + regexp formatter
authored
31 require File.expand_path '../phony/countries/norway', __FILE__
f01d580 Florian R. Hanke + first draft for the netherlands
authored
32 require File.expand_path '../phony/countries/netherlands', __FILE__
e32f33e Florian R. Hanke + romania, best effort, + 1.1.3
authored
33 require File.expand_path '../phony/countries/romania', __FILE__
5fd6965 Florian R. Hanke + Annyeonhaseyo, South Korea!
authored
34 require File.expand_path '../phony/countries/south_korea', __FILE__
da33c53 Florian R. Hanke + sweden, yay, + russia, sweden specs
authored
35 require File.expand_path '../phony/countries/sweden', __FILE__
c8173d5 Keith Bingman added uk
kbingman authored
36 require File.expand_path '../phony/countries/united_kingdom', __FILE__
a84d745 Florian R. Hanke + DSL rewrite
authored
37 require File.expand_path '../phony/country_definitions', __FILE__
03dc48d Florian R. Hanke - old code (80% replaced), + preparation for new features
authored
38
cedc4c2 Florian R. Hanke + phony rename
authored
39 module Phony
38d6a14 Florian R. Hanke + germany
authored
40
98cc263 Florian R. Hanke + vanity, normalize
authored
41 # Phony uses a single country codes instance.
42 #
43eed69 Florian R. Hanke + DSL rewrite almost finished
authored
43 @codes = CountryCodes.instance
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
44
45 # Normalizes the given number.
46 #
47 # Useful before inserting the number into a database.
31085d7 Florian R. Hanke + README, + gem, + Rakefile, + gemspec, + setup
authored
48 #
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
49 def self.normalize phone_number
40d86c8 Florian R. Hanke + bang methods, + docs, + specs
authored
50 normalize! phone_number.dup
51 end
52 def self.normalize! phone_number
53 @codes.normalize phone_number
31085d7 Florian R. Hanke + README, + gem, + Rakefile, + gemspec, + setup
authored
54 end
1b0c34f Florian R. Hanke + massive rewrite, needs cleanup
authored
55
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
56 # Splits the phone number into pieces according to the country codes.
31085d7 Florian R. Hanke + README, + gem, + Rakefile, + gemspec, + setup
authored
57 #
660a0c3 Florian R. Hanke + total rewrite of phony. Faster, more readable, easier expandable
authored
58 def self.split phone_number
40d86c8 Florian R. Hanke + bang methods, + docs, + specs
authored
59 split! phone_number.dup
60 end
61 def self.split! phone_number
62 @codes.split phone_number
31085d7 Florian R. Hanke + README, + gem, + Rakefile, + gemspec, + setup
authored
63 end
1b0c34f Florian R. Hanke + massive rewrite, needs cleanup
authored
64
e650d67 Florian R. Hanke + let's not be too enthusiastic
authored
65 # Formats a E164 number according to local customs.
9c05e49 Florian R. Hanke + US, France, Switzerland, New Zealand,...
authored
66 #
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
67 def self.formatted phone_number, options = {}
b742c4f Florian R. Hanke + cleanup
authored
68 formatted! phone_number.dup, options
3e8fd89 Florian R. Hanke + normalizing numbers
authored
69 end
b742c4f Florian R. Hanke + cleanup
authored
70 def self.formatted! phone_number, options = {}
40d86c8 Florian R. Hanke + bang methods, + docs, + specs
authored
71 @codes.formatted phone_number, options
72 end
73
525e5f5 Florian R. Hanke + vanity number handling
authored
74 # def self.service? number
75 # @codes.service? number.dup
76 # end
77 # def self.mobile? number
78 # @codes.mobile? number.dup
79 # end
80 # def self.landline? number
81 # @codes.landline? number.dup
82 # end
b742c4f Florian R. Hanke + cleanup
authored
83
660a0c3 Florian R. Hanke + total rewrite of phony. Faster, more readable, easier expandable
authored
84 # Returns true if there is a character in the number
85 # after the first four numbers.
eaad76e Andi Schacke + vanity_number handling
andi authored
86 #
660a0c3 Florian R. Hanke + total rewrite of phony. Faster, more readable, easier expandable
authored
87 def self.vanity? phone_number
98cc263 Florian R. Hanke + vanity, normalize
authored
88 @codes.vanity? phone_number.dup
eaad76e Andi Schacke + vanity_number handling
andi authored
89 end
90
ebaa3a2 Florian R. Hanke + rewrite, split finished
authored
91 # Converts any character in the vanity_number to its numeric representation.
eaad76e Andi Schacke + vanity_number handling
andi authored
92 # Does not check if the passed number is a valid vanity_number, simply does replacement.
93 #
147134d Florian R. Hanke + vanity number rewrite
authored
94 def self.vanity_to_number vanity_number
98cc263 Florian R. Hanke + vanity, normalize
authored
95 @codes.vanity_to_number vanity_number.dup
eaad76e Andi Schacke + vanity_number handling
andi authored
96 end
97
c8c60f8 Florian R. Hanke + e164 basics
authored
98 end
Something went wrong with that request. Please try again.