uk_phone_numbers 0.1.0 → 0.1.1
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.
- data/CHANGELOG.md +8 -0
- data/lib/uk_phone_numbers.rb +2 -2
- data/lib/uk_phone_numbers/version.rb +1 -1
- data/spec/uk_phone_numbers_spec.rb +9 -5
- metadata +16 -9
data/CHANGELOG.md
ADDED
data/lib/uk_phone_numbers.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module UKPhoneNumbers
|
|
2
|
-
# http://www.area-codes.org.uk/formatting.
|
|
2
|
+
# http://www.area-codes.org.uk/formatting.php#programmers
|
|
3
3
|
PATTERNS = <<-PATTERNS
|
|
4
4
|
(01###) #####[#]
|
|
5
5
|
(011#) ### ####
|
|
@@ -31,7 +31,7 @@ module UKPhoneNumbers
|
|
|
31
31
|
regexp = regexp.split.map { |p| "(#{p})" }.join
|
|
32
32
|
regexp.gsub!(/\[([^\]]*)\]/, '(?:\1)?')
|
|
33
33
|
regexp.gsub!(/#/, '\d')
|
|
34
|
-
Regexp.new("
|
|
34
|
+
Regexp.new("\\A#{regexp}\\z")
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
REGEXPS = []
|
|
@@ -16,23 +16,23 @@ describe UKPhoneNumbers do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "strips parens from the pattern" do
|
|
19
|
-
regexp_for("()").
|
|
19
|
+
regexp_for("()").should_not include("()")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "parenthesises whitespace-separated sections" do
|
|
23
|
-
regexp_for("0 12 345").should
|
|
23
|
+
regexp_for("0 12 345").should include("(0)(12)(345)")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "replaces # with \\d" do
|
|
27
|
-
regexp_for("0#").should
|
|
27
|
+
regexp_for("0#").should include("(0\\d)")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "replaces bracketed expressions with optional non-capturing groups" do
|
|
31
|
-
regexp_for("0[12]3[4]5").should
|
|
31
|
+
regexp_for("0[12]3[4]5").should include("(0(?:12)?3(?:4)?5)")
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "handles hashes inside brackets" do
|
|
35
|
-
regexp_for("0[#]1[#]2").should
|
|
35
|
+
regexp_for("0[#]1[#]2").should include("(0(?:\\d)?1(?:\\d)?2)")
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -44,6 +44,10 @@ describe UKPhoneNumbers do
|
|
|
44
44
|
it "returns false for invalid numbers" do
|
|
45
45
|
subject.valid?('08456123123123').should be_false
|
|
46
46
|
end
|
|
47
|
+
|
|
48
|
+
it "returns false for multiline strings containing a valid number" do
|
|
49
|
+
subject.valid?("08456123123\nnotaphonenumber\n").should be_false
|
|
50
|
+
end
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
describe ".format" do
|
metadata
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uk_phone_numbers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0
|
|
5
4
|
prerelease:
|
|
5
|
+
version: 0.1.1
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Harry Marr
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
|
|
16
|
-
requirement: &70215946414560 !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
18
16
|
requirements:
|
|
19
17
|
- - ~>
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '2.6'
|
|
20
|
+
none: false
|
|
21
|
+
name: rspec
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
|
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ~>
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '2.6'
|
|
29
|
+
none: false
|
|
25
30
|
description:
|
|
26
31
|
email:
|
|
27
32
|
- harry@gocardless.com
|
|
@@ -30,6 +35,7 @@ extensions: []
|
|
|
30
35
|
extra_rdoc_files: []
|
|
31
36
|
files:
|
|
32
37
|
- .gitignore
|
|
38
|
+
- CHANGELOG.md
|
|
33
39
|
- Gemfile
|
|
34
40
|
- LICENSE
|
|
35
41
|
- README.md
|
|
@@ -44,22 +50,23 @@ rdoc_options: []
|
|
|
44
50
|
require_paths:
|
|
45
51
|
- lib
|
|
46
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
-
none: false
|
|
48
53
|
requirements:
|
|
49
54
|
- - ! '>='
|
|
50
55
|
- !ruby/object:Gem::Version
|
|
51
56
|
version: '0'
|
|
52
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
57
|
none: false
|
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
59
|
requirements:
|
|
55
60
|
- - ! '>='
|
|
56
61
|
- !ruby/object:Gem::Version
|
|
57
62
|
version: '0'
|
|
63
|
+
none: false
|
|
58
64
|
requirements: []
|
|
59
65
|
rubyforge_project:
|
|
60
|
-
rubygems_version: 1.8.
|
|
66
|
+
rubygems_version: 1.8.23
|
|
61
67
|
signing_key:
|
|
62
68
|
specification_version: 3
|
|
63
69
|
summary: A Ruby library for parsing and formatting UK phone numbers.
|
|
64
70
|
test_files:
|
|
65
71
|
- spec/uk_phone_numbers_spec.rb
|
|
72
|
+
has_rdoc:
|