Permalink
Browse files

- greece special file

  • Loading branch information...
1 parent cf11e22 commit 6f14f188dbc93b30b5936ace2203a824dd844387 @floere committed May 2, 2011
Showing with 7 additions and 29 deletions.
  1. +0 −1 lib/phony.rb
  2. +5 −1 lib/phony/countries.rb
  3. +0 −26 lib/phony/countries/greece.rb
  4. +2 −1 spec/lib/phony/countries_spec.rb
View
@@ -21,7 +21,6 @@
require File.expand_path '../phony/countries/chile', __FILE__
require File.expand_path '../phony/countries/china', __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__
require File.expand_path '../phony/countries/malaysia', __FILE__
@@ -44,7 +44,11 @@
#
country '27', fixed(2) >> split(3,4)
- # country '30' # Greece, see special file.
+ # Greece.
+ #
+ country '30', match(/^(2[3-8]?1|69[0345789]|800)\d+$/) >> split(6) | # Geo/Mobile
+ fixed(4) >> split(6) # 3-digit NDCs
+
# country '31' # Netherlands, see special file.
# Belgium.
@@ -1,26 +0,0 @@
-# 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).
-#
-ndcs = [
- '21', # Athens
- '231', # Thessaloniki
- '241', # Larissa
- '251', # Kavala
- '261', # Patras
- '271', # Tripoli
- '281', # Heraklion
- '690', # Mobile
- '693', # Mobile
- '694', # Mobile
- '695', # Mobile
- '697', # Mobile
- '698', # Mobile
- '699', # Mobile
- '800' # Service
-]
-
-Phony.define do
- country '30', one_of(ndcs, :max_length => 4) >> split(6)
-end
@@ -85,7 +85,8 @@
Phony.split('491815878323').should == ['49', '181', '587', '8323'] # Service numbers
end
it "handles greek numbers" do
- Phony.split('3021123456').should == ['30', '21', '123456']
+ Phony.split('3021123456').should == ['30', '21', '123456'] # Athens
+ Phony.split('3069512345').should == ['30', '695', '12345'] # Mobile
Phony.split('3025941234').should == ['30', '2594', '1234']
Phony.split('3022631234').should == ['30', '2263', '1234']
end

0 comments on commit 6f14f18

Please sign in to comment.