Coder Social home page Coder Social logo

Comments (8)

floere avatar floere commented on August 18, 2024

Hi Declan,

Thanks for the sensible issue entry.
I discuss this issue in #37 and also #35. Checking E164 plausibility is discussed here: https://github.com/floere/phony/blob/master/README.textile#plausibility

In a nutshell: Phony only handles international numbers that conform to E164 or are normalizable to it. For example: https://github.com/floere/phony/blob/master/spec/lib/phony_spec.rb#L190-194.

Currently, I am debating whether to raise a useful error, but since I'd like Phony to be only for handling E164 numbers, I'm unsure.

One idea is to check the number first, something like:

Phony.normalize! number if Phony.plausible? number

Does that help?

from phony.

theirishpenguin avatar theirishpenguin commented on August 18, 2024

Thanks for the quick feedback floere.

I did not give the best example, which also illustrates the problem with plausible?().
Here we go, using '353' instead of '1'...

Phony.normalize! '353' if Phony.plausible? '353'

Giving the output...

"353[#<Phony::NationalCode:0x9d1a318 @national_splitter=#<Phony::
NationalSplitters::Variable:0x9d1acb4 @size=nil, @zero=\"0\",.
@mapped_ndc_min_length=1, @mapped_ndc_max_length=2, @ndcs={1=>[\"1\"], 2=>[\"21\",.
\"41\", \"42\", \"46\", \"49\", \"56\", \"58\", \"59\", \"65\", \"66\", \"71\",
\"74\", \"76\", \"90\", \"94\"]}>, @local_splitter=#<Phony::LocalSplitters::
Fixed:0x9d1a598 @format=[3, 14]>, @normalize=true>, #<Phony::NationalCode:0x9d198dc
@national_splitter=#<Phony::NationalSplitters::Variable:0x9d19e54 @size=nil,.
@zero=\"0\", @mapped_ndc_min_length=2, @mapped_ndc_max_length=3, @ndcs={2=>[\"22\",
\"23\", \"24\", \"25\", \"26\", \"27\", \"28\", \"29\", \"43\", \"44\", \"47\", \"48\",
\"52\", \"53\", \"54\", \"55\", \"62\", \"63\", \"64\", \"67\", \"68\", \"69\", \"93\",
\"94\", \"95\", \"96\", \"97\", \"98\", \"99\"], 3=>[\"402\", \"404\", \"502\", \"504\",
\"505\", \"506\", \"509\"]}>, @local_splitter=#<Phony::LocalSplitters::Fixed:0x9d19904
@format=[15]>, @normalize=true>, #<Phony::NationalCode:0x9d14cd8 @national_splitter=
#<Phony::NationalSplitters::Variable:0x9d1514c @size=nil, @zero=\"0\",
@mapped_ndc_min_length=2, @mapped_ndc_max_length=2, @ndcs={2=>[\"45\", \"51\", \"61\",
\"91\"]}>, @local_splitter=#<Phony::LocalSplitters::Fixed:0x9d14cec @format=[16]>,.
@normalize=true>, #<Phony::NationalCode:0x9d13fcc @national_splitter=#<Phony::
NationalSplitters::Variable:0x9d14b34 @size=nil, @zero=\"0\", @mapped_ndc_min_length=3,.
@mapped_ndc_max_length=3, @ndcs={3=>[\"800\"]}>, @local_splitter=#<Phony::
LocalSplitters::Fixed:0x9d14cec @format=[16]>, @normalize=true>, #<Phony::NationalCode:
0x9d13ab8 @national_splitter=#<Phony::NationalSplitters::Regex:0x9d13c70 @size=nil,.
@zero=\"0\", @regex=/^(8\\d).+$/>, @local_splitter=#<Phony::LocalSplitters::Fixed:
0x9d1a598 @format=[3, 14]>, @normalize=true>, #<Phony::NationalCode:0x9d13748
@national_splitter=#<Phony::NationalSplitters::None:0x9d1384c>, @local_splitter=#<
Phony::LocalSplitters::Fixed:0x9d1375c @format=[10]>, @normalize=true>]"

Basically I think that plausible?() is returning true but then normalize!() chokes on the processing.

from phony.

floere avatar floere commented on August 18, 2024

Thanks for the feedback. I understand the real problem now – plausible? is not returning false, as it should, but true. I will look into it why that is so. Cheers!

from phony.

floere avatar floere commented on August 18, 2024

@theirishpenguin Thanks Declan. A fix is released in 1.7.3. Also see https://github.com/floere/phony/wiki/Contributors.

from phony.

theirishpenguin avatar theirishpenguin commented on August 18, 2024

That's great floere! I've retested the fix and it works great!

Thanks for the mention in the contributors file.

Agus go raibh mΓ­le maith agat :-)
Declan

from phony.

floere avatar floere commented on August 18, 2024

Great to hear! Due to the nature of its domain, Phony is a work in progress and I am very glad to get such good feedback to improve it. I am the last man to say it's finished or perfect, so your help is much appreciated.

Contributors: My pleasure – if you wish to be listed in the "Github contributors", just send your next bug report as a failing test in the tests. (Although I hope that there are no further bugs)
Also, if you find an Irish number that does not look ok, or if you happen to hear about changes in the Irish phone number system, I am very glad to hear about it here, as a pull request, or on twitter under "@Hanke".

Thanks! I really love languages, Gaeilge is in my top 10 :)
Florian

from phony.

theirishpenguin avatar theirishpenguin commented on August 18, 2024

Oops. Didn't see this message you left 2 months ago. Thanks again for all the work on this and I'll shout if I hear of any updates to the Irish phone number system (hopefully there won't be any for a while!).

Gaeilge is a great ol language. Though Ruby is my fav these days :)

Ciao,
Dec

from phony.

floere avatar floere commented on August 18, 2024

Hi Declan,

Thanks for the message!

Cheers,
Florian

from phony.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.