Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for phony version ~> 2.1 #45

Merged
merged 14 commits into from
Jan 28, 2014
Merged

Conversation

pjg
Copy link
Contributor

@pjg pjg commented Jan 26, 2014

Upgrade gem (mostly just specs) to support latest version of phony (2.1.x).

The fix was just to amend all invalid/incorrect (in the E164 sense) phone numbers used in the specs to valid ones.

References #28.

pjg added 13 commits January 25, 2014 19:41
To match the setting from the gemspec.
If they exist, before calling them and finding out the AR record does
not respond to them.

This fixes phony_validator specs.
From wikipedia:

"When calling France from abroad, the leading zero should be omitted: to
call a number in Southwest France, one would dial +33 5 xx xx xx xx."

http://en.wikipedia.org/wiki/Telephone_numbers_in_France
Latest phony gem does not strip leading zeros from numbers when
formatting (i.e. if a phone number has a "local" leading zero, phony
will now preserve it).
phony gem now preserves any leading characters in the original phone
number when forcing it to another country code.
phony now puts last four digits in a separate block.
And old specs expect it to strip. Latest phony does not strip them
anymore if they are contained in the original string.
The normalization algorithm in this plugin will just return a
non-normalized version in the case where the country code is missing and
the number is not plausible.
Currently, when there is a leading zero (after optional country code)
phony will add another zero when formatting with the :national option:

```
Phony.formatted('310101234123', :format => :national)
=> "0010 123 4123"
```

Perhaps this is a bug at Phony. I am not sure.

Changing specs here so that they pass, by using a different number,
without leading zero.
And by "valid", I mean Phony.plausible? => true:

```
Phony.plausible?('1 555 555 5555')
=> true
```

Previous one was not (in current version of phony: ~> 2.1):
```
Phony.plausible?('1234567890')
=> false
```
Phony will now add a leading zero for internationally formatted NL numbers.
@joost
Copy link
Owner

joost commented Jan 26, 2014

Hi Paweł. Great work getting up-to-date with the latest phony. Was wondering about the zero output in international numbers (see my comment pjg@d2e02e8#diff-3c58bac5dd643cc025b5502d772b0023R14).
Any idea why those are added by the new phony gem?

i.e. normalize even non-plausible (in Phony gem sense) numbers.

This commit reverses 1f30058.

Phony normalized numbers are without leading zeros after country code
and without plus signs in front (for that you need to use #format).
@pjg
Copy link
Contributor Author

pjg commented Jan 27, 2014

PR updated. After this commit the overall changes by this PR are much more limited in scope ;)

joost pushed a commit that referenced this pull request Jan 28, 2014
Add support for phony version ~> 2.1
@joost joost merged commit 8c673b3 into joost:master Jan 28, 2014
@joost
Copy link
Owner

joost commented Jan 28, 2014

This is in v0.6.0.

@pjg
Copy link
Contributor Author

pjg commented Jan 28, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants