Skip to content

Commit

Permalink
Add reserved keyword to Phony DSL.
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Sep 13, 2014
1 parent 5d824cc commit 9b4234a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
4 changes: 4 additions & 0 deletions history.textile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
h2. Version 2.3.0

* hanke: Introduces the reserved DSL. If reserved, any operation on a number fails.

h2. Version 2.2.16

* hanke: Fixes for Spain and Austria (Thanks, see #176, #177).
Expand Down
16 changes: 8 additions & 8 deletions lib/phony/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Reserved.
#
#country '0', fixed(1) >> split(10) # Reserved.
reserved '0'

# USA, Canada, etc.
#
Expand Down Expand Up @@ -878,11 +878,11 @@
country '872', todo # Inmarsat (Pacific Ocean)
country '873', todo # Inmarsat (Indian Ocean)
country '874', todo # Inmarsat (Atlantic Ocean-West)
country '875', todo # Reserved - Maritime Mobile Service Applications
country '876', todo # Reserved - Maritime Mobile Service Applications
country '877', todo # Reserved - Maritime Mobile Service Applications
country '875', todo # Maritime Mobile Service Applications
country '876', todo # Maritime Mobile Service Applications
country '877', todo # Maritime Mobile Service Applications
country '878', todo # Universal Personal Telecommunication Service (UPT)
country '879', todo # Reserved for national non-commercial purposes
reserved '879' # Reserved for national non-commercial purposes

# Bangladesh (People's Republic of)
# country '880' # see special file
Expand All @@ -896,7 +896,7 @@
# country '886' # Taiwan, see special file

country '887', todo # -
country '888', todo # Reserved for future global service
reserved '888' # Reserved for future global service
country '889', todo # -

country '890', todo # -
Expand Down Expand Up @@ -982,7 +982,7 @@
# Oman (Sultanate of), https://www.numberingplans.com/?page=dialling&sub=areacodes
country '968', fixed(2) >> split(3,3)

country '969', todo # Reserved - reservation currently under investigation
reserved '969' # Reserved - reservation currently under investigation

country '970', # 970 is used in those countries that block access to 972 (Israel)
one_of('1') >> split(3,3,3) | # special numbers
Expand Down Expand Up @@ -1054,5 +1054,5 @@

country '997', todo # Spare code
country '998', fixed(2) >> split(3, 4) # Uzbekistan (Republic of) http://www.wtng.info/wtng-998-uz.html
country '999', todo # Reserved for possible future use within the Telecommunications for Disaster Relief (TDR) concept
reserved '999' # Reserved for possible future use within the Telecommunications for Disaster Relief (TDR) concept
end
18 changes: 12 additions & 6 deletions lib/phony/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ def country country_code, definition, options = {}
Phony::CountryCodes.instance.add country_code, definition
end

# Designates a country code as reserved.
#
def reserved country_code
# Does nothing, will just fail with an exception.
end

# This country still uses a default NDC (and needs to be done, hence the todo).
#
def todo
none >> split(10)
end

#
#
def trunk code, options = {}
Expand Down Expand Up @@ -131,12 +143,6 @@ def match regex, options = {}

NationalSplitters::Regex.instance_for regex, options[:on_fail_take], options
end

# This country still uses a default NDC (and needs to be done, hence the todo).
#
def todo
none >> split(10)
end

# Local splitters.
#
Expand Down
4 changes: 4 additions & 0 deletions lib/phony/national_splitters/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def country_for local_splitter
Phony::Country.new Phony::NationalCode.new(self, local_splitter)
end

def reserved

end

end

end
Expand Down
2 changes: 1 addition & 1 deletion phony.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'phony'
s.version = '2.2.16'
s.version = '2.3.0'
s.authors = ['Florian Hanke']
s.email = 'florian.hanke+phony@gmail.com'
s.homepage = 'http://github.com/floere/phony'
Expand Down

0 comments on commit 9b4234a

Please sign in to comment.