dialy 0.3.0 → 0.4.0
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/README.rdoc +4 -0
- data/VERSION +1 -1
- data/dialy.gemspec +22 -25
- data/lib/dialy/formatter.rb +13 -2
- data/spec/dialy_spec.rb +9 -0
- data/spec/spec_helper.rb +1 -7
- metadata +8 -9
- data/.gitignore +0 -21
data/README.rdoc
CHANGED
@@ -21,6 +21,10 @@ Because the area codes in Germany, Austria and Switzerland have different length
|
|
21
21
|
Dialy::Config[:default_country_code] = 49
|
22
22
|
Dialy::Number.new('0221/123456').to_s
|
23
23
|
# => '+49 221 1234567'
|
24
|
+
|
25
|
+
# Display national number without country code
|
26
|
+
Dialy::Number.new('0221/123456').to_s(:short)
|
27
|
+
# => '(0221) 1234567'
|
24
28
|
|
25
29
|
|
26
30
|
== Install
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/dialy.gemspec
CHANGED
@@ -1,53 +1,50 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dialy}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Georg Ledermann"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-03-25}
|
13
13
|
s.description = %q{Knows all area codes from Germany, Austria and Switzerland}
|
14
14
|
s.email = %q{mail@georg-ledermann.de}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
"spec/spec_helper.rb"
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"dialy.gemspec",
|
26
|
+
"lib/dialy.rb",
|
27
|
+
"lib/dialy/config.rb",
|
28
|
+
"lib/dialy/data.rb",
|
29
|
+
"lib/dialy/data/at.rb",
|
30
|
+
"lib/dialy/data/ch.rb",
|
31
|
+
"lib/dialy/data/countries.rb",
|
32
|
+
"lib/dialy/data/de.rb",
|
33
|
+
"lib/dialy/formatter.rb",
|
34
|
+
"spec/dialy_spec.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb"
|
38
37
|
]
|
39
38
|
s.homepage = %q{http://github.com/ledermann/dialy}
|
40
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
41
39
|
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = %q{1.
|
40
|
+
s.rubygems_version = %q{1.6.2}
|
43
41
|
s.summary = %q{Formatting phone numbers in E.123}
|
44
42
|
s.test_files = [
|
45
43
|
"spec/dialy_spec.rb",
|
46
|
-
|
44
|
+
"spec/spec_helper.rb"
|
47
45
|
]
|
48
46
|
|
49
47
|
if s.respond_to? :specification_version then
|
50
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
48
|
s.specification_version = 3
|
52
49
|
|
53
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/lib/dialy/formatter.rb
CHANGED
@@ -20,8 +20,19 @@ module Dialy
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# String representation in E.123 format
|
23
|
-
def to_s
|
24
|
-
|
23
|
+
def to_s(format=:international)
|
24
|
+
case format
|
25
|
+
when :international
|
26
|
+
"+#{@country_code} #{[ @area_code, @number ].compact.join(' ')}"
|
27
|
+
when :short
|
28
|
+
if @country_code == Config[:default_country_code]
|
29
|
+
"(0#{@area_code}) #{@number}"
|
30
|
+
else
|
31
|
+
to_s(:international)
|
32
|
+
end
|
33
|
+
else
|
34
|
+
raise ArgumentError
|
35
|
+
end
|
25
36
|
end
|
26
37
|
|
27
38
|
private
|
data/spec/dialy_spec.rb
CHANGED
@@ -55,6 +55,15 @@ describe "Dialy" do
|
|
55
55
|
it "should format with missing 0" do
|
56
56
|
Dialy::Number.new('240612345678').to_s.should == @expected
|
57
57
|
end
|
58
|
+
|
59
|
+
it "should format german number in short format" do
|
60
|
+
Dialy::Number.new('+49 2406 12345678').to_s(:short).should == '(02406) 12345678'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should format number from other country always in long format" do
|
64
|
+
Dialy::Number.new('+41 71 1234567').to_s.should == '+41 71 1234567'
|
65
|
+
Dialy::Number.new('+41 71 1234567').to_s(:short).should == '+41 71 1234567'
|
66
|
+
end
|
58
67
|
end
|
59
68
|
|
60
69
|
describe "German mobile" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dialy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Georg Ledermann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-25 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -45,7 +45,6 @@ extra_rdoc_files:
|
|
45
45
|
- README.rdoc
|
46
46
|
files:
|
47
47
|
- .document
|
48
|
-
- .gitignore
|
49
48
|
- LICENSE
|
50
49
|
- README.rdoc
|
51
50
|
- Rakefile
|
@@ -67,8 +66,8 @@ homepage: http://github.com/ledermann/dialy
|
|
67
66
|
licenses: []
|
68
67
|
|
69
68
|
post_install_message:
|
70
|
-
rdoc_options:
|
71
|
-
|
69
|
+
rdoc_options: []
|
70
|
+
|
72
71
|
require_paths:
|
73
72
|
- lib
|
74
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -92,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
91
|
requirements: []
|
93
92
|
|
94
93
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.
|
94
|
+
rubygems_version: 1.6.2
|
96
95
|
signing_key:
|
97
96
|
specification_version: 3
|
98
97
|
summary: Formatting phone numbers in E.123
|