e164 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'jeweler'
4
+ gem 'jeweler', :git => 'https://github.com/helios/jeweler.git'
5
5
  gem 'rspec'
6
6
  end
@@ -1,27 +1,30 @@
1
+ GIT
2
+ remote: https://github.com/helios/jeweler.git
3
+ revision: 948e4a7b1552a921c4d5b2968ed8fa40e45cfd20
4
+ specs:
5
+ jeweler (1.6.0)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+
1
10
  GEM
2
11
  remote: http://rubygems.org/
3
12
  specs:
4
13
  diff-lcs (1.1.2)
5
14
  git (1.2.5)
6
- jeweler (1.5.2)
7
- bundler (~> 1.0.0)
8
- git (>= 1.2.5)
9
- rake
10
- rake (0.8.7)
11
- rspec (2.0.1)
12
- rspec-core (~> 2.0.1)
13
- rspec-expectations (~> 2.0.1)
14
- rspec-mocks (~> 2.0.1)
15
- rspec-core (2.0.1)
16
- rspec-expectations (2.0.1)
17
- diff-lcs (>= 1.1.2)
18
- rspec-mocks (2.0.1)
19
- rspec-core (~> 2.0.1)
20
- rspec-expectations (~> 2.0.1)
15
+ rake (0.9.0)
16
+ rspec (2.6.0)
17
+ rspec-core (~> 2.6.0)
18
+ rspec-expectations (~> 2.6.0)
19
+ rspec-mocks (~> 2.6.0)
20
+ rspec-core (2.6.3)
21
+ rspec-expectations (2.6.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.6.0)
21
24
 
22
25
  PLATFORMS
23
26
  ruby
24
27
 
25
28
  DEPENDENCIES
26
- jeweler
29
+ jeweler!
27
30
  rspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{e164}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
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{2011-04-06}
12
+ s.date = %q{2011-05-26}
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.}
@@ -3,9 +3,9 @@ module E164
3
3
  Dir.glob(File.join(File.dirname(__FILE__), 'e164/*.rb')).each {|f| require f }
4
4
 
5
5
  ValidFormat = /^\+([\d]{1,3})([\d]{1,14})$/
6
- Identifiers = ['+','011']
6
+ Identifiers = ['+','011', '00']
7
7
  DefaultIdentifier = '+'
8
- DefaultCountryCode = '1'
8
+ DefaultCountryCode = '1' # Override by E164.set_default_country_code!()
9
9
 
10
10
  def self.normalize(num)
11
11
  parse(num).unshift(DefaultIdentifier).join
@@ -51,4 +51,10 @@ module E164
51
51
 
52
52
  [num.shift, num.shift(destination_code_length).join, *num]
53
53
  end
54
+
55
+ def self.set_default_country_code!(country_code)
56
+ ret_value = remove_const(:DefaultCountryCode)
57
+ const_set(:DefaultCountryCode, country_code)
58
+ ret_value
59
+ end
54
60
  end
@@ -8,6 +8,18 @@ describe E164 do
8
8
  it 'should set DefaultCountryCode to 1(NANP)' do
9
9
  E164::DefaultCountryCode.should == '1'
10
10
  end
11
+
12
+ describe '#set_default_country_code!' do
13
+ it 'should override DefaultCountryCode' do
14
+ original = E164.set_default_country_code!('44')
15
+ begin
16
+ E164::DefaultCountryCode.should == '44'
17
+ ensure
18
+ # set back original DefaultCountryCode's value
19
+ E164.set_default_country_code!(original)
20
+ end
21
+ end
22
+ end
11
23
 
12
24
  describe '#normalize' do
13
25
  it 'should remove all non-numeric punctuation except the e164 identifier prefix' do
@@ -25,5 +37,9 @@ describe E164 do
25
37
  it "shouldn't die on german numbers" do
26
38
  lambda { E164.normalize('+4988612345670') }.should_not raise_error
27
39
  end
40
+
41
+ it 'should handle 00 identifier' do
42
+ E164.normalize('00441234567890').should == '+441234567890'
43
+ end
28
44
  end
29
45
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e164
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - hexorx
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-06 00:00:00 -06:00
18
+ date: 2011-05-26 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency