Open asilano opened 3 years ago
Any suggested fix? Open to pull requests.
On Thu, Jan 28, 2021, 12:19 Chris Howlett notifications@github.com wrote:
Because normalize_number strips all non-phonelike characters from its input, you get weird results like the following:
PhonyRails.plausible_number?('https://doi.org/10.1002/rse2.195', country_code: 'GB')
=> true
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joost/phony_rails/issues/204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWKSXCSGCAALXLXJFVJDTS4FB2PANCNFSM4WW4E3AA .
Well, it depends on what you, as owner, want the behaviour to be. I see that you strip any non-(digit, bracket or plus), and I can see that stripping dashes from +44-1234-567-890 (for instance) makes sense. Letters feel like they're less likely to appear in a valid number (especially since extensions are dealt with earlier).
Perhaps it should strip all non-phonelike, non-alphabetic characters?
@joost I want to try and submit a pull request, but I can't get tests running. I've:
bundle exec rspec spec
I get the following error output:
No DRb server is running. Running in local process instead ...
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
An error occurred while loading ./spec/lib/phony_rails_spec.rb.
Failure/Error: require 'mongoid'
NameError:
uninitialized constant ActiveModel::Serializers::Xml
# ./spec/spec_helper.rb:12:in `require'
# ./spec/spec_helper.rb:12:in `<top (required)>'
# ./spec/lib/phony_rails_spec.rb:3:in `require'
# ./spec/lib/phony_rails_spec.rb:3:in `<top (required)>'
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
An error occurred while loading ./spec/lib/validators/phony_validator_spec.rb.
Failure/Error: require 'mongoid'
NameError:
uninitialized constant ActiveModel::Serializers::Xml
# ./spec/spec_helper.rb:12:in `require'
# ./spec/spec_helper.rb:12:in `<top (required)>'
# ./spec/lib/validators/phony_validator_spec.rb:3:in `require'
# ./spec/lib/validators/phony_validator_spec.rb:3:in `<top (required)>'
No examples found.
Finished in 0.00006 seconds (files took 1.1 seconds to load)
0 examples, 0 failures, 2 errors occurred outside of examples
[Coveralls] Outside the CI environment, not sending data.
Hi @asilano! I see things broke when using phony_rails
with the more recent gems.
I've fixed the tests by some updates & by removing MongoDb support.
I will push a branch for you to have a look at little later today.
Please see the https://github.com/joost/phony_rails/tree/no_mongoid branch for a version with working specs. Pull request welcome!
Thanks, the branch works nicely.
Unfortunately, my fix doesn't - normalize_number
is not massively to blame, and in fact Phony thinks that Phony.plausible?('https://example.com/15.55/a5b5c5/rse5.555')
is true as well.
I'll have a think, and maybe I'll go bother them too :)
Because
normalize_number
strips all non-phonelike characters from its input, you get weird results like the following: