e164 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,84 @@
1
+ E164
2
+ ====
3
+
4
+ E164 is a standard for formatting and routing international phone numbers. The goal of this gem is to make working with these numbers simpler. The E164 standard is composed of the following parts:
5
+
6
+ * International Access Code (IAC)
7
+ * Country Code (CC)
8
+ * National Destination Code (NDC)
9
+ * Subscriber Number (SN)
10
+
11
+ Right now the gem has the ability to parse out these 4 fields and normalize them to a standard format. It also contains country information scraped from wikipedia. Information has been scraped for the North American Numbering Plan (NANP), Austria and Germany as well. Right now this is just basic information and I hope to expand it in the future.
12
+
13
+ Warning!
14
+ --------
15
+
16
+ This gem is both incomplete and very US/NANP centric. So check the results before using in production. If you have information on formatting or route data either fork and add it or contact me. The biggest challenge is going to be keeping data used for parsing up to date.
17
+
18
+ Installation
19
+ ------------
20
+
21
+ E164 is hosted on GemCutter, so simply run the following:
22
+
23
+ gem sources -a http://gemcutter.org
24
+ sudo gem install inherited_resources
25
+
26
+ Use It!
27
+ -------
28
+
29
+ E164 contains two main methods on the E164 module. The *parse* method takes a phone number as a string and returns an array containing CC,NDC and SN. If no IAC is found a default country is presumed. Right now the IAC's looked for are ['+','011'] and the default CC is 1 (NANP). Options to override the defaults will be coming soon.
30
+
31
+ E164.parse('3035559850') #=> ['1','303','5559850']
32
+ E164.parse('13035559850') #=> ['1','303','5559850']
33
+ E164.parse('+203035559850') #=> ['20','30','35559850']
34
+ E164.parse('011203035559850') #=> ['20','30','35559850']
35
+
36
+ The *normalize* method also takes a number as a string but returns it in the standard format. All it is really doing is parsing it and then joining the pieces.
37
+
38
+ E164.normalize('3035559850') #=> '+13035559850'
39
+ E164.normalize('13035559850') #=> '+13035559850'
40
+ E164.normalize('+203035559850') #=> '+203035559850'
41
+ E164.normalize('011203035559850') #=> '+203035559850'
42
+
43
+ Country info is stored in a hash of hashes with the CC being the key.
44
+
45
+ E164::CountryCodes['1'] #=> {:national_destination_codes => 3, :abbreviation => 'NANP', :description => 'North American Numbering Plan', :info => 'en.wikipedia.com.org/wiki/NANP'}
46
+
47
+ NDC information is available for:
48
+
49
+ * NANP
50
+ * Austria
51
+ * Germany
52
+
53
+ Just like the CountryCodes, NDC info is stored in a hash of hashes and accessed through a constant. Some NDCs will have more information than others.
54
+
55
+ E164::NANP('303') #=> {:abbreviation => 'Colorado', :description => '[Colorado] (Boulder, Longmont, Aurora, Denver and central Colorado, overlays with [720])', :info => 'en.wikipedia.com.org/wiki/Area_codes_303_and_720'}
56
+
57
+ E164::Austria['1'] => {:description => 'Wient'}
58
+
59
+ E164::Germany['10'] => {:description => 'Call-By-Call'}
60
+
61
+ ToDo
62
+ ----
63
+
64
+ * Country specific formatting
65
+ * Add overrides for default options
66
+ * Add data for more areas
67
+ * Link to additional info for countries (currency, timezone, etc.)
68
+
69
+ Note on Patches/Pull Requests
70
+ -----------------------------
71
+
72
+ * Fork the project.
73
+ * Make your feature addition or bug fix.
74
+ * Add tests for it. This is important so I don't break it in a
75
+ future version unintentionally.
76
+ * Commit, do not mess with rakefile, version, or history.
77
+ (if you want to have your own version, that is fine but
78
+ bump version in a commit by itself I can ignore when I pull)
79
+ * Send me a pull request. Bonus points for topic branches.
80
+
81
+ Copyright
82
+ ---------
83
+
84
+ Copyright (c) 2009 hexorx. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,24 +5,24 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{e164}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hexorx"]
12
- s.date = %q{2009-12-15}
12
+ s.date = %q{2009-12-16}
13
13
  s.description = %q{The e164 gem can parse and normalize numbers into the e164 format.
14
14
  It provides extra information on the Country Code and National Destination Codes.
15
15
  It can be used standalone or mixed into a model.}
16
16
  s.email = %q{hexorx@gmail.com}
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.rdoc"
19
+ "README.markdown"
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
23
  ".gitignore",
24
24
  "LICENSE",
25
- "README.rdoc",
25
+ "README.markdown",
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "e164.gemspec",
@@ -1,7 +1,7 @@
1
1
  Dir.glob(File.join(File.dirname(__FILE__), 'national_destination_codes/*.rb')).each {|f| require f }
2
2
 
3
3
  CountryCodes = {
4
- '1' => {:national_destination_codes => NANP, :abbreviation => 'NANP', :description => 'USA/NANP', :info => 'en.wikipedia.com.org/wiki/NANP'},
4
+ '1' => {:national_destination_codes => 3, :abbreviation => 'NANP', :description => 'North American Numbering Plan', :info => 'en.wikipedia.com.org/wiki/NANP'},
5
5
  '7' => {:national_destination_codes => 3, :abbreviation => '', :description => 'Russia', :info => 'en.wikipedia.com.org/wiki/Russia'},
6
6
 
7
7
  '20' => {:national_destination_codes => 2, :abbreviation => '', :description => 'Egypt', :info => 'en.wikipedia.com.org/wiki/Egypt'},
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e164
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hexorx
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-15 00:00:00 -07:00
12
+ date: 2009-12-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,12 +43,12 @@ extensions: []
43
43
 
44
44
  extra_rdoc_files:
45
45
  - LICENSE
46
- - README.rdoc
46
+ - README.markdown
47
47
  files:
48
48
  - .document
49
49
  - .gitignore
50
50
  - LICENSE
51
- - README.rdoc
51
+ - README.markdown
52
52
  - Rakefile
53
53
  - VERSION
54
54
  - e164.gemspec
@@ -1,18 +0,0 @@
1
- = e164
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but
13
- bump version in a commit by itself I can ignore when I pull)
14
- * Send me a pull request. Bonus points for topic branches.
15
-
16
- == Copyright
17
-
18
- Copyright (c) 2009 hexorx. See LICENSE for details.