Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iso_countries_plus

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iso_countries_plus

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

IsoCountriesPlus

This gem differs from other ISO country gems in that it allows VERY flexible name lookups by cross-compiling additional country name standards, so country names like 'South Korea' and 'Russia' will work properly. It uses a file compiled by OpenGeocode.org consisting of the ISO 3166-1 country names (including foreign variants) and codes, as well as the U.S. Board on Geographic Names (BGN), United Nations Group of Experts on Geographic Names (UNGEGN), and U.K. Permanent Committee on Geographic Names (PCGN) country names. More info here: http://opengeocode.org/download.php#countrynames

File downloadable here: http://opengeocode.org/download/countrynames.txt

Developed by Whiplash Merchandising

Installation

Add this line to your application's Gemfile:

gem 'iso_countries_plus'

And then execute:

$ bundle

Or install it yourself as:

$ gem install iso_countries_plus

Usage

IsoCountry.all

IsoCountry.find_by_name("Russia")
IsoCountry.find_by_alpha2("RU")
IsoCountry.find_by_alpha2("RUS")

country = IsoCountry.find_by_name("South Korea")
country.alpha2 # KR
country.alpha3 # KOR
country.name # Korea, Republic of

Features

Combined countries like 'Bosnia and Herzegovina' will also be accessible individually as 'Bosnia' and 'Herzegovina'.

Grouped islands like Pitcairn, Henderson, Ducie, and Oeno Islands will also be accessible as (for example) "Pitcairn", "Ducie Island", and "Oeno Islands" (i.e the name with and without the "Island" and "Islands" suffixes).

Country names are also stored in lowercase. This is useful for allowing more flexibility for user input or when values are entered as all caps.

For example:

country = "GERMANY"
IsoCountry.find_by_name(country.downcase)

Adding Countries

Additional countries are listed in additions.yml as key-value pairs.

'USA': US
'UK': GB
'Great Britain': GB
'England': GB
'Scotland': GB
'Wales': GB
'Northern Ireland': GB

Feel free to fork the gem and add more, or message me with other additions.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 01 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc