This repository has been archived by the owner on May 26, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.0.0, converted from plugin to gem
- Loading branch information
Showing
4 changed files
with
90 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
NumberRecognizer | ||
================ | ||
|
||
NumberRecognizer is library to recognize mobile phone numbers. It can make educated guesses to correct local numbers into numbers in international format. | ||
|
||
Examples | ||
-------- | ||
|
||
require "number_recognizer" | ||
@nc = NumberRecognizer.new("0612345678") | ||
@nc.valid_or_correct_mobile? # => true | ||
@nc.country_name # => "Netherlands" | ||
@nc.country # => "31" | ||
@nc.prefix # => "31" | ||
@nc.local_number # => "612345678" | ||
@nc.normalized_number # => "31612345678" | ||
|
||
Supported countries | ||
------------------- | ||
|
||
It does not aim for worldwide coverage and correction, as that is not the problem I'm trying to solve. | ||
If you want to add a country, feel free to send me a pull request or create a feature request. | ||
|
||
* Australia (614xxxxxxxx) | ||
* Belgium (324xxxxxxxx) | ||
* England (447xxxxxxxx, 447xxxxxxxxx) | ||
* Germany (491xxxxxxxxx, 491xxxxxxxxxx) | ||
* Netherlands (316xxxxxxxx) | ||
* Portugal (3519xxxxxxxx) | ||
* Spain (346xxxxxxxx, 347xxxxxxxx) | ||
|
||
Some countries have some number ranges not covered. The regular expressions cover those, so check [lib/number_recognizer.rb](http://github.com/Narnach/number_recognizer/blob/master/lib/number_recognizer.rb) for the details. | ||
|
||
It is also possible to add your own custom format: | ||
|
||
NumberRecognizer.add_format :country => "Utopia", :mobile=>true, :format => /(99)(9\d{8})/, :country_code=>999 | ||
|
||
Installation | ||
------------ | ||
|
||
Simply install the gem from rubygems: | ||
|
||
gem install number_recognizer | ||
|
||
If you use Bundler, add it to your Gemfile and the do a bundle install: | ||
|
||
gem "number_recognizer" | ||
|
||
Bug tracking / feature requests | ||
------------------------------- | ||
|
||
I use Github issues for this: https://github.com/Narnach/number_recognizer/issues | ||
|
||
Disclaimer | ||
---------- | ||
|
||
It scratches my own itch and does not aim to solve everyone's problems. | ||
If it works for you, great! If it does not; fork it, patch it and send me a pull request. | ||
|
||
Written by Wes 'Narnach' Oldenbeuving in 2009. Licensed under the MIT license. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Gem::Specification.new do |s| | ||
# Project | ||
s.name = 'number_recognizer' | ||
s.summary = "NumberRecognizer is library to recognize mobile phone numbers. It can make educated guesses to correct local numbers into numbers in international format." | ||
s.description = s.summary | ||
s.version = '1.0.0' | ||
s.date = '2012-03-27' | ||
s.platform = Gem::Platform::RUBY | ||
s.authors = ["Wes Oldenbeuving"] | ||
s.email = "narnach@me.com" | ||
s.homepage = "http://www.github.com/narnach/number_recognizer" | ||
|
||
# Files | ||
root_files = %w[Readme.md number_recognizer.gemspec MIT-LICENSE] | ||
bin_files = [] | ||
lib_files = %w[number_recognizer number_recognizer/format_dsl] | ||
s.bindir = "bin" | ||
s.require_path = "lib" | ||
s.executables = bin_files | ||
s.test_files = %w[number_recognizer].map{|f| "spec/#{f}_spec.rb"} | ||
s.files = root_files + s.test_files + bin_files.map {|f| 'bin/%s' % f} + lib_files.map {|f| 'lib/%s.rb' % f} + %w[spec/spec_helper.rb] | ||
|
||
# rdoc | ||
s.has_rdoc = true | ||
s.extra_rdoc_files = %w[ Readme.md] | ||
s.rdoc_options << '--inline-source' << '--line-numbers' << '--main' << 'Readme.md' | ||
|
||
# Requirements | ||
s.required_ruby_version = ">= 1.8.0" | ||
end |