Closed telamon closed 6 years ago
@telamon Hi Tony, thanks for sourcediving 😊
The stated goal of the library is "This gem normalizes, formats and splits E164 phone numbers." and this is where the line is and must be drawn, so that the focus is clear to the developers (mostly me) and its users. This is the way we can keep Phony be an excellent library now and in the future.
so that we don't have to rely onto a second or third library to do that conversion
I disagree with you here. Relying on other small libraries with a clearly specified focus is a great idea, so each can be maintained perfectly instead of one monolith.
If you still feel that Phony should include country names then I urge you to create a "phony-country" gem that depends on Phony and includes that extra info that is then maintained by you. The phony-rails gem does that and it works very well.
I'm closing this. Just reopen it if you have something to add. All the best! 🚀
Nah, I ended up using Telephone gem for normalization and cc lookup. It was just frustrating to see the information i needed in the comments but not being able to use it, basically my proposal wasn't to intended to put you out of scope but rather make already existing information available for programmatic access.
I mean there really isn't any point in cloning the Phony country-database just to convert the country-code from comment to symbol/string and have 2 data-sources to maintain - that would be madness.
My job's done anyway, I just couldn't use phony in it's current state, but give me a heads up if you change your mind. Cheers! :)
Nah, I ended up using Telephone gem for normalization and cc lookup.
I'm glad you found a library that suits you! All the best 😊
@floere @telamon Is it even possible? I mean i hacked a bit around with this, becuase I need exactly this, and found the following:
ISO3166::Country.all.detect { |_n, iso_code| x = ISO3166::Country[iso_code] ; x.country_code == '49' } # => works, germany
ISO3166::Country.all.detect { |_n, iso_code| x = ISO3166::Country[iso_code] ; x.country_code == '1' } # => expected US, got ANT
For example, if you try to find the number by the ISO3166 list of country codes and international prefixes, Antigua und Barbuda is listed before the US and has the same prefix. So from a list of country coes alone this is'nt even possible, is it?
@phillipp That's a bit of a problem indeed – the NANP covers a lot of countries, and I have to admit that "country code" is not correct. To map a number to a country, you absolutely need CC and "national" code. Maybe you could also provide the national code to the ISO library (unsure whether it does national codes).
What I did
What happened
What I expected to happen and why
Given that there is already a great deal of information stored in the countries register i'm honestly surprised that it's lacking the country name. If you just would've extended your country DSL to include the 2-letter country identifier specified by ISO3166 then it would open the possibility to do the following
Why would we want to? Well I'd be even more surprised if people actually stored '46' in their
Customer.country
column, Isn't it just plainly logical to include the country-identifier so that we don't have to rely onto a second or third library to do that conversion? ( The identifiers are already in the country-comments, they're just not registered... )And in my case I have a lot of old and dirty numbers where I potentially know the country but the phone-number might have to be manually prefixed before It can be used with Phony.