big-phoney 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,3 +22,6 @@ Also, check validity:
22
22
 
23
23
  The formatting and prefix type splitting stuff is still very US-centric. That will
24
24
  change as the need arises (or as you send me a pull request, you awesome developer you).
25
+
26
+
27
+ (Code heavily inspired by http://github.com/gitpan/Parse-PhoneNumber)
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{big-phoney}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Pat Nakajima"]
9
+ s.date = %q{2010-08-03}
10
+ s.files = ["LICENSE", "README.md", "big-phoney.gemspec", "lib/big-phoney.rb", "lib/big_phoney.rb", "lib/big_phoney/.gitignore", "lib/big_phoney/country_codes.rb", "spec/big_phoney_spec.rb", "spec/spec_helper.rb"]
11
+ s.require_paths = ["lib"]
12
+ s.rubygems_version = %q{1.3.7}
13
+ s.summary = %q{Simple phone number parsing in Ruby}
14
+
15
+ if s.respond_to? :specification_version then
16
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
17
+ s.specification_version = 3
18
+
19
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
20
+ else
21
+ end
22
+ else
23
+ end
24
+ end
data/lib/big-phoney.rb CHANGED
@@ -74,30 +74,20 @@ class PhoneNumber
74
74
  @number = "1#{@number}"
75
75
  end
76
76
 
77
- if PhoneNumber.assume_us?
78
- if $_ && $_ < MIN_US_LENGTH
79
- errors << :too_short
80
- else
81
- @country_code = "1"
82
- @number.sub!(/^1/, '')
83
- @num = $_
84
- end
85
- else
86
- 0.upto(2) do |len|
87
- break if @country_code
88
- if COUNTRY_CODES.include?(country_code = @number[0..len])
89
- @country_code ||= country_code
90
- @number.sub!(/^#{country_code}/, '')
91
- end
77
+ 0.upto(2) do |len|
78
+ break if @country_code
79
+ if COUNTRY_CODES.include?(country_code = @number[0..len])
80
+ @country_code ||= country_code
81
+ @number.sub!(/^#{country_code}/, '')
92
82
  end
83
+ end
93
84
 
94
- if @country_code.nil?
95
- errors << :country_code
96
- end
85
+ if @country_code.nil?
86
+ errors << :country_code
87
+ end
97
88
 
98
- if @country_code && "#{@country_code}#{@number}".size < MINLEN
99
- errors << :too_short
100
- end
89
+ if @number.size < MINLEN
90
+ errors << :too_short
101
91
  end
102
92
  end
103
93
  end
@@ -20,7 +20,7 @@ describe PhoneNumber do
20
20
  end
21
21
 
22
22
  it "is invalid when too short" do
23
- number = PhoneNumber.new('423432')
23
+ number = PhoneNumber.new('423432123')
24
24
  number.should_not be_valid
25
25
  number.errors.should include(:too_short)
26
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: big-phoney
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Nakajima
@@ -30,6 +30,7 @@ extra_rdoc_files: []
30
30
  files:
31
31
  - LICENSE
32
32
  - README.md
33
+ - big-phoney.gemspec
33
34
  - lib/big-phoney.rb
34
35
  - lib/big_phoney.rb
35
36
  - lib/big_phoney/.gitignore