Browse files

+ greece

  • Loading branch information...
1 parent 332d1bd commit 29ea6bb028c709eb17b1fe4acda6549db4bdc7e2 @floere committed Nov 19, 2010
View
1 lib/phony.rb
@@ -23,6 +23,7 @@
require File.expand_path '../phony/countries/austria', __FILE__
require File.expand_path '../phony/countries/egypt', __FILE__
require File.expand_path '../phony/countries/germany', __FILE__
+require File.expand_path '../phony/countries/greece', __FILE__
require File.expand_path '../phony/countries/hungary', __FILE__
require File.expand_path '../phony/countries/italy', __FILE__
View
2 lib/phony/countries/all_other.rb
@@ -44,7 +44,7 @@ def self.mapping
:local_format => [3, 4]
),
- '30' => fixed(2), # Greece
+ '30' => Countries::Greece,
'31' => fixed(2), # Netherlands
'32' => fixed(1, # Belgium
:local_format => [3, 4]
View
30 lib/phony/countries/greece.rb
@@ -0,0 +1,30 @@
+# Greece uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
+#
+# Note: Greece uses a variable ndc format from length 2 to 4.
+# To save space, we only use ndcs of length up to 3 (and use the fallback).
+#
+Phony::Countries::Greece = Phony::Country.configured :local_format => [6],
+ :ndc_fallback_length => 4,
+ :ndc_mapping => {
+ :landline => [
+ '21', # Athens
+ '231', # Thessaloniki
+ '241', # Larissa
+ '251', # Kavala
+ '261', # Patras
+ '271', # Tripoli
+ '281', # Heraklion
+ ],
+ :mobile => [
+ '690',
+ '693',
+ '694',
+ '695',
+ '697',
+ '698',
+ '699'
+ ],
+ :service => [ # TODO
+ '800'
+ ]
+ }
View
18 spec/lib/phony/countries/greece_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe Phony::Countries::Greece do
+
+ before(:each) do
+ @greece = Phony::Countries::Greece
+ end
+
+ describe "split" do
+ it 'works' do
+ @greece.split('21123456').should == ['21', '123456']
+ end
+ it 'works' do
+ @greece.split('25941234').should == ['2594', '1234']
+ end
+ end
+
+end
View
4 spec/lib/phony/countries/hungary_spec.rb
@@ -7,10 +7,10 @@
end
describe "split" do
- it "should handle Budapest" do
+ it 'handles Budapest' do
@hungary.split('12345678').should == ['1', '234', '5678']
end
- it "should handle Cologne" do
+ it 'works' do
@hungary.split('22123456').should == ['22', '123', '456']
end
end
View
3 spec/lib/phony_spec.rb
@@ -17,6 +17,9 @@
it "should handle german numbers" do
Phony.split('4976112345').should == ['49', '761', '123', '45']
end
+ it "should handle greek numbers" do
+ Phony.split('3022631234').should == ['30', '2263', '1234']
+ end
it "should handle hungarian numbers" do
Phony.split('3612345678').should == ['36', '1', '234', '5678']
end

0 comments on commit 29ea6bb

Please sign in to comment.