Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
Version 1.0.0, converted from plugin to gem
Browse files Browse the repository at this point in the history
  • Loading branch information
Narnach committed Mar 27, 2012
1 parent a5ac68b commit 956fa5f
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 46 deletions.
60 changes: 60 additions & 0 deletions README.md
@@ -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.
44 changes: 0 additions & 44 deletions README.rdoc

This file was deleted.

2 changes: 0 additions & 2 deletions init.rb

This file was deleted.

30 changes: 30 additions & 0 deletions number_recognizer.gemspec
@@ -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

0 comments on commit 956fa5f

Please sign in to comment.