factbook 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ef14a3d11b87b854592f81c50406e43f4399ac3
4
- data.tar.gz: 8c4eb43f4dfdca5b20d4dd60699b51c52a8cc7ff
3
+ metadata.gz: 644b296946acd4f2c6993fd8b6f35342058e14f5
4
+ data.tar.gz: 2ee8bfffd3efe837e42dc400434f40fe5359a0a9
5
5
  SHA512:
6
- metadata.gz: 57066d2a00d4818330ca710947fa5fedfb80ad224b84d31d906eb7606ba8127b8c1f102405a61f6dd3742b3c6f0fa4ec10f290a8d1da3367747a85ca31279a14
7
- data.tar.gz: 6aa9fa498d6a1f836300e3fe985a5abd2cf8770211d414427608d2515f3d4fa56108b798e17a7e8d2b0f1bc52f8347787fd431cc97a099877eeafd89fffb12af
6
+ metadata.gz: f5e0b528262e1f5399eed7b6cebcace7a8311025212c1be05c266e5f6cf479e852d6682d566f3759d714cf6d37b39ac29692e4cb8d6c13352336768d270eff42
7
+ data.tar.gz: 25c5c82128a134f68ec139e031b2825c5e820cb2e21f42c10d41430b702693e7cfd9a9a248e5c3f5b899f159e34bc02980f77eed8130414f54bc94e4d68a8b79
@@ -1,3 +1,3 @@
1
- ### 0.0.1 / 2014-07-07
2
-
3
- * Everything is new. First release.
1
+ ### 0.0.1 / 2014-07-07
2
+
3
+ * Everything is new. First release.
@@ -1,4 +1,4 @@
1
- HISTORY.md
1
+ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
data/README.md CHANGED
@@ -1,543 +1,548 @@
1
- # factbook - scripts for the world factbook (get open structured data e.g JSON etc.)
2
-
3
- * home :: [github.com/factbook/factbook](https://github.com/factbook/factbook)
4
- * bugs :: [github.com/factbook/factbook/issues](https://github.com/factbook/factbook/issues)
5
- * gem :: [rubygems.org/gems/factbook](https://rubygems.org/gems/factbook)
6
- * rdoc :: [rubydoc.info/gems/factbook](http://rubydoc.info/gems/factbook)
7
- * forum :: [groups.google.com/group/openmundi](https://groups.google.com/group/openmundi)
8
-
9
-
10
-
11
- ## What's the World Factbook?
12
-
13
- The World Factbook [1][2] published by the Central Intelligence Agency (CIA)
14
- offers free country profiles in the public domain (that is, no copyright(s), no rights reserved).
15
-
16
- - [1] [The World Factbook](https://www.cia.gov/library/publications/the-world-factbook/)
17
- - [2] [Wikipedia Article: The World Factbook](http://en.wikipedia.org/wiki/The_World_Factbook)
18
-
19
-
20
- ## Usage
21
-
22
- ### Get country profile page as a hash (that is, structured data e.g. nested key/values)
23
-
24
- ```ruby
25
- page = Factbook::Page.new( 'br' ) # br is the country code for Brazil
26
- pp page.data # pretty print hash
27
- ```
28
-
29
- resulting in:
30
-
31
- ```ruby
32
- {"Introduction"=>
33
- {"Background"=>
34
- {"text"=>
35
- "Following more than three centuries under Portuguese rule,
36
- Brazil gained its independence in 1822, ..."}},
37
- "Geography"=>
38
- {"Location"=>{"text"=>"Eastern South America, bordering the Atlantic Ocean"},
39
- "Geographic coordinates"=>{"text"=>"10 00 S, 55 00 W"},
40
- "Map references"=>{"text"=>"South America"},
41
- "Area"=>
42
- {"total"=>{"text"=>"8,515,770 sq km"},
43
- "land"=>{"text"=>"8,358,140 sq km"},
44
- "water"=>{"text"=>"157,630 sq km"},
45
- "note"=>
46
- {"text"=>
47
- "includes Arquipelago de Fernando de Noronha, Atol das Rocas, ..."}},
48
- "Area - comparative"=>
49
- {"text"=>"slightly smaller than the US"},
50
- "Land boundaries"=>
51
- {"total"=>{"text"=>"16,145 km"},
52
- "border countries (10)"=>
53
- {"text"=>
54
- "Argentina 1,263 km, Bolivia 3,403 km, Colombia 1,790 km,
55
- French Guiana 649 km, Guyana 1,308 km, Paraguay 1,371 km, Peru 2,659 km,
56
- Suriname 515 km, Uruguay 1,050 km, Venezuela 2,137 km"}},
57
- "Climate"=>{"text"=>"mostly tropical, but temperate in south"},
58
- "Elevation extremes"=>
59
- {"lowest point"=>{"text"=>"Atlantic Ocean 0 m"},
60
- "highest point"=>{"text"=>"Pico da Neblina 2,994 m"}},
61
- "Natural resources"=>
62
- {"text"=>
63
- "bauxite, gold, iron ore, manganese, nickel, phosphates, ..."},
64
- ...
65
- ```
66
-
67
- ### Use shortcut attribute accessors
68
-
69
- ```ruby
70
- pp page.background ## same as page['Introduction']['Background']['text']
71
- # => "Following more than three centuries..."
72
- pp page.area ## same as page['Geography'][''Area']['total']['text']
73
- # => "8,515,770 sq km"
74
- pp page.area_land ## same as page['Geography'][''Area']['land']['text']
75
- # => "8,358,140 sq km"
76
- pp page.area_water ## same as page['Geography'][''Area']['water']['text']
77
- # => "157,630 sq km"
78
- pp page.area_note ## same as page['Geography'][''Area']['note']['text']
79
- # => "includes Arquipelago de Fernando de Noronha, Atol das Rocas, ..."
80
- pp page.area_comparative ## same as page['Geography']['Area - comparative']['text']
81
- # => "slightly smaller than the US"
82
- pp page.climate ## same as page['Geography']['Climate']['text']
83
- # => "mostly tropical, but temperate in south"
84
- pp page.terrain ## same as page['Geography']['Terrain']['text']
85
- # => "mostly flat to rolling lowlands in north; ..."
86
- pp page.elevation_lowest ## same as page['Geography']['Elevation extremes']['lowest point']['text']
87
- # => "Atlantic Ocean 0 m"
88
- pp page.elevation_highest ## same as page['Geography']['Elevation extremes']['highest point']['text']
89
- # => "Pico da Neblina 2,994 m"
90
- pp page.resources ## same as page['Geography'][Natural resources']['text']
91
- # => "bauxite, gold, iron ore, manganese, nickel, phosphates, ..."
92
- ...
93
- ```
94
-
95
- See [`data/attributes.yml`](data/attributes.yml) for the full listing of all built-in attribute shortcut accessors.
96
- See [Attributes](ATTRIBUTES.md) for a quick reference listing.
97
-
98
-
99
- ### Save to disk as JSON
100
-
101
- ```ruby
102
- page = Factbook::Page.new( 'br' )
103
- File.open( 'br.json', 'w') do |f|
104
- f.write page.to_json
105
- end
106
- ```
107
-
108
-
109
- ### List all codes
110
-
111
- ```ruby
112
- Factbook.codes.each do |code|
113
- pp code
114
- end
115
- ```
116
-
117
- resulting in:
118
-
119
- ```ruby
120
- #<struct Factbook::Codes::Code
121
- code="af",
122
- name="Afghanistan",
123
- category="Countries",
124
- region="South Asia">
125
- #<struct Factbook::Codes::Code
126
- code="al",
127
- name="Albania",
128
- category="Countries",
129
- region="Europe">
130
- #<struct Factbook::Codes::Code
131
- code="ag",
132
- name="Algeria",
133
- category="Countries",
134
- region="Africa">
135
- #<struct Factbook::Codes::Code
136
- code="an",
137
- name="Andorra",
138
- category="Countries",
139
- region="Europe">
140
- ...
141
- ```
142
-
143
- Note: You can filter codes by category e.g. Countries, Dependencies, Miscellaneous, Oceans, etc.
144
- and/or by region e.g. Africa, Europe, South Asia, Central America and Caribbean, etc.
145
-
146
-
147
- ```ruby
148
-
149
- assert_equal 261, Factbook.codes.size
150
-
151
- ## categories
152
- assert_equal 195, Factbook.codes.countries.size
153
- assert_equal 52, Factbook.codes.dependencies.size
154
- assert_equal 5, Factbook.codes.oceans.size
155
- assert_equal 1, Factbook.codes.world.size
156
- assert_equal 2, Factbook.codes.others.size
157
- assert_equal 6, Factbook.codes.misc.size
158
-
159
- ## regions
160
- assert_equal 55, Factbook.codes.europe.size
161
- assert_equal 9, Factbook.codes.south_asia.size
162
- assert_equal 6, Factbook.codes.central_asia.size
163
- assert_equal 22, Factbook.codes.east_n_souteast_asia.size
164
- assert_equal 19, Factbook.codes.middle_east.size
165
- assert_equal 56, Factbook.codes.africa.size
166
- assert_equal 7, Factbook.codes.north_america.size
167
- assert_equal 33, Factbook.codes.central_america_n_caribbean.size
168
- assert_equal 14, Factbook.codes.south_america.size
169
- assert_equal 30, Factbook.codes.australia_oceania.size
170
- assert_equal 4, Factbook.codes.antartica.size
171
- assert_equal 5, Factbook.codes.region('Oceans').size
172
- assert_equal 1, Factbook.codes.region('World').size
173
-
174
- ## categories + regions
175
- assert_equal 45, Factbook.codes.countries.europe.size
176
- ...
177
- ```
178
-
179
- See [`data/codes.csv`](data/codes.csv) for the built-in listing of all codes with categories and regions.
180
-
181
-
182
-
183
- ## The World Factbook Summary (267 Entries)
184
-
185
- The World Factbook includes 267 entries -
186
- 195 sovereign countries /
187
- 2 others /
188
- 58 dependencies /
189
- 6 miscellaneous /
190
- 5 oceans /
191
- 1 world:
192
-
193
-
194
- ### Sovereign Countries (195)
195
-
196
- **A**
197
- `af` Afghanistan
198
- `al` Albania
199
- `ag` Algeria
200
- `an` Andorra
201
- `ao` Angola
202
- `ac` Antigua and Barbuda
203
- `ar` Argentina
204
- `am` Armenia
205
- `as` Australia
206
- `au` Austria
207
- `aj` Azerbaijan
208
- **B**
209
- `bf` The Bahamas
210
- `ba` Bahrain
211
- `bg` Bangladesh
212
- `bb` Barbados
213
- `bo` Belarus
214
- `be` Belgium
215
- `bh` Belize
216
- `bn` Benin
217
- `bt` Bhutan
218
- `bl` Bolivia
219
- `bk` Bosnia and Herzegovina
220
- `bc` Botswana
221
- `br` Brazil
222
- `bx` Brunei
223
- `bu` Bulgaria
224
- `uv` Burkina Faso
225
- `bm` Burma
226
- `by` Burundi
227
- **C**
228
- `cb` Cambodia
229
- `cm` Cameroon
230
- `ca` Canada
231
- `cv` Cape Verde
232
- `ct` Central African Republic
233
- `cd` Chad
234
- `ci` Chile
235
- `ch` China
236
- `co` Colombia
237
- `cn` Comoros
238
- `cg` Congo DR
239
- `cf` Congo
240
- `cs` Costa Rica
241
- `iv` Cote d'Ivoire
242
- `hr` Croatia
243
- `cu` Cuba
244
- `cy` Cyprus
245
- `ez` Czech Republic
246
- **D**
247
- `da` Denmark
248
- `dj` Djibouti
249
- `do` Dominica
250
- `dr` Dominican Republic
251
- **E**
252
- `ec` Ecuador
253
- `eg` Egypt
254
- `es` El Salvador
255
- `ek` Equatorial Guinea
256
- `er` Eritrea
257
- `en` Estonia
258
- `et` Ethiopia
259
- **F**
260
- `fj` Fiji
261
- `fi` Finland
262
- `fr` France
263
- **G**
264
- `gb` Gabon
265
- `ga` The Gambia
266
- `gg` Georgia
267
- `gm` Germany
268
- `gh` Ghana
269
- `gr` Greece
270
- `gj` Grenada
271
- `gt` Guatemala
272
- `gv` Guinea
273
- `pu` Guinea-Bissau
274
- `gy` Guyana
275
- **H**
276
- `ha` Haiti
277
- `ho` Honduras
278
- `hu` Hungary
279
- **I**
280
- `ic` Iceland
281
- `in` India
282
- `id` Indonesia
283
- `ir` Iran
284
- `iz` Iraq
285
- `ei` Ireland
286
- `is` Israel
287
- `it` Italy
288
- **J**
289
- `jm` Jamaica
290
- `ja` Japan
291
- `jo` Jordan
292
- **K**
293
- `kz` Kazakhstan
294
- `ke` Kenya
295
- `kr` Kiribati
296
- `kn` North Korea
297
- `ks` South Korea
298
- `kv` Kosovo
299
- `ku` Kuwait
300
- `kg` Kyrgyzstan
301
- **L**
302
- `la` Laos
303
- `lg` Latvia
304
- `le` Lebanon
305
- `lt` Lesotho
306
- `li` Liberia
307
- `ly` Libya
308
- `ls` Liechtenstein
309
- `lh` Lithuania
310
- `lu` Luxembourg
311
- **M**
312
- `mk` Macedonia
313
- `ma` Madagascar
314
- `mi` Malawi
315
- `my` Malaysia
316
- `mv` Maldives
317
- `ml` Mali
318
- `mt` Malta
319
- `rm` Marshall Islands
320
- `mr` Mauritania
321
- `mp` Mauritius
322
- `mx` Mexico
323
- `fm` Micronesia
324
- `md` Moldova
325
- `mn` Monaco
326
- `mg` Mongolia
327
- `mj` Montenegro
328
- `mo` Morocco
329
- `mz` Mozambique
330
- **N**
331
- `wa` Namibia
332
- `nr` Nauru
333
- `np` Nepal
334
- `nl` Netherlands
335
- `nz` New Zealand
336
- `nu` Nicaragua
337
- `ng` Niger
338
- `ni` Nigeria
339
- `no` Norway
340
- **O**
341
- `mu` Oman
342
- **P**
343
- `pk` Pakistan
344
- `ps` Palau
345
- `pm` Panama
346
- `pp` Papua New Guinea
347
- `pa` Paraguay
348
- `pe` Peru
349
- `rp` Philippines
350
- `pl` Poland
351
- `po` Portugal
352
- **Q**
353
- `qa` Qatar
354
- **R**
355
- `ro` Romania
356
- `rs` Russia
357
- `rw` Rwanda
358
- **S**
359
- `sc` Saint Kitts and Nevis
360
- `st` Saint Lucia
361
- `vc` Saint Vincent and the Grenadines
362
- `ws` Samoa
363
- `sm` San Marino
364
- `tp` Sao Tome and Principe
365
- `sa` Saudi Arabia
366
- `sg` Senegal
367
- `ri` Serbia
368
- `se` Seychelles
369
- `sl` Sierra Leone
370
- `sn` Singapore
371
- `lo` Slovakia
372
- `si` Slovenia
373
- `bp` Solomon Islands
374
- `so` Somalia
375
- `sf` South Africa
376
- `od` South Sudan
377
- `sp` Spain
378
- `ce` Sri Lanka
379
- `su` Sudan
380
- `ns` Suriname
381
- `wz` Swaziland
382
- `sw` Sweden
383
- `sz` Switzerland
384
- `sy` Syria
385
- **T**
386
- `ti` Tajikistan
387
- `tz` Tanzania
388
- `th` Thailand
389
- `tt` Timor-Leste
390
- `to` Togo
391
- `tn` Tonga
392
- `td` Trinidad and Tobago
393
- `ts` Tunisia
394
- `tu` Turkey
395
- `tx` Turkmenistan
396
- `tv` Tuvalu
397
- **U**
398
- `ug` Uganda
399
- `up` Ukraine
400
- `ae` United Arab Emirates
401
- `uk` United Kingdom
402
- `us` United States
403
- `uy` Uruguay
404
- `uz` Uzbekistan
405
- **V**
406
- `nh` Vanuatu
407
- `vt` Vatican City (Holy See)
408
- `ve` Venezuela
409
- `vm` Vietnam
410
- **Y**
411
- `ym` Yemen
412
- **Z**
413
- `za` Zambia
414
- `zi` Zimbabwe
415
-
416
-
417
- ### Other (2)
418
-
419
- `tw` Taiwan
420
- `ee` European Union
421
-
422
- ### Dependencies (58)
423
-
424
- Australia (6):
425
- `at` Ashmore and Cartier Islands
426
- `kt` Christmas Island
427
- `ck` Cocos (Keeling) Islands
428
- `cr` Coral Sea Islands
429
- `hm` Heard Island and McDonald Islands
430
- `nf` Norfolk Island
431
-
432
- China (2):
433
- `hk` Hong Kong
434
- `mc` Macau
435
-
436
- Denmark (2):
437
- `fo` Faroe Islands
438
- `gl` Greenland
439
-
440
- France (8):
441
- `ip` Clipperton Island
442
- `fp` French Polynesia
443
- `fs` French Southern and Antarctic Lands
444
- `nc` New Caledonia
445
- `tb` Saint Barthelemy
446
- `rn` Saint Martin
447
- `sb` Saint Pierre and Miquelon
448
- `wf` Wallis and Futuna
449
-
450
- Netherlands (3):
451
- `aa` Aruba
452
- `uc` Curacao
453
- `nn` Sint Maarten
454
-
455
- New Zealand (3):
456
- `cw` Cook Islands
457
- `ne` Niue
458
- `tl` Tokelau
459
-
460
- Norway (3):
461
- `bv` Bouvet Island
462
- `jn` Jan Mayen
463
- `sv` Svalbard
464
-
465
- Great Britain (17):
466
- `ax` Akrotiri (Sovereign Base)
467
- `av` Anguilla
468
- `bd` Bermuda
469
- `io` British Indian Ocean Territory
470
- `vi` British Virgin Islands
471
- `cj` Cayman Islands
472
- `dx` Dhekelia (Sovereign Base)
473
- `fk` Falkland Islands
474
- `gi` Gibraltar
475
- `gk` Guernsey
476
- `je` Jersey
477
- `im` Isle of Man
478
- `mh` Montserrat
479
- `pc` Pitcairn Islands
480
- `sh` Saint Helena
481
- `sx` South Georgia and the South Sandwich Islands
482
- `tk` Turks and Caicos Islands
483
-
484
- United States (14):
485
- `aq` American Samoa
486
- `gq` Guam
487
- `bq` Navassa Island
488
- `cq` Northern Mariana Islands
489
- `rq` Puerto Rico
490
- `vq` US Virgin Islands
491
- `wq` Wake Island
492
- `um` US Pacific Island Wildlife Refuges
493
- (Baker Island, Howland Island, Jarvis Island, Johnston Atoll, Kingman Reef, Midway Islands, Palmyra Atoll)
494
-
495
-
496
- ### Miscellaneous (6)
497
-
498
- `ay` Antarctica
499
- `gz` Gaza Strip
500
- `pf` Paracel Islands
501
- `pg` Spratly Islands
502
- `we` West Bank
503
- `wi` Western Sahara
504
-
505
- ### Oceans (5)
506
-
507
- `xq` Arctic Ocean
508
- `zh` Atlantic Ocean
509
- `xo` Indian Ocean
510
- `zn` Pacific Ocean
511
- `oo` Southern Ocean
512
-
513
- ### World (1)
514
-
515
- `xx` World
516
-
517
-
518
-
519
-
520
- ## Ready-To-Use Public Domain Factbook Datasets
521
-
522
- [opendatajson/factbook.json](https://github.com/opendatajson/factbook.json) - open (public domain)
523
- factbook country profiles in JSON for all the world's countries (using internet domain names
524
- for country codes e.g. Austria is `at.json` not `au.json`, Germany is `de.json` not `gm.json` and so on)
525
-
526
-
527
- ## Install
528
-
529
- Just install the gem:
530
-
531
- $ gem install factbook
532
-
533
-
534
- ## License
535
-
536
- The `factbook` scripts are dedicated to the public domain.
537
- Use it as you please with no restrictions whatsoever.
538
-
539
-
540
- ## Questions? Comments?
541
-
542
- Send them along to the [Open Mundi (world.db) Database Forum/Mailing List](http://groups.google.com/group/openmundi).
543
- Thanks!
1
+ # factbook - scripts for the world factbook (get open structured data e.g JSON etc.)
2
+
3
+ * home :: [github.com/factbook/factbook](https://github.com/factbook/factbook)
4
+ * bugs :: [github.com/factbook/factbook/issues](https://github.com/factbook/factbook/issues)
5
+ * gem :: [rubygems.org/gems/factbook](https://rubygems.org/gems/factbook)
6
+ * rdoc :: [rubydoc.info/gems/factbook](http://rubydoc.info/gems/factbook)
7
+ * forum :: [groups.google.com/group/openmundi](https://groups.google.com/group/openmundi)
8
+
9
+
10
+
11
+ ## What's the World Factbook?
12
+
13
+ The World Factbook [1][2] published by the Central Intelligence Agency (CIA)
14
+ offers free country profiles in the public domain (that is, no copyright(s), no rights reserved).
15
+
16
+ - [1] [The World Factbook](https://www.cia.gov/library/publications/the-world-factbook/)
17
+ - [2] [Wikipedia Article: The World Factbook](http://en.wikipedia.org/wiki/The_World_Factbook)
18
+
19
+
20
+ ## Usage
21
+
22
+ ### Get country profile page as a hash (that is, structured data e.g. nested key/values)
23
+
24
+ ```ruby
25
+ page = Factbook::Page.new( 'br' ) # br is the country code for Brazil
26
+ pp page.data # pretty print hash
27
+ ```
28
+
29
+ resulting in:
30
+
31
+ ```ruby
32
+ {"Introduction"=>
33
+ {"Background"=>
34
+ {"text"=>
35
+ "Following more than three centuries under Portuguese rule,
36
+ Brazil gained its independence in 1822, ..."}},
37
+ "Geography"=>
38
+ {"Location"=>{"text"=>"Eastern South America, bordering the Atlantic Ocean"},
39
+ "Geographic coordinates"=>{"text"=>"10 00 S, 55 00 W"},
40
+ "Map references"=>{"text"=>"South America"},
41
+ "Area"=>
42
+ {"total"=>{"text"=>"8,515,770 sq km"},
43
+ "land"=>{"text"=>"8,358,140 sq km"},
44
+ "water"=>{"text"=>"157,630 sq km"},
45
+ "note"=>
46
+ {"text"=>
47
+ "includes Arquipelago de Fernando de Noronha, Atol das Rocas, ..."}},
48
+ "Area - comparative"=>
49
+ {"text"=>"slightly smaller than the US"},
50
+ "Land boundaries"=>
51
+ {"total"=>{"text"=>"16,145 km"},
52
+ "border countries (10)"=>
53
+ {"text"=>
54
+ "Argentina 1,263 km, Bolivia 3,403 km, Colombia 1,790 km,
55
+ French Guiana 649 km, Guyana 1,308 km, Paraguay 1,371 km, Peru 2,659 km,
56
+ Suriname 515 km, Uruguay 1,050 km, Venezuela 2,137 km"}},
57
+ "Climate"=>{"text"=>"mostly tropical, but temperate in south"},
58
+ "Elevation extremes"=>
59
+ {"lowest point"=>{"text"=>"Atlantic Ocean 0 m"},
60
+ "highest point"=>{"text"=>"Pico da Neblina 2,994 m"}},
61
+ "Natural resources"=>
62
+ {"text"=>
63
+ "bauxite, gold, iron ore, manganese, nickel, phosphates, ..."},
64
+ ...
65
+ ```
66
+
67
+ ### Use shortcut attribute accessors
68
+
69
+ ```ruby
70
+ pp page.background ## same as page['Introduction']['Background']['text']
71
+ # => "Following more than three centuries..."
72
+ pp page.area ## same as page['Geography'][''Area']['total']['text']
73
+ # => "8,515,770 sq km"
74
+ pp page.area_land ## same as page['Geography'][''Area']['land']['text']
75
+ # => "8,358,140 sq km"
76
+ pp page.area_water ## same as page['Geography'][''Area']['water']['text']
77
+ # => "157,630 sq km"
78
+ pp page.area_note ## same as page['Geography'][''Area']['note']['text']
79
+ # => "includes Arquipelago de Fernando de Noronha, Atol das Rocas, ..."
80
+ pp page.area_comparative ## same as page['Geography']['Area - comparative']['text']
81
+ # => "slightly smaller than the US"
82
+ pp page.climate ## same as page['Geography']['Climate']['text']
83
+ # => "mostly tropical, but temperate in south"
84
+ pp page.terrain ## same as page['Geography']['Terrain']['text']
85
+ # => "mostly flat to rolling lowlands in north; ..."
86
+ pp page.elevation_lowest ## same as page['Geography']['Elevation extremes']['lowest point']['text']
87
+ # => "Atlantic Ocean 0 m"
88
+ pp page.elevation_highest ## same as page['Geography']['Elevation extremes']['highest point']['text']
89
+ # => "Pico da Neblina 2,994 m"
90
+ pp page.resources ## same as page['Geography'][Natural resources']['text']
91
+ # => "bauxite, gold, iron ore, manganese, nickel, phosphates, ..."
92
+ ...
93
+ ```
94
+
95
+ See [`data/attributes.yml`](data/attributes.yml) for the full listing of all built-in attribute shortcut accessors.
96
+ See [Attributes](ATTRIBUTES.md) for a quick reference listing.
97
+
98
+
99
+ ### Save to disk as JSON
100
+
101
+ ```ruby
102
+ page = Factbook::Page.new( 'br' )
103
+ File.open( 'br.json', 'w:utf-8') do |f|
104
+ f.write page.to_json
105
+ end
106
+ ```
107
+
108
+
109
+ ### List all codes
110
+
111
+ ```ruby
112
+ Factbook.codes.each do |code|
113
+ pp code
114
+ end
115
+ ```
116
+
117
+ resulting in:
118
+
119
+ ```
120
+ #<struct Factbook::Codes::Code
121
+ code ="af",
122
+ name ="Afghanistan",
123
+ category="Countries",
124
+ region ="South Asia">
125
+ #<struct Factbook::Codes::Code
126
+ code ="al",
127
+ name ="Albania",
128
+ category="Countries",
129
+ region ="Europe">
130
+ #<struct Factbook::Codes::Code
131
+ code ="ag",
132
+ name ="Algeria",
133
+ category="Countries",
134
+ region ="Africa">
135
+ #<struct Factbook::Codes::Code
136
+ code ="an",
137
+ name ="Andorra",
138
+ category="Countries",
139
+ region ="Europe">
140
+ ...
141
+ ```
142
+
143
+ Note: You can filter codes by category e.g. Countries, Dependencies, Miscellaneous, Oceans, etc.
144
+ and/or by region e.g. Africa, Europe, South Asia, Central America and Caribbean, etc.
145
+
146
+
147
+ ```ruby
148
+
149
+ assert_equal 261, Factbook.codes.size
150
+
151
+ ## categories
152
+ assert_equal 195, Factbook.codes.countries.size
153
+ assert_equal 52, Factbook.codes.dependencies.size
154
+ assert_equal 5, Factbook.codes.oceans.size
155
+ assert_equal 1, Factbook.codes.world.size
156
+ assert_equal 2, Factbook.codes.others.size
157
+ assert_equal 6, Factbook.codes.misc.size
158
+
159
+ ## regions
160
+ assert_equal 55, Factbook.codes.europe.size
161
+ assert_equal 9, Factbook.codes.south_asia.size
162
+ assert_equal 6, Factbook.codes.central_asia.size
163
+ assert_equal 22, Factbook.codes.east_n_souteast_asia.size
164
+ assert_equal 19, Factbook.codes.middle_east.size
165
+ assert_equal 56, Factbook.codes.africa.size
166
+ assert_equal 7, Factbook.codes.north_america.size
167
+ assert_equal 33, Factbook.codes.central_america_n_caribbean.size
168
+ assert_equal 14, Factbook.codes.south_america.size
169
+ assert_equal 30, Factbook.codes.australia_oceania.size
170
+ assert_equal 4, Factbook.codes.antartica.size
171
+ assert_equal 5, Factbook.codes.region('Oceans').size
172
+ assert_equal 1, Factbook.codes.region('World').size
173
+
174
+ ## categories + regions
175
+ assert_equal 45, Factbook.codes.countries.europe.size
176
+ ...
177
+ ```
178
+
179
+ See [`data/codes.csv`](data/codes.csv) for the built-in listing of all codes with categories and regions.
180
+
181
+
182
+
183
+ ## The World Factbook Summary (267 Entries)
184
+
185
+ The World Factbook includes 267 entries -
186
+ 195 sovereign countries /
187
+ 2 others /
188
+ 58 dependencies /
189
+ 6 miscellaneous /
190
+ 5 oceans /
191
+ 1 world:
192
+
193
+
194
+ ### Sovereign Countries (195)
195
+
196
+ **A**
197
+ `af` Afghanistan
198
+ `al` Albania
199
+ `ag` Algeria
200
+ `an` Andorra
201
+ `ao` Angola
202
+ `ac` Antigua and Barbuda
203
+ `ar` Argentina
204
+ `am` Armenia
205
+ `as` Australia
206
+ `au` Austria
207
+ `aj` Azerbaijan
208
+ **B**
209
+ `bf` The Bahamas
210
+ `ba` Bahrain
211
+ `bg` Bangladesh
212
+ `bb` Barbados
213
+ `bo` Belarus
214
+ `be` Belgium
215
+ `bh` Belize
216
+ `bn` Benin
217
+ `bt` Bhutan
218
+ `bl` Bolivia
219
+ `bk` Bosnia and Herzegovina
220
+ `bc` Botswana
221
+ `br` Brazil
222
+ `bx` Brunei
223
+ `bu` Bulgaria
224
+ `uv` Burkina Faso
225
+ `bm` Burma
226
+ `by` Burundi
227
+ **C**
228
+ `cb` Cambodia
229
+ `cm` Cameroon
230
+ `ca` Canada
231
+ `cv` Cape Verde
232
+ `ct` Central African Republic
233
+ `cd` Chad
234
+ `ci` Chile
235
+ `ch` China
236
+ `co` Colombia
237
+ `cn` Comoros
238
+ `cg` Congo DR
239
+ `cf` Congo
240
+ `cs` Costa Rica
241
+ `iv` Cote d'Ivoire
242
+ `hr` Croatia
243
+ `cu` Cuba
244
+ `cy` Cyprus
245
+ `ez` Czech Republic
246
+ **D**
247
+ `da` Denmark
248
+ `dj` Djibouti
249
+ `do` Dominica
250
+ `dr` Dominican Republic
251
+ **E**
252
+ `ec` Ecuador
253
+ `eg` Egypt
254
+ `es` El Salvador
255
+ `ek` Equatorial Guinea
256
+ `er` Eritrea
257
+ `en` Estonia
258
+ `et` Ethiopia
259
+ **F**
260
+ `fj` Fiji
261
+ `fi` Finland
262
+ `fr` France
263
+ **G**
264
+ `gb` Gabon
265
+ `ga` The Gambia
266
+ `gg` Georgia
267
+ `gm` Germany
268
+ `gh` Ghana
269
+ `gr` Greece
270
+ `gj` Grenada
271
+ `gt` Guatemala
272
+ `gv` Guinea
273
+ `pu` Guinea-Bissau
274
+ `gy` Guyana
275
+ **H**
276
+ `ha` Haiti
277
+ `ho` Honduras
278
+ `hu` Hungary
279
+ **I**
280
+ `ic` Iceland
281
+ `in` India
282
+ `id` Indonesia
283
+ `ir` Iran
284
+ `iz` Iraq
285
+ `ei` Ireland
286
+ `is` Israel
287
+ `it` Italy
288
+ **J**
289
+ `jm` Jamaica
290
+ `ja` Japan
291
+ `jo` Jordan
292
+ **K**
293
+ `kz` Kazakhstan
294
+ `ke` Kenya
295
+ `kr` Kiribati
296
+ `kn` North Korea
297
+ `ks` South Korea
298
+ `kv` Kosovo
299
+ `ku` Kuwait
300
+ `kg` Kyrgyzstan
301
+ **L**
302
+ `la` Laos
303
+ `lg` Latvia
304
+ `le` Lebanon
305
+ `lt` Lesotho
306
+ `li` Liberia
307
+ `ly` Libya
308
+ `ls` Liechtenstein
309
+ `lh` Lithuania
310
+ `lu` Luxembourg
311
+ **M**
312
+ `mk` Macedonia
313
+ `ma` Madagascar
314
+ `mi` Malawi
315
+ `my` Malaysia
316
+ `mv` Maldives
317
+ `ml` Mali
318
+ `mt` Malta
319
+ `rm` Marshall Islands
320
+ `mr` Mauritania
321
+ `mp` Mauritius
322
+ `mx` Mexico
323
+ `fm` Micronesia
324
+ `md` Moldova
325
+ `mn` Monaco
326
+ `mg` Mongolia
327
+ `mj` Montenegro
328
+ `mo` Morocco
329
+ `mz` Mozambique
330
+ **N**
331
+ `wa` Namibia
332
+ `nr` Nauru
333
+ `np` Nepal
334
+ `nl` Netherlands
335
+ `nz` New Zealand
336
+ `nu` Nicaragua
337
+ `ng` Niger
338
+ `ni` Nigeria
339
+ `no` Norway
340
+ **O**
341
+ `mu` Oman
342
+ **P**
343
+ `pk` Pakistan
344
+ `ps` Palau
345
+ `pm` Panama
346
+ `pp` Papua New Guinea
347
+ `pa` Paraguay
348
+ `pe` Peru
349
+ `rp` Philippines
350
+ `pl` Poland
351
+ `po` Portugal
352
+ **Q**
353
+ `qa` Qatar
354
+ **R**
355
+ `ro` Romania
356
+ `rs` Russia
357
+ `rw` Rwanda
358
+ **S**
359
+ `sc` Saint Kitts and Nevis
360
+ `st` Saint Lucia
361
+ `vc` Saint Vincent and the Grenadines
362
+ `ws` Samoa
363
+ `sm` San Marino
364
+ `tp` Sao Tome and Principe
365
+ `sa` Saudi Arabia
366
+ `sg` Senegal
367
+ `ri` Serbia
368
+ `se` Seychelles
369
+ `sl` Sierra Leone
370
+ `sn` Singapore
371
+ `lo` Slovakia
372
+ `si` Slovenia
373
+ `bp` Solomon Islands
374
+ `so` Somalia
375
+ `sf` South Africa
376
+ `od` South Sudan
377
+ `sp` Spain
378
+ `ce` Sri Lanka
379
+ `su` Sudan
380
+ `ns` Suriname
381
+ `wz` Swaziland
382
+ `sw` Sweden
383
+ `sz` Switzerland
384
+ `sy` Syria
385
+ **T**
386
+ `ti` Tajikistan
387
+ `tz` Tanzania
388
+ `th` Thailand
389
+ `tt` Timor-Leste
390
+ `to` Togo
391
+ `tn` Tonga
392
+ `td` Trinidad and Tobago
393
+ `ts` Tunisia
394
+ `tu` Turkey
395
+ `tx` Turkmenistan
396
+ `tv` Tuvalu
397
+ **U**
398
+ `ug` Uganda
399
+ `up` Ukraine
400
+ `ae` United Arab Emirates
401
+ `uk` United Kingdom
402
+ `us` United States
403
+ `uy` Uruguay
404
+ `uz` Uzbekistan
405
+ **V**
406
+ `nh` Vanuatu
407
+ `vt` Vatican City (Holy See)
408
+ `ve` Venezuela
409
+ `vm` Vietnam
410
+ **Y**
411
+ `ym` Yemen
412
+ **Z**
413
+ `za` Zambia
414
+ `zi` Zimbabwe
415
+
416
+
417
+ ### Other (2)
418
+
419
+ `tw` Taiwan
420
+ `ee` European Union
421
+
422
+ ### Dependencies (58)
423
+
424
+ Australia (6):
425
+ `at` Ashmore and Cartier Islands
426
+ `kt` Christmas Island
427
+ `ck` Cocos (Keeling) Islands
428
+ `cr` Coral Sea Islands
429
+ `hm` Heard Island and McDonald Islands
430
+ `nf` Norfolk Island
431
+
432
+ China (2):
433
+ `hk` Hong Kong
434
+ `mc` Macau
435
+
436
+ Denmark (2):
437
+ `fo` Faroe Islands
438
+ `gl` Greenland
439
+
440
+ France (8):
441
+ `ip` Clipperton Island
442
+ `fp` French Polynesia
443
+ `fs` French Southern and Antarctic Lands
444
+ `nc` New Caledonia
445
+ `tb` Saint Barthelemy
446
+ `rn` Saint Martin
447
+ `sb` Saint Pierre and Miquelon
448
+ `wf` Wallis and Futuna
449
+
450
+ Netherlands (3):
451
+ `aa` Aruba
452
+ `uc` Curacao
453
+ `nn` Sint Maarten
454
+
455
+ New Zealand (3):
456
+ `cw` Cook Islands
457
+ `ne` Niue
458
+ `tl` Tokelau
459
+
460
+ Norway (3):
461
+ `bv` Bouvet Island
462
+ `jn` Jan Mayen
463
+ `sv` Svalbard
464
+
465
+ Great Britain (17):
466
+ `ax` Akrotiri (Sovereign Base)
467
+ `av` Anguilla
468
+ `bd` Bermuda
469
+ `io` British Indian Ocean Territory
470
+ `vi` British Virgin Islands
471
+ `cj` Cayman Islands
472
+ `dx` Dhekelia (Sovereign Base)
473
+ `fk` Falkland Islands
474
+ `gi` Gibraltar
475
+ `gk` Guernsey
476
+ `je` Jersey
477
+ `im` Isle of Man
478
+ `mh` Montserrat
479
+ `pc` Pitcairn Islands
480
+ `sh` Saint Helena
481
+ `sx` South Georgia and the South Sandwich Islands
482
+ `tk` Turks and Caicos Islands
483
+
484
+ United States (14):
485
+ `aq` American Samoa
486
+ `gq` Guam
487
+ `bq` Navassa Island
488
+ `cq` Northern Mariana Islands
489
+ `rq` Puerto Rico
490
+ `vq` US Virgin Islands
491
+ `wq` Wake Island
492
+ `um` US Pacific Island Wildlife Refuges
493
+ (Baker Island, Howland Island, Jarvis Island, Johnston Atoll, Kingman Reef, Midway Islands, Palmyra Atoll)
494
+
495
+
496
+ ### Miscellaneous (6)
497
+
498
+ `ay` Antarctica
499
+ `gz` Gaza Strip
500
+ `pf` Paracel Islands
501
+ `pg` Spratly Islands
502
+ `we` West Bank
503
+ `wi` Western Sahara
504
+
505
+ ### Oceans (5)
506
+
507
+ `xq` Arctic Ocean
508
+ `zh` Atlantic Ocean
509
+ `xo` Indian Ocean
510
+ `zn` Pacific Ocean
511
+ `oo` Southern Ocean
512
+
513
+ ### World (1)
514
+
515
+ `xx` World
516
+
517
+
518
+
519
+
520
+ ## Ready-To-Use Public Domain Factbook Datasets
521
+
522
+ [factbook/factbook.json](https://github.com/factbook/factbook.json) - open (public domain)
523
+ factbook country profiles in JSON for all the world's countries (using internet domain names
524
+ for country codes e.g. Austria is `at.json` not `au.json`, Germany is `de.json` not `gm.json` and so on)
525
+
526
+
527
+ ## Install
528
+
529
+ Use
530
+
531
+ gem install factbook
532
+
533
+ or add to your Gemfile
534
+
535
+ gem 'factbook'
536
+
537
+
538
+
539
+ ## License
540
+
541
+ The `factbook` scripts are dedicated to the public domain.
542
+ Use it as you please with no restrictions whatsoever.
543
+
544
+
545
+ ## Questions? Comments?
546
+
547
+ Send them along to the [Open Mundi (world.db) Database Forum/Mailing List](http://groups.google.com/group/openmundi).
548
+ Thanks!