Giter VIP home page Giter VIP logo

iso_country_codes's People

Contributors

alexcastano avatar alexrabarts avatar bkoski avatar gleseur avatar greshny avatar greysteil avatar ignat-z avatar jefftd avatar joshuaflanagan avatar ksheurs avatar rmm5t avatar rob-anderson avatar shanna avatar stefan-kolb avatar stonehz avatar toothbrush avatar wontaeyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iso_country_codes's Issues

Wrong return of IsoCountryCodes.for_select in 0.7.2

Good day, I'm using your library and after release of 0.7.2 version
IsoCountryCodes.for_select returns

 ["Virgin Islands (U.S.)", "VI"],
 ["Wallis and Futuna", "WF"],
 ["Western Sahara", "EH"],
 ["Yemen", "YE"],
 ["Zambia", "ZM"],
 ["Zimbabwe", "ZW"],
 [nil, nil]]

nil values at the end.

Reverted back to 0.7.1 and this problem has gone. Can someone else prove it? Is it a valid output?

Option to skip UnknownCodeError when code not found

@alexrabarts thanks for your work on this. I'm using it in a production app!

Are you still maintaining this project? I'd be happy to step up to the plate and implement this myself if you're still around and merging pool requests.

I'm using the gem in a save callback on a model in conjunction with a geocoding service that is returning country codes. I convert the country code to the country name using iso_country_codes. It makes me nervous that the third party service could return a new or invalid country code and prevent the model from saving. So, I'm doing something like this:

user.country = begin; IsoCountryCodes.find(geo.country).name; rescue; geo.country; end;

It'd be handy if there was a configuration option to return whatever was passed to the find method if no country is found instead of raising an error.

Country codes read in from yml? Extensible gem?

Would it be possible to change iso_4217.rb and iso_3166_1.rb such that the values are read in from a yml file? Doing that and allowing any key for the property names (using method_missing or defining methods based on the attribute keys that are read in from the yaml file - instead of hard-coded method names in the ruby class) will allow the following:

The yml file could then be "externalized" to the consumer (you will need to provide a way for the gem consumer to specify a custom yml file) - ie they can take the default, add new attributes (for eg, in my case, I would like a "flag_sprite_class", "phone_code", "enabled"). Extending the gem will be super-easy in this case! What do you think?

ISO 3166-2 support

Hi! I would make sense to support the ISO 3166-2 for region support in this gem?
I was looking for something that can group the ISO codes for Countries, Regions and Currencies and this seems to be a good match.

Is there a way to add a country?

I had to add Kosovo and rename "Macedonia (the former Yugoslav Republic of)" to "North Macedonia". I fixed my issue by adding this:

class XXK < IsoCountryCodes::Code
  self.numeric = nil
  self.name    = %q{Kosovo}
  self.alpha2  = %q{XK}
  self.alpha3  = %q{XXK}
  self.iban    = 'XK'
  self.main_currency = 'EUR'
  self.continent = 'EU'
  self.calling = '+383'
end

IsoCountryCodes::Code::MKD.module_eval do
  self.name    = %q{North Macedonia}
end

Because I use the gem for Ruby on Rails I added the code to: config/initializers/adjust_iso_country_codes.rb.
Kosovo appears on the last place. Where can I add .sort_by to resort all the countries?

NoMethodError: undefined method `to_set' for ["AFGHANISTAN"]:Array

What I did:

  • gem install 'iso_country_codes
  • irb
  • require 'iso_country_codes
  • IsoCountryCodes.search_by_name('Belgie')

What I expected:
BE

What I got:

❯ irb
2.4.0 :001 > require 'iso_country_codes'
 => true
2.4.0 :002 > IsoCountryCodes.search_by_name('Belgie')
NoMethodError: undefined method `to_set' for ["AFGHANISTAN"]:Array
Did you mean?  to_s
	from /X/.rvm/gems/ruby-2.4.0/gems/iso_country_codes-0.7.8/lib/iso_country_codes/iso_country_codes.rb:94:in `word_set'
	from /X/.rvm/gems/ruby-2.4.0/gems/iso_country_codes-0.7.8/lib/iso_country_codes/iso_country_codes.rb:44:in `block in search_by_name'
	from /X/.rvm/gems/ruby-2.4.0/gems/iso_country_codes-0.7.8/lib/iso_country_codes/iso_country_codes.rb:44:in `select'
	from /X/.rvm/gems/ruby-2.4.0/gems/iso_country_codes-0.7.8/lib/iso_country_codes/iso_country_codes.rb:44:in `search_by_name'
	from (irb):2
	from /X/.rvm/rubies/ruby-2.4.0/bin/irb:11:in `<main>'

search_by_name Macao / Macau ?

Would it be possible to have this work? What's the policy on alternative spellings for country names? Stripe currently gives the old name and crashes the search.

https://en.wikipedia.org/wiki/ISO_3166-2:MO

pry(main)> IsoCountryCodes.search_by_name('Macao')
=> [#<IsoCountryCodes::Code::MAC:0x007ffb84191360>]

pry(main)> IsoCountryCodes.search_by_name('Macau')
IsoCountryCodes::UnknownCodeError: No ISO 3166-1 codes could be found searching with name 'Macau'.
from /Users/nruth/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/iso_country_codes-0.6.1/lib/iso_country_codes/iso_country_codes.rb:14:in `block in singleton class'

