haberbyte / phoney Goto Github PK
View Code? Open in Web Editor NEWRuby library that parses a phone number and automatically formats it correctly, depending on the country/locale you set.
License: MIT License
Ruby library that parses a phone number and automatically formats it correctly, depending on the country/locale you set.
License: MIT License
There have been few changes between 0.1.3 and master, some of which include the use of Ruby 1.9 hash keys (maybe there are bigger issues with 1.8.7?).
https://github.com/habermann24/phoney/blob/master/lib/data/regions.yml
This entry for +44 (in both gb and uk):
should be replaced with this:
This line is missing from the data:
The gb/uk data also does not appear to cater for 9-digit numbers beginning 500 or 800, nor for 7-digit numbers beginning 800 1111 or 845 46 47x.
Numbers in gb/uk beginning 500 are always 9 digits long. Numbers beginning 800 can be 7, 9 or 10 digits long. Numbers beginning 845 can be 7 or 10 digits long. All other numbers beginning 2, 3, 5, 7, 8, 9 are always 10 digits long.
There's also 40 areas in gb/uk where some numbers beginning 1xxx have only 9 digits, not the usual 10 (i.e. there is a mix of 9 and 10 digit numbers within the same area). One area code beginning 16977 also has some 9 digit numbers (those beginning 16977 2xxx and 16977 3xxx) while the rest of the numbers within the area have 10 digits.
http://www.aa-asterisk.org.uk/index.php/Number_format
http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
I'm also one of the contributors to Google's libphonenumber project.
$ gem install phoney
ERROR: Error installing phoney:
phoney requires phoney (>= 0)
$ gem install phoney -v '=0.1.0'
Fetching: phoney-0.1.0.gem (100%)
Successfully installed phoney-0.1.0
1 gem installed
$ gem install phoney
Successfully installed phoney-0.1.1
1 gem installed
I had intended to update the phone number patterns for GB/UK in /lib/data/regions.yml with some recent changes, but the file has been deleted.
I understand the project uses data in the binary file /lib/data/regions.bin now, but where does the data within that file come from?
I believe the data is possibly converted to the binary format using a utility, but I cannot find an editable file with the source data. Is it in a separate project?
> PhoneNumber.new('+74959374685').to_s
RuntimeError: Must enter number
Should be: +7 (495) 937-46-85
Consider using a more distinctive name to reduce chance of conflicts in the top-level namespace. (Maybe "Phoney::PhoneNumber" or just "Phoney")
I'd hate to have to fork phoney just because my app already has a "PhoneNumber" concept that I want in the global namespace.
Not sure whats going on but I can't seem to create any Phoney instances? This is very bizarre.
You can reproduce it by
pn=PhoneNumber.new('1234567',:na)
undefined method each' for nil:NilClass /bundle/ruby/2.0.0/gems/phoney-0.1.3/lib/phoney/parser.rb:187:in
get_dialout_prefix'
/bundle/ruby/2.0.0/gems/phoney-0.1.3/lib/phoney/parser.rb:26:in parse_to_parts' /bundle/ruby/2.0.0/gems/phoney-0.1.3/lib/phoney/base.rb:43:in
initialize'
I noticed the entire project is under a complete rewrite and the issue seems to be resolved. Just wondering when you plan to release another new version?
Thanks,
Dan
Version
$ gem list phoney --details
*** LOCAL GEMS ***
phoney (0.1.3)
Author: Jan Habermann
Homepage: http://github.com/habermann24/phoney
Installed at: /Users/craibuc/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
Ruby library that formats phone numbers.
IRB
irb(main):001:0> require 'phoney'
=> true
irb(main):002:0> pn = Phoney.new("+17041234567")
NameError: uninitialized constant Phoney
from (irb):4
from /Users/xxx/.rbenv/versions/2.2.2/bin/irb:11:in `<main>'
>> PhoneNumber.new("+4408701651420").to_s
=> "+44 08701651420"
Should be "+44 (0) 870 165 1420"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.