phony 2.22.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +117 -0
  3. metadata +7 -6
  4. data/README.textile +0 -116
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a0232ad1bb74afc030a899aacce2e9c478baace2f599fe75dc7f04ded271e10
4
- data.tar.gz: 5f92fbceede92639520864a37ef4e1948a0455bddca9ca4aedbc89a95971b727
3
+ metadata.gz: 22d7b6e8936fc0c98194fa172131611d5bc3d5a9987b634cc560459d500f845d
4
+ data.tar.gz: 6efd37bba4276e4c10231b34ca20319b9288b72317ac8e818468717af6e4278a
5
5
  SHA512:
6
- metadata.gz: ca05c2c33863f7816d6b21d3e1bfe75c1fd48c6458ce1f0404ddb89f362df1d8c7892e667b5e3452d33e392b3904445365aa1ec456e9d3ed9b1e3d08bec97bcf
7
- data.tar.gz: d69be3c2e154a175dd76312260caa901112512fe40a164c9ba9ae9748e5db3ee6a6d12e47d328329c669e4fdd48916ceaf7028b2ad0bccfa2ab9f4938809f0f2
6
+ metadata.gz: d95038f6c3b29ba2cf15048c8c55785d31fbc28b89d0552bbae34cdbd3aef6a0dcb525d34a40a84dd2d62907ab9aae48bbaf4a7f02b6514739b4b6646496b9d8
7
+ data.tar.gz: 27de5eb29a2d59da382b5b285b0b860326a34088b2ccd63ef922e417ea093b5a256ad80f227de746e50d41811189a7b5c9053c444abcc0e6563adc5ba129f7ac
data/README.md ADDED
@@ -0,0 +1,117 @@
1
+ [![Build Status](https://secure.travis-ci.org/floere/phony.png)](http://travis-ci.org/floere/phony)
2
+ [![Coverage Status](https://coveralls.io/repos/floere/phony/badge.svg?branch=master)](https://coveralls.io/r/floere/phony?branch=master)
3
+ [![Code Climate](https://codeclimate.com/github/floere/phony.png)](https://codeclimate.com/github/floere/phony)
4
+ [![Inline docs](http://inch-ci.org/github/floere/phony.png)](http://inch-ci.org/github/floere/phony)
5
+
6
+ # Phony
7
+
8
+ Disclaimer: Phony works with international numbers only, such as `61 412 345 678`!
9
+
10
+ The (admittedly crazy) goal of this Gem is to be able to normalize/format/split all phone numbers in the world.
11
+
12
+ Used in: [airbnb.com](http://airbnb.com), [socialcam.com](http://socialcam.com), [zendesk.com](http://www.zendesk.com/) (and many, many others).
13
+
14
+ ## Runtime Memory Usage {#memory}
15
+
16
+ According to [memory_profiler](https://github.com/SamSaffron/memory_profiler), the Phony gem uses roughly 1MB of memory per Ruby process.
17
+ Usage was generated using (look for `Total retained`): `ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony" }.pretty_print'`
18
+
19
+ ## Description
20
+
21
+ This gem normalizes, formats and splits "**E164 phone numbers**". A valid E164 phone number **must** include a country code.
22
+
23
+ E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number. For example, the Australian number `+61 412 345 678` can be broken down into the following components:
24
+ * Country Code (CC): a country code of `61`
25
+ * National Destination Code (NDC): a mobile number denoted by the `4` (specific to Australia)
26
+ * Local Number Part: a subscriber number of `12 345 678`
27
+
28
+ It currently handles the countries listed at the end of this README.
29
+
30
+ It is covered by roughly 2,250 tests that run in 2 seconds (April 2019).
31
+ If it doesn't work, please [enter an issue](http://github.com/floere/phony/issues) or better, fork and [send a pull request](http://github.com/floere/phony/pulls).
32
+
33
+ ## Installation
34
+
35
+ With Rails? Check out: https://github.com/joost/phony_rails.
36
+
37
+ With Bundler: Append `gem 'phony'` to your `Gemfile` and `bundle install` it.
38
+
39
+ Without Bundler: Run `gem install phony` from your command line.
40
+
41
+ ## Usage docs {#usage}
42
+
43
+ Phony uses [qed](https://github.com/rubyworks/qed) as docs and to run its functional tests. Start here for usage docs: [Usage index](./qed/index.md).
44
+
45
+ ### Phony.normalize(number) {#normalizing}
46
+
47
+ Normalize intelligently removes all non-numeric characters of a number. Do it before storing a number in a DB.
48
+
49
+ [Phony.normalize docs](./qed/normalize.md)
50
+
51
+ `Phony.normalize('1-888-407-4747').assert == '18884074747'`
52
+
53
+ ### Phony.format(number, options = {}) {#formatting}
54
+
55
+ Format formats a normalized number according to a country's predominant formatting. Lots of options for int'l, national, local formatting.
56
+
57
+ [Phony.format docs](./qed/format.md)
58
+
59
+ `Phony.format('41443643532').assert == '+41 44 364 35 32'`
60
+
61
+ ### Phony.plausible?(number, options = {}) {#plausibility}
62
+
63
+ Is a number plausible?
64
+
65
+ [Phony.plausible? docs](./qed/plausibility.md)
66
+
67
+ `Phony.assert.plausible?('+41 44 111 22 33')`
68
+
69
+ ### Phony.split(number) {#splitting}
70
+
71
+ Split a number into its parts: CC, NDC, local.
72
+
73
+ [Phony.split docs](./qed/split.md)
74
+
75
+ `Phony.split('3928061371').assert == ['39', '2', '806', '1371']`
76
+
77
+ NB If a country does not have an NDC, `#split` will return `false` in the NDC position, for example for Denmark:
78
+
79
+ `Phony.split('4512121212').assert == ['45', false, '12', '12', '12', '12']`
80
+
81
+ ### Loading only a country subset (Phony 2.18.0+). {#loading}
82
+
83
+ Use this in case you'd like to save [memory](#memory) that is used by Phony's CC rules.
84
+
85
+ [Phony::Config.load docs](./qed/config.md)
86
+
87
+ First, `require 'phony/config'`.
88
+ Then, one of the following, which will load the rest of Phony.
89
+
90
+ Load only these CCs:
91
+ `Phony::Config.load(only: ['41', '44'])`
92
+
93
+ Loads everything except these CCs:
94
+ `Phony::Config.load(except: ['41', '44'])`
95
+
96
+ Convenience form of `only`:
97
+ `Phony::Config.load('41', '44')`
98
+
99
+ Each of these loads the rest of Phony.
100
+
101
+ Memory usage can be checked using (look for `Total retained`):
102
+ `ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony/config"; Phony::Config.load("1") }.pretty_print'`
103
+ For example, when just loading the NANP CC, the retained memory usage is ~63kB.
104
+
105
+ ## List of Handled Countries
106
+
107
+ Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mauritian, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
108
+
109
+ ## Proud Sponsors
110
+
111
+ * Renuo AG (July 2022 – January 2025): [Github](https://github.com/renuo), [Homepage](https://www.renuo.ch). Much appreciated!
112
+
113
+ ## License
114
+
115
+ MIT.
116
+ See [LICENSE](./LICENSE) file.
117
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.22.7
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-03 00:00:00.000000000 Z
11
+ date: 2025-12-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Fast international phone number (E164 standard) normalizing, splitting
14
14
  and formatting. Lots of formatting options: International (+.., 00..), national
@@ -17,9 +17,9 @@ email: florian.hanke+phony@gmail.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files:
20
- - README.textile
20
+ - README.md
21
21
  files:
22
- - README.textile
22
+ - README.md
23
23
  - lib/phony.rb
24
24
  - lib/phony/config.rb
25
25
  - lib/phony/countries.rb
@@ -82,7 +82,8 @@ files:
82
82
  homepage: https://github.com/floere/phony
83
83
  licenses:
84
84
  - MIT
85
- metadata: {}
85
+ metadata:
86
+ rubygems_mfa_required: 'true'
86
87
  post_install_message:
87
88
  rdoc_options: []
88
89
  require_paths:
@@ -91,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
92
  requirements:
92
93
  - - ">="
93
94
  - !ruby/object:Gem::Version
94
- version: '2.7'
95
+ version: '3.2'
95
96
  required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  requirements:
97
98
  - - ">="
data/README.textile DELETED
@@ -1,116 +0,0 @@
1
- "!{float:right}https://secure.travis-ci.org/floere/phony.png!":http://travis-ci.org/floere/phony
2
- !https://coveralls.io/repos/floere/phony/badge.svg?branch=master(Coverage Status)!:https://coveralls.io/r/floere/phony?branch=master
3
- "!https://codeclimate.com/github/floere/phony.png!":https://codeclimate.com/github/floere/phony
4
- !http://inch-ci.org/github/floere/phony.png!:http://inch-ci.org/github/floere/phony
5
-
6
- h1. Phony
7
-
8
- Disclaimer: Phony works with international numbers only, such as @61 412 345 678@!
9
-
10
- The (admittedly crazy) goal of this Gem is to be able to normalize/format/split all phone numbers in the world.
11
-
12
- Used in: "airbnb.com":http://airbnb.com, "socialcam.com":http://socialcam.com, "zendesk.com":http://www.zendesk.com/ (and many, many others).
13
-
14
- h2(#memory). Runtime Memory Usage
15
-
16
- According to "memory_profiler":https://github.com/SamSaffron/memory_profiler, the Phony gem uses roughly 1MB of memory per Ruby process.
17
- Usage was generated using (look for @Total retained@): @ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony" }.pretty_print'@
18
-
19
- h2. Description
20
-
21
- This gem normalizes, formats and splits "*E164 phone numbers*":http://en.wikipedia.org/wiki/E.164. A valid E164 phone number *must* include a country code.
22
-
23
- E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number. For example, the Australian number @+61 412 345 678@ can be broken down into the following components:
24
- * Country Code (CC): a country code of @61@
25
- * National Destination Code (NDC): a mobile number denoted by the @4@ (specific to Australia)
26
- * Local Number Part: a subscriber number of @12 345 678@
27
-
28
- It currently handles the countries listed at the end of this README.
29
-
30
- It is covered by roughly 2,250 tests that run in 2 seconds (April 2019).
31
- If it doesn't work, please "enter an issue":http://github.com/floere/phony/issues or better, fork and "send a pull request":http://github.com/floere/phony/pulls.
32
-
33
- h2. Installation
34
-
35
- With Rails? Check out: https://github.com/joost/phony_rails.
36
-
37
- With Bundler: Append @gem 'phony'@ to your @Gemfile@ and @bundle install@ it.
38
-
39
- Without Bundler: Run @gem install phony@ from your command line.
40
-
41
- h2(#usage). Usage docs
42
-
43
- Phony uses "qed":https://github.com/rubyworks/qed as docs and to run its functional tests. Start here for usage docs: "Usage index":./qed/index.md.
44
-
45
- h3(#normalizing). Phony.normalize(number)
46
-
47
- Normalize intelligently removes all non-numeric characters of a number. Do it before storing a number in a DB.
48
-
49
- "Phony.normalize docs":./qed/normalize.md
50
-
51
- @Phony.normalize('1-888-407-4747').assert == '18884074747'@
52
-
53
- h3(#formatting). Phony.format(number, options = {})
54
-
55
- Format formats a normalized number according to a country's predominant formatting. Lots of options for int'l, national, local formatting.
56
-
57
- "Phony.format docs":./qed/format.md
58
-
59
- @Phony.format('41443643532').assert == '+41 44 364 35 32'@
60
-
61
- h3(#plausibility). Phony.plausible?(number, options = {})
62
-
63
- Is a number plausible?
64
-
65
- "Phony.plausible? docs":./qed/plausibility.md
66
-
67
- @Phony.assert.plausible?('+41 44 111 22 33')@
68
-
69
- h3(#splitting). Phony.split(number)
70
-
71
- Split a number into its parts: CC, NDC, local.
72
-
73
- "Phony.split docs":./qed/split.md
74
-
75
- @Phony.split('3928061371').assert == ['39', '2', '806', '1371']@
76
-
77
- NB If a country does not have an NDC, @#split@ will return @false@ in the NDC position, for example for Denmark:
78
-
79
- @Phony.split('4512121212').assert == ['45', false, '12', '12', '12', '12']@
80
-
81
- h3(#loading). Loading only a country subset (Phony 2.18.0+).
82
-
83
- Use this in case you'd like to save "memory":#memory that is used by Phony's CC rules.
84
-
85
- "Phony::Config.load docs":./qed/config.md
86
-
87
- First, @require 'phony/config'@.
88
- Then, one of the following, which will load the rest of Phony.
89
-
90
- Load only these CCs:
91
- @Phony::Config.load(only: ['41', '44'])@
92
-
93
- Loads everything except these CCs:
94
- @Phony::Config.load(except: ['41', '44'])@
95
-
96
- Convenience form of @only@:
97
- @Phony::Config.load('41', '44')@
98
-
99
- Each of these loads the rest of Phony.
100
-
101
- Memory usage can be checked using (look for @Total retained@):
102
- @ruby -e 'require "memory_profiler"; MemoryProfiler.report(allow_files: "phony"){ require "phony/config"; Phony::Config.load("1") }.pretty_print'@
103
- For example, when just loading the NANP CC, the retained memory usage is ~63kB.
104
-
105
- h2. List of Handled Countries
106
-
107
- Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mauritian, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
108
-
109
- h2. Proud Sponsors
110
-
111
- * Renuo AG (July 2022 – January 2025): "Github":https://github.com/renuo, "Homepage":https://www.renuo.ch. Much appreciated!
112
-
113
- h2. License
114
-
115
- MIT.
116
- See "LICENSE":./LICENSE file.