phonofy 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +57 -20
- data/README.md.erb +12 -12
- data/Rakefile +2 -1
- data/lib/phonofy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b628ab1214d8aaf8e00487444e04d5bcb54346296a29ed9b50ff5a838f6639ff
|
4
|
+
data.tar.gz: c2641d00024c02b51d724a960f7e8cd8b603ecc79f1168961b315adb070e3fd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f7e112092e433f2db4513aa0ae8317632ffcf485e6f9bdb29b086de8e733e26d1a6859944e876fd08c20f5cc3e1d4298b4e4ffa2ad66fdb91cd3672b30fed2
|
7
|
+
data.tar.gz: 3ef7d410590278075723b4c263a9ef146f503ca7df101f507834060c08db1de671b9842089d3f67e446e1584682eaec07df25e5b545134842b50e0d8b1f6c775
|
data/README.md
CHANGED
@@ -1,44 +1,81 @@
|
|
1
1
|
# Phonofy
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
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.
|
3
|
+
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.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
Add this line to your application's Gemfile:
|
10
8
|
|
11
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'phonofy'
|
11
|
+
```
|
12
12
|
|
13
|
-
|
13
|
+
And then execute:
|
14
14
|
|
15
|
-
|
15
|
+
```shell
|
16
|
+
bundle
|
17
|
+
```
|
16
18
|
|
17
|
-
|
19
|
+
Or install it yourself as:
|
18
20
|
|
19
|
-
|
21
|
+
```shell
|
22
|
+
gem install phonofy
|
23
|
+
```
|
20
24
|
|
21
|
-
|
25
|
+
## **Usage**
|
26
|
+
To use phonofy, simply call the **phonofy** method in your Rails model:
|
22
27
|
|
23
|
-
|
28
|
+
```ruby
|
29
|
+
class User < ApplicationRecord
|
30
|
+
phonofy
|
31
|
+
end
|
24
32
|
```
|
25
|
-
|
33
|
+
|
34
|
+
This will add phone number validation and formatting to the **phone_number** attribute of the **Driver** model.
|
35
|
+
|
36
|
+
You can also specify a custom attribute name for the phone number:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
class Contact < ApplicationRecord
|
40
|
+
phonofy :mobile_number
|
41
|
+
end
|
26
42
|
```
|
27
43
|
|
28
|
-
|
44
|
+
This will add phone number validation and formatting to the **mobile_number** attribute of the **Contact** model.
|
45
|
+
|
46
|
+
You can also pass additional options to phonofy to customize its behavior:
|
29
47
|
|
30
|
-
|
48
|
+
```ruby
|
49
|
+
class User < ApplicationRecord
|
50
|
+
phonofy :phone, phonelib: { countries: [:us, :ca], types: [:mobile] }
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
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.
|
55
|
+
|
56
|
+
|
57
|
+
## **Configuration**
|
58
|
+
|
59
|
+
You can configure phonofy by creating an initializer file in your Rails application and setting the default options:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# config/initializers/phonofy.rb
|
63
|
+
Phonofy.configure do |config|
|
64
|
+
config.default_phonelib_options = { countries: [:us, :ca], types: [:mobile] }
|
65
|
+
config.default_twilio_options = { lookup: { type: :carrier_type } }
|
66
|
+
end
|
67
|
+
```
|
31
68
|
|
32
|
-
|
69
|
+
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.
|
33
70
|
|
34
|
-
## Contributing
|
71
|
+
## **Contributing**
|
35
72
|
|
36
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
73
|
+
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.
|
37
74
|
|
38
|
-
## License
|
75
|
+
## **License**
|
39
76
|
|
40
77
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
78
|
|
42
|
-
##
|
79
|
+
## **Credits**
|
43
80
|
|
44
|
-
|
81
|
+
phonofy was created by Khaled AbuShqear and is maintained by a community of contributors.
|
data/README.md.erb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# <%=
|
1
|
+
# <%= spec.name.capitalize %>
|
2
2
|
|
3
|
-
<%=
|
3
|
+
<%= spec.description %>
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem '<%=
|
10
|
+
gem '<%= spec.name %>'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -19,11 +19,11 @@ bundle
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
21
|
```shell
|
22
|
-
gem install <%=
|
22
|
+
gem install <%= spec.name %>
|
23
23
|
```
|
24
24
|
|
25
25
|
## **Usage**
|
26
|
-
To use <%=
|
26
|
+
To use <%= spec.name %>, simply call the **phonofy** method in your Rails model:
|
27
27
|
|
28
28
|
```ruby
|
29
29
|
class User < ApplicationRecord
|
@@ -43,7 +43,7 @@ end
|
|
43
43
|
|
44
44
|
This will add phone number validation and formatting to the **mobile_number** attribute of the **Contact** model.
|
45
45
|
|
46
|
-
You can also pass additional options to <%=
|
46
|
+
You can also pass additional options to <%= spec.name %> to customize its behavior:
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
class User < ApplicationRecord
|
@@ -56,21 +56,21 @@ This will add phone number validation and formatting to the **phone** attribute
|
|
56
56
|
|
57
57
|
## **Configuration**
|
58
58
|
|
59
|
-
You can configure <%=
|
59
|
+
You can configure <%= spec.name %> by creating an initializer file in your Rails application and setting the default options:
|
60
60
|
|
61
61
|
```ruby
|
62
|
-
# config/initializers/<%=
|
63
|
-
<%=
|
62
|
+
# config/initializers/<%= spec.name %>.rb
|
63
|
+
<%= spec.name.capitalize %>.configure do |config|
|
64
64
|
config.default_phonelib_options = { countries: [:us, :ca], types: [:mobile] }
|
65
65
|
config.default_twilio_options = { lookup: { type: :carrier_type } }
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
|
-
This will set the default options for <%=
|
69
|
+
This will set the default options for <%= spec.name %> 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.
|
70
70
|
|
71
71
|
## **Contributing**
|
72
72
|
|
73
|
-
Bug reports and pull requests are welcome on GitHub at <%=
|
73
|
+
Bug reports and pull requests are welcome on GitHub at <%= spec.metadata["source_code_uri"] %>. 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.
|
74
74
|
|
75
75
|
## **License**
|
76
76
|
|
@@ -78,4 +78,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
78
78
|
|
79
79
|
## **Credits**
|
80
80
|
|
81
|
-
<%=
|
81
|
+
<%= spec.name %> was created by <%= spec.authors.first %> and is maintained by a community of contributors.
|
data/Rakefile
CHANGED
@@ -12,11 +12,12 @@ RuboCop::RakeTask.new
|
|
12
12
|
task default: %i[spec rubocop]
|
13
13
|
|
14
14
|
require "erb"
|
15
|
+
spec = Gem::Specification.load("phonofy.gemspec")
|
15
16
|
|
16
17
|
desc "Generate README.md from template"
|
17
18
|
task :readme do
|
18
19
|
template = File.read("README.md.erb")
|
19
|
-
readme = ERB.new(template).
|
20
|
+
readme = ERB.new(template).result_with_hash({ spec: spec })
|
20
21
|
File.write("README.md", readme)
|
21
22
|
end
|
22
23
|
|
data/lib/phonofy/version.rb
CHANGED