dialy 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.3.0
1
+ 0.4.0
@@ -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 the gemspec command
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.3.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{2010-10-05}
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
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "dialy.gemspec",
27
- "lib/dialy.rb",
28
- "lib/dialy/config.rb",
29
- "lib/dialy/data.rb",
30
- "lib/dialy/data/at.rb",
31
- "lib/dialy/data/ch.rb",
32
- "lib/dialy/data/countries.rb",
33
- "lib/dialy/data/de.rb",
34
- "lib/dialy/formatter.rb",
35
- "spec/dialy_spec.rb",
36
- "spec/spec.opts",
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.3.7}
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
- "spec/spec_helper.rb"
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
@@ -20,8 +20,19 @@ module Dialy
20
20
  end
21
21
 
22
22
  # String representation in E.123 format
23
- def to_s
24
- "+#{@country_code} #{[ @area_code, @number ].compact.join(' ')}"
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
@@ -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
@@ -1,9 +1,3 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'dialy'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end
3
+ require 'dialy'
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: 19
5
- prerelease: false
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.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: 2010-10-05 00:00:00 +02:00
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
- - --charset=UTF-8
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.3.7
94
+ rubygems_version: 1.6.2
96
95
  signing_key:
97
96
  specification_version: 3
98
97
  summary: Formatting phone numbers in E.123
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC