ruby-continent 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +8 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +9 -0
- data/README.md +68 -0
- data/Rakefile +10 -0
- data/bin/parse_raw +43 -0
- data/lib/continent.rb +31 -0
- data/share/continent_names.yml +8 -0
- data/share/data.yml +2568 -0
- data/share/raw +263 -0
- data/test/test.rb +39 -0
- metadata +56 -0
data/share/raw
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
# Source: http://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent_(data_file)
|
2
|
+
AS AF AFG 4 Afghanistan, Islamic Republic of
|
3
|
+
EU AL ALB 8 Albania, Republic of
|
4
|
+
AN AQ ATA 10 Antarctica (the territory South of 60 deg S)
|
5
|
+
AF DZ DZA 12 Algeria, People's Democratic Republic of
|
6
|
+
OC AS ASM 16 American Samoa
|
7
|
+
EU AD AND 20 Andorra, Principality of
|
8
|
+
AF AO AGO 24 Angola, Republic of
|
9
|
+
NA AG ATG 28 Antigua and Barbuda
|
10
|
+
EU AZ AZE 31 Azerbaijan, Republic of
|
11
|
+
AS AZ AZE 31 Azerbaijan, Republic of
|
12
|
+
SA AR ARG 32 Argentina, Argentine Republic
|
13
|
+
OC AU AUS 36 Australia, Commonwealth of
|
14
|
+
EU AT AUT 40 Austria, Republic of
|
15
|
+
NA BS BHS 44 Bahamas, Commonwealth of the
|
16
|
+
AS BH BHR 48 Bahrain, Kingdom of
|
17
|
+
AS BD BGD 50 Bangladesh, People's Republic of
|
18
|
+
EU AM ARM 51 Armenia, Republic of
|
19
|
+
AS AM ARM 51 Armenia, Republic of
|
20
|
+
NA BB BRB 52 Barbados
|
21
|
+
EU BE BEL 56 Belgium, Kingdom of
|
22
|
+
NA BM BMU 60 Bermuda
|
23
|
+
AS BT BTN 64 Bhutan, Kingdom of
|
24
|
+
SA BO BOL 68 Bolivia, Republic of
|
25
|
+
EU BA BIH 70 Bosnia and Herzegovina
|
26
|
+
AF BW BWA 72 Botswana, Republic of
|
27
|
+
AN BV BVT 74 Bouvet Island (Bouvetoya)
|
28
|
+
SA BR BRA 76 Brazil, Federative Republic of
|
29
|
+
NA BZ BLZ 84 Belize
|
30
|
+
AS IO IOT 86 British Indian Ocean Territory (Chagos Archipelago)
|
31
|
+
OC SB SLB 90 Solomon Islands
|
32
|
+
NA VG VGB 92 British Virgin Islands
|
33
|
+
AS BN BRN 96 Brunei Darussalam
|
34
|
+
EU BG BGR 100 Bulgaria, Republic of
|
35
|
+
AS MM MMR 104 Myanmar, Union of
|
36
|
+
AF BI BDI 108 Burundi, Republic of
|
37
|
+
EU BY BLR 112 Belarus, Republic of
|
38
|
+
AS KH KHM 116 Cambodia, Kingdom of
|
39
|
+
AF CM CMR 120 Cameroon, Republic of
|
40
|
+
NA CA CAN 124 Canada
|
41
|
+
AF CV CPV 132 Cape Verde, Republic of
|
42
|
+
NA KY CYM 136 Cayman Islands
|
43
|
+
AF CF CAF 140 Central African Republic
|
44
|
+
AS LK LKA 144 Sri Lanka, Democratic Socialist Republic of
|
45
|
+
AF TD TCD 148 Chad, Republic of
|
46
|
+
SA CL CHL 152 Chile, Republic of
|
47
|
+
AS CN CHN 156 China, People's Republic of
|
48
|
+
AS TW TWN 158 Taiwan
|
49
|
+
AS CX CXR 162 Christmas Island
|
50
|
+
AS CC CCK 166 Cocos (Keeling) Islands
|
51
|
+
SA CO COL 170 Colombia, Republic of
|
52
|
+
AF KM COM 174 Comoros, Union of the
|
53
|
+
AF YT MYT 175 Mayotte
|
54
|
+
AF CG COG 178 Congo, Republic of the
|
55
|
+
AF CD COD 180 Congo, Democratic Republic of the
|
56
|
+
OC CK COK 184 Cook Islands
|
57
|
+
NA CR CRI 188 Costa Rica, Republic of
|
58
|
+
EU HR HRV 191 Croatia, Republic of
|
59
|
+
NA CU CUB 192 Cuba, Republic of
|
60
|
+
EU CY CYP 196 Cyprus, Republic of
|
61
|
+
AS CY CYP 196 Cyprus, Republic of
|
62
|
+
EU CZ CZE 203 Czech Republic
|
63
|
+
AF BJ BEN 204 Benin, Republic of
|
64
|
+
EU DK DNK 208 Denmark, Kingdom of
|
65
|
+
NA DM DMA 212 Dominica, Commonwealth of
|
66
|
+
NA DO DOM 214 Dominican Republic
|
67
|
+
SA EC ECU 218 Ecuador, Republic of
|
68
|
+
NA SV SLV 222 El Salvador, Republic of
|
69
|
+
AF GQ GNQ 226 Equatorial Guinea, Republic of
|
70
|
+
AF ET ETH 231 Ethiopia, Federal Democratic Republic of
|
71
|
+
AF ER ERI 232 Eritrea, State of
|
72
|
+
EU EE EST 233 Estonia, Republic of
|
73
|
+
EU FO FRO 234 Faroe Islands
|
74
|
+
SA FK FLK 238 Falkland Islands (Malvinas)
|
75
|
+
AN GS SGS 239 South Georgia and the South Sandwich Islands
|
76
|
+
OC FJ FJI 242 Fiji, Republic of the Fiji Islands
|
77
|
+
EU FI FIN 246 Finland, Republic of
|
78
|
+
EU AX ALA 248 Åland Islands
|
79
|
+
EU FR FRA 250 France, French Republic
|
80
|
+
SA GF GUF 254 French Guiana
|
81
|
+
OC PF PYF 258 French Polynesia
|
82
|
+
AN TF ATF 260 French Southern Territories
|
83
|
+
AF DJ DJI 262 Djibouti, Republic of
|
84
|
+
AF GA GAB 266 Gabon, Gabonese Republic
|
85
|
+
EU GE GEO 268 Georgia
|
86
|
+
AS GE GEO 268 Georgia
|
87
|
+
AF GM GMB 270 Gambia, Republic of the
|
88
|
+
AS PS PSE 275 Palestinian Territory, Occupied
|
89
|
+
EU DE DEU 276 Germany, Federal Republic of
|
90
|
+
AF GH GHA 288 Ghana, Republic of
|
91
|
+
EU GI GIB 292 Gibraltar
|
92
|
+
OC KI KIR 296 Kiribati, Republic of
|
93
|
+
EU GR GRC 300 Greece, Hellenic Republic
|
94
|
+
NA GL GRL 304 Greenland
|
95
|
+
NA GD GRD 308 Grenada
|
96
|
+
NA GP GLP 312 Guadeloupe
|
97
|
+
OC GU GUM 316 Guam
|
98
|
+
NA GT GTM 320 Guatemala, Republic of
|
99
|
+
AF GN GIN 324 Guinea, Republic of
|
100
|
+
SA GY GUY 328 Guyana, Co-operative Republic of
|
101
|
+
NA HT HTI 332 Haiti, Republic of
|
102
|
+
AN HM HMD 334 Heard Island and McDonald Islands
|
103
|
+
EU VA VAT 336 Holy See (Vatican City State)
|
104
|
+
NA HN HND 340 Honduras, Republic of
|
105
|
+
AS HK HKG 344 Hong Kong, Special Administrative Region of China
|
106
|
+
EU HU HUN 348 Hungary, Republic of
|
107
|
+
EU IS ISL 352 Iceland, Republic of
|
108
|
+
AS IN IND 356 India, Republic of
|
109
|
+
AS ID IDN 360 Indonesia, Republic of
|
110
|
+
AS IR IRN 364 Iran, Islamic Republic of
|
111
|
+
AS IQ IRQ 368 Iraq, Republic of
|
112
|
+
EU IE IRL 372 Ireland
|
113
|
+
AS IL ISR 376 Israel, State of
|
114
|
+
EU IT ITA 380 Italy, Italian Republic
|
115
|
+
AF CI CIV 384 Cote d'Ivoire, Republic of
|
116
|
+
NA JM JAM 388 Jamaica
|
117
|
+
AS JP JPN 392 Japan
|
118
|
+
EU KZ KAZ 398 Kazakhstan, Republic of
|
119
|
+
AS KZ KAZ 398 Kazakhstan, Republic of
|
120
|
+
AS JO JOR 400 Jordan, Hashemite Kingdom of
|
121
|
+
AF KE KEN 404 Kenya, Republic of
|
122
|
+
AS KP PRK 408 Korea, Democratic People's Republic of
|
123
|
+
AS KR KOR 410 Korea, Republic of
|
124
|
+
AS KW KWT 414 Kuwait, State of
|
125
|
+
AS KG KGZ 417 Kyrgyz Republic
|
126
|
+
AS LA LAO 418 Lao People's Democratic Republic
|
127
|
+
AS LB LBN 422 Lebanon, Lebanese Republic
|
128
|
+
AF LS LSO 426 Lesotho, Kingdom of
|
129
|
+
EU LV LVA 428 Latvia, Republic of
|
130
|
+
AF LR LBR 430 Liberia, Republic of
|
131
|
+
AF LY LBY 434 Libyan Arab Jamahiriya
|
132
|
+
EU LI LIE 438 Liechtenstein, Principality of
|
133
|
+
EU LT LTU 440 Lithuania, Republic of
|
134
|
+
EU LU LUX 442 Luxembourg, Grand Duchy of
|
135
|
+
AS MO MAC 446 Macao, Special Administrative Region of China
|
136
|
+
AF MG MDG 450 Madagascar, Republic of
|
137
|
+
AF MW MWI 454 Malawi, Republic of
|
138
|
+
AS MY MYS 458 Malaysia
|
139
|
+
AS MV MDV 462 Maldives, Republic of
|
140
|
+
AF ML MLI 466 Mali, Republic of
|
141
|
+
EU MT MLT 470 Malta, Republic of
|
142
|
+
NA MQ MTQ 474 Martinique
|
143
|
+
AF MR MRT 478 Mauritania, Islamic Republic of
|
144
|
+
AF MU MUS 480 Mauritius, Republic of
|
145
|
+
NA MX MEX 484 Mexico, United Mexican States
|
146
|
+
EU MC MCO 492 Monaco, Principality of
|
147
|
+
AS MN MNG 496 Mongolia
|
148
|
+
EU MD MDA 498 Moldova, Republic of
|
149
|
+
EU ME MNE 499 Montenegro, Republic of
|
150
|
+
NA MS MSR 500 Montserrat
|
151
|
+
AF MA MAR 504 Morocco, Kingdom of
|
152
|
+
AF MZ MOZ 508 Mozambique, Republic of
|
153
|
+
AS OM OMN 512 Oman, Sultanate of
|
154
|
+
AF NA NAM 516 Namibia, Republic of
|
155
|
+
OC NR NRU 520 Nauru, Republic of
|
156
|
+
AS NP NPL 524 Nepal, State of
|
157
|
+
EU NL NLD 528 Netherlands, Kingdom of the
|
158
|
+
NA AN ANT 530 Netherlands Antilles
|
159
|
+
NA CW CUW 531 Curaçao
|
160
|
+
NA AW ABW 533 Aruba
|
161
|
+
NA SX SXM 534 Sint Maarten (Netherlands)
|
162
|
+
NA BQ BES 535 Bonaire, Sint Eustatius and Saba
|
163
|
+
OC NC NCL 540 New Caledonia
|
164
|
+
OC VU VUT 548 Vanuatu, Republic of
|
165
|
+
OC NZ NZL 554 New Zealand
|
166
|
+
NA NI NIC 558 Nicaragua, Republic of
|
167
|
+
AF NE NER 562 Niger, Republic of
|
168
|
+
AF NG NGA 566 Nigeria, Federal Republic of
|
169
|
+
OC NU NIU 570 Niue
|
170
|
+
OC NF NFK 574 Norfolk Island
|
171
|
+
EU NO NOR 578 Norway, Kingdom of
|
172
|
+
OC MP MNP 580 Northern Mariana Islands, Commonwealth of the
|
173
|
+
OC UM UMI 581 United States Minor Outlying Islands
|
174
|
+
NA UM UMI 581 United States Minor Outlying Islands
|
175
|
+
OC FM FSM 583 Micronesia, Federated States of
|
176
|
+
OC MH MHL 584 Marshall Islands, Republic of the
|
177
|
+
OC PW PLW 585 Palau, Republic of
|
178
|
+
AS PK PAK 586 Pakistan, Islamic Republic of
|
179
|
+
NA PA PAN 591 Panama, Republic of
|
180
|
+
OC PG PNG 598 Papua New Guinea, Independent State of
|
181
|
+
SA PY PRY 600 Paraguay, Republic of
|
182
|
+
SA PE PER 604 Peru, Republic of
|
183
|
+
AS PH PHL 608 Philippines, Republic of the
|
184
|
+
OC PN PCN 612 Pitcairn Islands
|
185
|
+
EU PL POL 616 Poland, Republic of
|
186
|
+
EU PT PRT 620 Portugal, Portuguese Republic
|
187
|
+
AF GW GNB 624 Guinea-Bissau, Republic of
|
188
|
+
AS TL TLS 626 Timor-Leste, Democratic Republic of
|
189
|
+
NA PR PRI 630 Puerto Rico, Commonwealth of
|
190
|
+
AS QA QAT 634 Qatar, State of
|
191
|
+
AF RE REU 638 Reunion
|
192
|
+
EU RO ROU 642 Romania
|
193
|
+
EU RU RUS 643 Russian Federation
|
194
|
+
AS RU RUS 643 Russian Federation
|
195
|
+
AF RW RWA 646 Rwanda, Republic of
|
196
|
+
NA BL BLM 652 Saint Barthelemy
|
197
|
+
AF SH SHN 654 Saint Helena
|
198
|
+
NA KN KNA 659 Saint Kitts and Nevis, Federation of
|
199
|
+
NA AI AIA 660 Anguilla
|
200
|
+
NA LC LCA 662 Saint Lucia
|
201
|
+
NA MF MAF 663 Saint Martin
|
202
|
+
NA PM SPM 666 Saint Pierre and Miquelon
|
203
|
+
NA VC VCT 670 Saint Vincent and the Grenadines
|
204
|
+
EU SM SMR 674 San Marino, Republic of
|
205
|
+
AF ST STP 678 Sao Tome and Principe, Democratic Republic of
|
206
|
+
AS SA SAU 682 Saudi Arabia, Kingdom of
|
207
|
+
AF SN SEN 686 Senegal, Republic of
|
208
|
+
EU RS SRB 688 Serbia, Republic of
|
209
|
+
AF SC SYC 690 Seychelles, Republic of
|
210
|
+
AF SL SLE 694 Sierra Leone, Republic of
|
211
|
+
AS SG SGP 702 Singapore, Republic of
|
212
|
+
EU SK SVK 703 Slovakia (Slovak Republic)
|
213
|
+
AS VN VNM 704 Vietnam, Socialist Republic of
|
214
|
+
EU SI SVN 705 Slovenia, Republic of
|
215
|
+
AF SO SOM 706 Somalia, Somali Republic
|
216
|
+
AF ZA ZAF 710 South Africa, Republic of
|
217
|
+
AF ZW ZWE 716 Zimbabwe, Republic of
|
218
|
+
EU ES ESP 724 Spain, Kingdom of
|
219
|
+
AF SS SSD 728 South Sudan
|
220
|
+
AF EH ESH 732 Western Sahara
|
221
|
+
AF SD SDN 736 Sudan, Republic of
|
222
|
+
SA SR SUR 740 Suriname, Republic of
|
223
|
+
EU SJ SJM 744 Svalbard & Jan Mayen Islands
|
224
|
+
AF SZ SWZ 748 Swaziland, Kingdom of
|
225
|
+
EU SE SWE 752 Sweden, Kingdom of
|
226
|
+
EU CH CHE 756 Switzerland, Swiss Confederation
|
227
|
+
AS SY SYR 760 Syrian Arab Republic
|
228
|
+
AS TJ TJK 762 Tajikistan, Republic of
|
229
|
+
AS TH THA 764 Thailand, Kingdom of
|
230
|
+
AF TG TGO 768 Togo, Togolese Republic
|
231
|
+
OC TK TKL 772 Tokelau
|
232
|
+
OC TO TON 776 Tonga, Kingdom of
|
233
|
+
NA TT TTO 780 Trinidad and Tobago, Republic of
|
234
|
+
AS AE ARE 784 United Arab Emirates
|
235
|
+
AF TN TUN 788 Tunisia, Tunisian Republic
|
236
|
+
EU TR TUR 792 Turkey, Republic of
|
237
|
+
AS TR TUR 792 Turkey, Republic of
|
238
|
+
AS TM TKM 795 Turkmenistan
|
239
|
+
NA TC TCA 796 Turks and Caicos Islands
|
240
|
+
OC TV TUV 798 Tuvalu
|
241
|
+
AF UG UGA 800 Uganda, Republic of
|
242
|
+
EU UA UKR 804 Ukraine
|
243
|
+
EU MK MKD 807 Macedonia, The Former Yugoslav Republic of
|
244
|
+
AF EG EGY 818 Egypt, Arab Republic of
|
245
|
+
EU GB GBR 826 United Kingdom of Great Britain & Northern Ireland
|
246
|
+
EU GG GGY 831 Guernsey, Bailiwick of
|
247
|
+
EU JE JEY 832 Jersey, Bailiwick of
|
248
|
+
EU IM IMN 833 Isle of Man
|
249
|
+
AF TZ TZA 834 Tanzania, United Republic of
|
250
|
+
NA US USA 840 United States of America
|
251
|
+
NA VI VIR 850 United States Virgin Islands
|
252
|
+
AF BF BFA 854 Burkina Faso
|
253
|
+
SA UY URY 858 Uruguay, Eastern Republic of
|
254
|
+
AS UZ UZB 860 Uzbekistan, Republic of
|
255
|
+
SA VE VEN 862 Venezuela, Bolivarian Republic of
|
256
|
+
OC WF WLF 876 Wallis and Futuna
|
257
|
+
OC WS WSM 882 Samoa, Independent State of
|
258
|
+
AS YE YEM 887 Yemen
|
259
|
+
AF ZM ZMB 894 Zambia, Republic of
|
260
|
+
OC XX null null Disputed Territory
|
261
|
+
AS XE null null Iraq-Saudi Arabia Neutral Zone
|
262
|
+
AS XD null null United Nations Neutral Zone
|
263
|
+
AS XS null null Spratly Islands
|
data/test/test.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'continent')
|
3
|
+
|
4
|
+
class TestContinent < Test::Unit::TestCase
|
5
|
+
def test_data
|
6
|
+
d = Continent.data
|
7
|
+
assert_kind_of Hash, d
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_by_alpha_3_code
|
11
|
+
c = Continent.by_alpha_3_code 'AUS'
|
12
|
+
assert_kind_of Hash, c
|
13
|
+
assert_operator c.length, '>', 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_by_alpha_2_code
|
17
|
+
c = Continent.by_alpha_2_code 'AU'
|
18
|
+
assert_kind_of Hash, c
|
19
|
+
assert_operator c.length, '>', 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_by_numeric_code
|
23
|
+
c = Continent.by_numeric_code 36
|
24
|
+
assert_kind_of Hash, c
|
25
|
+
assert_operator c.length, '>', 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_by_continent_code
|
29
|
+
c = Continent.by_continent_code 'OC'
|
30
|
+
assert_kind_of Array, c
|
31
|
+
assert_operator c.length, '>', 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_continent_name
|
35
|
+
c = Continent.by_alpha_3_code 'AUS'
|
36
|
+
con = c[:continent_codes].first
|
37
|
+
assert_equal 'Oceania', Continent.continent_name(con)
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-continent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael Alexander
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Get countries by continent, or find the continents for a country given
|
15
|
+
ISO 3166-1 alpha-2, alpha-3 and numeric codes
|
16
|
+
email: beefsack@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/continent.rb
|
22
|
+
- bin/parse_raw
|
23
|
+
- COPYING
|
24
|
+
- README.md
|
25
|
+
- Gemfile
|
26
|
+
- Rakefile
|
27
|
+
- Gemfile.lock
|
28
|
+
- test/test.rb
|
29
|
+
- share/continent_names.yml
|
30
|
+
- share/data.yml
|
31
|
+
- share/raw
|
32
|
+
homepage: https://github.com/beefsack/ruby-continent
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.23
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: A library for continents and their countries
|
56
|
+
test_files: []
|