Bahamas Calling code

Shouldn't the Bahamas calling code be +1242 instead of +242 ?
I think it's the same with all the american islands (american samoa +684, ...)

USA/US/United States

IsoCountryCodes.search_by_name("USA") -> nothing
IsoCountryCodes.search_by_name("US") -> bunch of things, not US

IsoCountryCodes.search_by_name("United states") -> works! :)

Maybe exactly as designed. Would you like a PR?

Country names, commas, and parenthesis

I have a tool that returning country names to me, which I think pass to iso_country_codes. In one case, it returned "Republic of Korea", and iso_country_codes couldn't find it and returned an error. This got me digging, and I found this is because the "Republic of" part of the name is parenthetical in https://github.com/alexrabarts/iso_country_codes/blob/master/lib/iso_country_codes/iso_3166_1.rb

I'm not claiming this is an error or bug, because when it comes to naming things, its never easy. It did lead me look at other records in the file, and I noticed that sometimes parenthesis are used for parts of the country name, other times its a comma that separates the parts. I'm wondering if there is a reason for the difference, or if its an inconsistency? If its an inconsistency, I wouldn't mind opening a PR for it.

Also, for these cases, would it be feasible for iso_country_codes to do a comparison between the input, and a version of the country name where the parenthesis were removed and order flipped? Again, I wouldn't be opposed to doing the leg work on the PR, but since I don't know the library very well, I wanted to find out if there may be other technical or non-technical reasons that this would be a bad idea before I started trying to code it up.

wrong currency code for SK

You have the wrong currency code for South Korea.. it should be KRW, not KPW (that is North Korean Won) :)

Saint Lucia States are missing names (they are all nil)

The name's for the states of Saint Lucia are all nil. See below.
[pry(main)> c.data["name"]
=> "Saint Lucia"
[pry(main)> c.states.map { |state| state.last["name"] }
=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]

["01",
#<struct ISO3166::Subdivision
name=nil,
code=nil,
unofficial_names=nil,
geo=nil,
translations=
{"ar"=>"حي أنس لا راي",
"bn"=>"আন্স লা রায়ে কোয়ার্টার",
"da"=>"Anse la Raye Quarter",
"de"=>"Anse-la-Raye",
"el"=>"Άνς λα Ράιγ",
"en"=>"Anse la Raye",
"es"=>"Anse La Raye",
"eu"=>"Anse la Raye auzoa",
"fa"=>"بخش آنسه لا ریه",
"fi"=>"Anse-la-Raye",
"fr"=>"District d’Anse-la-Raye",
"gu"=>"એન્સે લા રેય ક્વાર્ટર",
"hi"=>"एंस ला राए क्वार्टर",
"id"=>"Anse la Raye Quarter",
"it"=>"quartiere di Anse-la-Raye",
"ja"=>"アンス・ラ・レイ地区",
"kn"=>"ಆನ್ಸೆ ಲಾ ರೇಯ್ ಕ್ವಾರ್ಟರ್",
"ko"=>"앙스라레 구",
"lt"=>"Ans Lavua",
"mr"=>"अं. ला राय क्वार्टर",
"ms"=>"Anse la Raye Quarter",
"nb"=>"Anse la Raye Quarter",
"nl"=>"Anse-la-Raye",
"pl"=>"Anse la Raye",
"pt"=>"Anse-La-Raye",
"ru"=>"Анс-Лавуа",
"si"=>"අන්සේ ලා රයේ කාර්ටර්",
"sv"=>"Anse la Raye Quarter",
"ta"=>"அன்ஸே லா ரே குஆர்டெர்",
"te"=>"ఆన్స్ లా రే",
"th"=>"แอนซี่ ลา เรย์ ควอเตอร์",
"tr"=>"Anse la Raye (şehir)",
"ur"=>"انسے لا رائے کوارٹر",
"vi"=>"Anse la Raye",
"zh"=>"昂斯拉雷區"},
comments=nil>]

Expanding to include per-country ISO 3166-2

Hi,

I was interested in evolving this into containing the country state/provinces codes for ISO 3166-2. For example the ISO 3166-2:EC for Ecuador or ISO 3166-2:BR for Brazil.

Before I fork this, are there any comments or remarks or even guiding as to what pattern, format to follow?

Regards,

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.