STATUS: In development - not ready to be used.
<img src=“https://travis-ci.org/djonasson/worldwise.png?branch=master” alt=“Build Status” /> <img src=“https://codeclimate.com/github/djonasson/worldwise.png” alt=“Code Climate” /> <img src=“https://coveralls.io/repos/djonasson/worldwise/badge.png?branch=master” alt=“Coverage Status” /> <img src=“https://badge.fury.io/rb/worldwise.png” alt=“Gem Version” />
Worldwise is a Rails gem that provides your application with a series of ActiveRecord models representing various aspects of our world, such as geographic/political divisions, languages, currencies and more. Globalize3 is used to provide translations for each model.
There are several ways of dividing the planet into continents. The most common of these continent models are:
4 continents | Afro-Eurasia | America | Antarctica | Australia 5 continents | Africa | Eurasia | America | Antarctica | Australia 6 continents | Africa | Europe | Asia | America | Antarctica | Australia 6 continents | Africa | Eurasia | North America | South America | Antarctica | Australia 7 continents | Africa | Europe | Asia | North America | South America | Antarctica | Australia
These continent models are all handled by Worldwise.
irb(main)> ap ContinentModel.all.map(&:name) [ [0] "4 Continents", [1] "5 Continents", [2] "6 Continents (America)", [3] "6 Continents (Eurasia)", [4] "7 Continents" ]
irb(main)> Continent.count => 10 irb(main)> ContinentModel.all.map { |cm| [cm.name, cm.continents.map(&:name)] } => [ ["4 Continents", ["Afro-Eurasia", "America", "Antarctica", "Oceania"]], ["5 Continents", ["Africa", "America", "Antarctica", "Oceania", "Eurasia"]], ["6 Continents (America)", ["Africa", "America", "Antarctica", "Asia", "Oceania", "Europe"]], ["6 Continents (Eurasia)", ["Africa", "Antarctica", "Oceania", "Eurasia", "North America", "South America"]], ["7 Continents", ["Africa", "Antarctica", "Asia", "Oceania", "Europe", "North America", "South America"]] ] irb(main)> Continent.first.translations.count => 40 irb(main)> Continent.first.translations.map { |t| [t.locale, t.name] } => [[:ar, "أفريقيا"], [:bg, "Африка"], [:bs, "Afrika"], [:ca, "Àfrica"], [:cs, "Afrika"], [:cy, "Affrica"], [:da, "Afrika"], [:de, "Afrika"], [:el, "Αφρική"], [:en, "Africa"], [:eo, "Afriko"], [:es, "África"], [:eu, "Afrika"], [:fa, "افریقا"], [:fi, "Afrikka"], [:fr, "Afrique"], [:ga, "an Afraic"], [:he, "אפריקה"], [:hi, "अफ़्रीका"], [:hu, "Afrika"], [:id, "Afrika"], [:is, "Afríka"], [:ja, "アフリカ"], [:ko, "아프리카"], [:la, "Africa"], [:lt, "Afrika"], [:lv, "Āfrika"], [:nb, "Afrika"], [:nl, "Afrika"], [:false, "Afrika"], [:pl, "Afryka"], [:pt, "África"], [:ru, "Африка"], [:se, "Afrihkká"], [:sv, "Afrika"], [:th, "แอฟริกา"], [:tr, "Afrika"], [:uk, "Африка"], [:vi, "Châu Phi"], [:zh, "非洲"]]
irb(main)> Country.count => 246 irb(main)> Continent.first.countries.map(&:name) => ["Angola", "Burkina Faso", "Burundi", "Benin", "Botswana", "Congo, The Democratic Republic Of The", "Central African Republic", "Congo", "Côte D'Ivoire", "Cameroon", "Cape Verde", "Djibouti", "Algeria", "Egypt", "Western Sahara", "Eritrea", "Ethiopia", "Gabon", "Ghana", "Gambia", "Guinea", "Equatorial Guinea", "Guinea-Bissau", "British Indian Ocean Territory", "Kenya", "Comoros", "Liberia", "Lesotho", "Libya", "Morocco", "Madagascar", "Mali", "Mauritania", "Mauritius", "Malawi", "Mozambique", "Namibia", "Niger", "Nigeria", "Réunion", "Rwanda", "Seychelles", "Sudan", "Saint Helena", "Sierra Leone", "Senegal", "Somalia", "Sao Tome and Principe", "Swaziland", "Chad", "Togo", "Tunisia", "Tanzania, United Republic of", "Uganda", "Mayotte", "South Africa", "Zambia", "Zimbabwe"]
The Country model has quite a few attributes and it can sometimes be difficult to understand what they represent from the name only. For this reason there is a metadata method that returns a hash of all the attribute names and their respective descriptions:
irb(main)> Country.metadata[:iso_3166_alpha2] => "ISO 3166-1 alpha-2 country code"