Project

cogi_phony

0.0
No commit activity in last 3 years
No release in over 3 years
This gem provide you library to validate, parsing and format phone number, detect phone network in Vietnam.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 10.0
~> 2.0

Runtime

~> 2.15
 Project Readme

CogiPhony Build Status Coverage Status GitHub issues Gem Version

This gem provide you library to validate, parsing, format and normalize phone number, detect phone network in Vietnam.

It uses the super awesome Phony gem (https://github.com/floere/phony).

Installation

Add this line to your application's Gemfile:

gem 'cogi_phony'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cogi_phony

Usage

Validation

Check if a string is a valid phone number.

CogiPhony.validate? '+14037089189' # => true

Normalization

Normalize phone numer to international format.

CogiPhony.normalize '+1 (403) 708-9189' # => '+14037089189'

Formatting

Format formats phone numbers according to the predominant format of a country.

CogiPhony.format '+84933081090' # => +84 93 3081090
CogiPhony.format '+84933081090', format: 'global' # => '+84 93 3081090'
CogiPhony.format '+84933081090', format: 'vietnam' # => '093 3081090'

Extract country code

Extract country code from phone number.

CogiPhony.country_code_from_number '+84933081090' # => '84'

Check if Vietnam mobile phone

Check if phone number is Vietnam mobile phone format

CogiPhony.vn_mobile_phone? '+84933081090' # => true

Phone provider

Return phone provider from phone number.

CogiPhony.phone_to_provider '+84933081090' # => 'Mobifone'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Don't forget to add tests and run rspec before creating a pull request :)

See all contributors on https://github.com/hoahm/cogi_phony/graphs/contributors.