README.md in phonofy-0.1.1 vs README.md in phonofy-0.1.2

- old
+ new

@@ -1,44 +1,81 @@ # Phonofy -TODO: Delete this and the text below, and describe your gem +Phonofy is a Ruby gem that simplifies phone number formatting in Rails applications using the Phonelib library. With Phonofy, you can easily parse and format phone number data according to international standards, ensuring that your phone number data is consistent and valid across your application. -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/phonofy`. To experiment with that code, run `bin/console` for an interactive prompt. - ## Installation -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. +Add this line to your application's Gemfile: -Install the gem and add to the application's Gemfile by executing: +```ruby +gem 'phonofy' +``` - $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG +And then execute: -If bundler is not being used to manage dependencies, install the gem by executing: +```shell +bundle +``` - $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG +Or install it yourself as: -## Usage +```shell +gem install phonofy +``` -TODO: Write usage instructions here +## **Usage** +To use phonofy, simply call the **phonofy** method in your Rails model: -To access configs: +```ruby +class User < ApplicationRecord + phonofy +end ``` -User.phonofy_configs + +This will add phone number validation and formatting to the **phone_number** attribute of the **Driver** model. + +You can also specify a custom attribute name for the phone number: + +```ruby +class Contact < ApplicationRecord + phonofy :mobile_number +end ``` -## Development +This will add phone number validation and formatting to the **mobile_number** attribute of the **Contact** model. -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +You can also pass additional options to phonofy to customize its behavior: -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). +```ruby +class User < ApplicationRecord + phonofy :phone, phonelib: { countries: [:us, :ca], types: [:mobile] } +end +``` -## Contributing +This will add phone number validation and formatting to the **phone** attribute of the **User** model, and restrict it to US and Canada mobile phone numbers. -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/phonofy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/phonofy/blob/main/CODE_OF_CONDUCT.md). -## License +## **Configuration** +You can configure phonofy by creating an initializer file in your Rails application and setting the default options: + +```ruby +# config/initializers/phonofy.rb +Phonofy.configure do |config| + config.default_phonelib_options = { countries: [:us, :ca], types: [:mobile] } + config.default_twilio_options = { lookup: { type: :carrier_type } } +end +``` + +This will set the default options for phonofy to validate only US and Canada mobile phone numbers using the Phonelib library, and perform a Twilio lookup to get carrier information for the phone number. + +## **Contributing** + +Bug reports and pull requests are welcome on GitHub at https://github.com/shqear93/phonofy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct. + +## **License** + The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). -## Code of Conduct +## **Credits** -Everyone interacting in the Phonofy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/phonofy/blob/main/CODE_OF_CONDUCT.md). +phonofy was created by Khaled AbuShqear and is maintained by a community of contributors. \ No newline at end of file