factbook-codes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 647f0b94f4e8dd97a64d74a7071041f2626832577fbac29d4095ec6ea10f063a
4
+ data.tar.gz: 748f86b88eb922e964cb4b1bdae2797e8162a20f4a236a388312876aa84c5429
5
+ SHA512:
6
+ metadata.gz: 6a616c078ef9ddeffc7bd411b1ab0660c6efcfb2ad7a18472a242862b67074ded0431ede70f9e0d1e02533493f1c2a2d912574c5f1ac6efa91582b0b0911c43b
7
+ data.tar.gz: 3c3b7d498263fe6f0ed74dbe62c54a0117b559200881b1ef4060a276561f7f85a2822c7c6dbb9319a53cc1c83888898416a75dd83f5e43d44bd7422262a4e7e4
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ### 0.1.0 / 2021-03-03
2
+
3
+ * Everything is new. First release.
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ CHANGELOG.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ data/codes.csv
6
+ data/codesxref.csv
7
+ lib/factbook-codes.rb
8
+ lib/factbook-codes/codes.rb
9
+ lib/factbook-codes/version.rb
10
+ lib/factbook/codes.rb
11
+ test/helper.rb
12
+ test/test_codes.rb
data/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # factbook-codes - world factbook country codes (by region, by category, 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-codes](https://rubygems.org/gems/factbook-codes)
6
+ * rdoc :: [rubydoc.info/gems/factbook-codes](http://rubydoc.info/gems/factbook-codes)
7
+ * forum :: [groups.google.com/group/openmundi](https://groups.google.com/group/openmundi)
8
+
9
+
10
+ ## What's the World Factbook?
11
+
12
+ See [factbook/factbook.json »](https://github.com/factbook/factbook.json)
13
+
14
+
15
+
16
+ ## Usage
17
+
18
+ ### List all codes
19
+
20
+ ```ruby
21
+ Factbook.codes.each do |code|
22
+ pp code
23
+ end
24
+ ```
25
+
26
+ resulting in:
27
+
28
+ ```
29
+ #<struct Factbook::Codes::Code
30
+ code ="af",
31
+ name ="Afghanistan",
32
+ category="Countries",
33
+ region ="South Asia">
34
+ #<struct Factbook::Codes::Code
35
+ code ="al",
36
+ name ="Albania",
37
+ category="Countries",
38
+ region ="Europe">
39
+ #<struct Factbook::Codes::Code
40
+ code ="ag",
41
+ name ="Algeria",
42
+ category="Countries",
43
+ region ="Africa">
44
+ #<struct Factbook::Codes::Code
45
+ code ="an",
46
+ name ="Andorra",
47
+ category="Countries",
48
+ region ="Europe">
49
+ ...
50
+ ```
51
+
52
+ Note: You can filter codes by category e.g. Countries, Dependencies, Miscellaneous, Oceans, etc.
53
+ and/or by region e.g. Africa, Europe, South Asia, Central America and Caribbean, etc.
54
+
55
+
56
+ ```ruby
57
+
58
+ assert_equal 261, Factbook.codes.size
59
+
60
+ ## categories
61
+ assert_equal 195, Factbook.codes.countries.size
62
+ assert_equal 52, Factbook.codes.dependencies.size
63
+ assert_equal 5, Factbook.codes.oceans.size
64
+ assert_equal 1, Factbook.codes.world.size
65
+ assert_equal 2, Factbook.codes.others.size
66
+ assert_equal 6, Factbook.codes.misc.size
67
+
68
+ ## regions
69
+ assert_equal 55, Factbook.codes.europe.size
70
+ assert_equal 9, Factbook.codes.south_asia.size
71
+ assert_equal 6, Factbook.codes.central_asia.size
72
+ assert_equal 22, Factbook.codes.east_n_souteast_asia.size
73
+ assert_equal 19, Factbook.codes.middle_east.size
74
+ assert_equal 56, Factbook.codes.africa.size
75
+ assert_equal 7, Factbook.codes.north_america.size
76
+ assert_equal 33, Factbook.codes.central_america_n_caribbean.size
77
+ assert_equal 14, Factbook.codes.south_america.size
78
+ assert_equal 30, Factbook.codes.australia_oceania.size
79
+ assert_equal 4, Factbook.codes.antartica.size
80
+ assert_equal 5, Factbook.codes.region('Oceans').size
81
+ assert_equal 1, Factbook.codes.region('World').size
82
+
83
+ ## categories + regions
84
+ assert_equal 45, Factbook.codes.countries.europe.size
85
+ ...
86
+ ```
87
+
88
+ See [`data/codes.csv`](data/codes.csv) for the built-in listing of all codes with categories and regions.
89
+
90
+
91
+
92
+
93
+ ## Install
94
+
95
+ Use
96
+
97
+ gem install factbook-codes
98
+
99
+ or add to your Gemfile
100
+
101
+ gem 'factbook-codes'
102
+
103
+
104
+
105
+ ## License
106
+
107
+ The `factbook` scripts are dedicated to the public domain.
108
+ Use it as you please with no restrictions whatsoever.
109
+
110
+
111
+ ## Questions? Comments?
112
+
113
+ Send them along to the [Open Mundi (world.db) Database Forum/Mailing List](http://groups.google.com/group/openmundi).
114
+ Thanks!
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ require 'hoe'
2
+ require './lib/factbook-codes/version.rb'
3
+
4
+
5
+ Hoe.spec 'factbook-codes' do
6
+
7
+ self.version = Factbook::Module::Codes::VERSION
8
+
9
+ self.summary = 'factbook-codes - world factbook country codes (by region, by category, etc.)'
10
+ self.description = summary
11
+
12
+ self.urls = { home: 'https://github.com/factbook/factbook' }
13
+
14
+ self.author = 'Gerald Bauer'
15
+ self.email = 'openmundi@googlegroups.com'
16
+
17
+ # switch extension to .markdown for gihub formatting
18
+ self.readme_file = 'README.md'
19
+ self.history_file = 'CHANGELOG.md'
20
+
21
+ self.extra_deps = [
22
+ ['logutils' ],
23
+ ['csvreader'],
24
+ ]
25
+
26
+ self.licenses = ['Public Domain']
27
+
28
+ self.spec_extras = {
29
+ required_ruby_version: '>= 2.2.2'
30
+ }
31
+
32
+ end
data/data/codes.csv ADDED
@@ -0,0 +1,262 @@
1
+ Code,Name,Category,Region
2
+ af,Afghanistan,Countries,South Asia
3
+ al,Albania,Countries,Europe
4
+ ag,Algeria,Countries,Africa
5
+ an,Andorra,Countries,Europe
6
+ ao,Angola,Countries,Africa
7
+ ac,Antigua and Barbuda,Countries,Central America and Caribbean
8
+ ar,Argentina,Countries,South America
9
+ am,Armenia,Countries,Middle East
10
+ as,Australia,Countries,Australia-Oceania
11
+ au,Austria,Countries,Europe
12
+ aj,Azerbaijan,Countries,Middle East
13
+ bf,"Bahamas, The",Countries,Central America and Caribbean
14
+ ba,Bahrain,Countries,Middle East
15
+ bg,Bangladesh,Countries,South Asia
16
+ bb,Barbados,Countries,Central America and Caribbean
17
+ bo,Belarus,Countries,Europe
18
+ be,Belgium,Countries,Europe
19
+ bh,Belize,Countries,Central America and Caribbean
20
+ bn,Benin,Countries,Africa
21
+ bt,Bhutan,Countries,South Asia
22
+ bl,Bolivia,Countries,South America
23
+ bk,Bosnia and Herzegovina,Countries,Europe
24
+ bc,Botswana,Countries,Africa
25
+ br,Brazil,Countries,South America
26
+ bx,Brunei,Countries,East & Southeast Asia
27
+ bu,Bulgaria,Countries,Europe
28
+ uv,Burkina Faso,Countries,Africa
29
+ bm,Burma,Countries,East & Southeast Asia
30
+ by,Burundi,Countries,Africa
31
+ cb,Cambodia,Countries,East & Southeast Asia
32
+ cm,Cameroon,Countries,Africa
33
+ ca,Canada,Countries,North America
34
+ cv,Cabo Verde,Countries,Africa
35
+ ct,Central African Republic,Countries,Africa
36
+ cd,Chad,Countries,Africa
37
+ ci,Chile,Countries,South America
38
+ ch,China,Countries,East & Southeast Asia
39
+ co,Colombia,Countries,South America
40
+ cn,Comoros,Countries,Africa
41
+ cg,"Congo, Democratic Republic of the",Countries,Africa
42
+ cf,"Congo, Republic of the",Countries,Africa
43
+ cs,Costa Rica,Countries,Central America and Caribbean
44
+ iv,Cote d'Ivoire,Countries,Africa
45
+ hr,Croatia,Countries,Europe
46
+ cu,Cuba,Countries,Central America and Caribbean
47
+ cy,Cyprus,Countries,Europe
48
+ ez,Czech Republic,Countries,Europe
49
+ da,Denmark,Countries,Europe
50
+ dj,Djibouti,Countries,Africa
51
+ do,Dominica,Countries,Central America and Caribbean
52
+ dr,Dominican Republic,Countries,Central America and Caribbean
53
+ ec,Ecuador,Countries,South America
54
+ eg,Egypt,Countries,Africa
55
+ es,El Salvador,Countries,Central America and Caribbean
56
+ ek,Equatorial Guinea,Countries,Africa
57
+ er,Eritrea,Countries,Africa
58
+ en,Estonia,Countries,Europe
59
+ et,Ethiopia,Countries,Africa
60
+ fj,Fiji,Countries,Australia-Oceania
61
+ fi,Finland,Countries,Europe
62
+ fr,France,Countries,Europe
63
+ gb,Gabon,Countries,Africa
64
+ ga,"Gambia, The",Countries,Africa
65
+ gg,Georgia,Countries,Middle East
66
+ gm,Germany,Countries,Europe
67
+ gh,Ghana,Countries,Africa
68
+ gr,Greece,Countries,Europe
69
+ gj,Grenada,Countries,Central America and Caribbean
70
+ gt,Guatemala,Countries,Central America and Caribbean
71
+ gv,Guinea,Countries,Africa
72
+ pu,Guinea-Bissau,Countries,Africa
73
+ gy,Guyana,Countries,South America
74
+ ha,Haiti,Countries,Central America and Caribbean
75
+ ho,Honduras,Countries,Central America and Caribbean
76
+ hu,Hungary,Countries,Europe
77
+ ic,Iceland,Countries,Europe
78
+ in,India,Countries,South Asia
79
+ id,Indonesia,Countries,East & Southeast Asia
80
+ ir,Iran,Countries,Middle East
81
+ iz,Iraq,Countries,Middle East
82
+ ei,Ireland,Countries,Europe
83
+ is,Israel,Countries,Middle East
84
+ it,Italy,Countries,Europe
85
+ jm,Jamaica,Countries,Central America and Caribbean
86
+ ja,Japan,Countries,East & Southeast Asia
87
+ jo,Jordan,Countries,Middle East
88
+ kz,Kazakhstan,Countries,Central Asia
89
+ ke,Kenya,Countries,Africa
90
+ kr,Kiribati,Countries,Australia-Oceania
91
+ kn,"Korea, North",Countries,East & Southeast Asia
92
+ ks,"Korea, South",Countries,East & Southeast Asia
93
+ kv,Kosovo,Countries,Europe
94
+ ku,Kuwait,Countries,Middle East
95
+ kg,Kyrgyzstan,Countries,Central Asia
96
+ la,Laos,Countries,East & Southeast Asia
97
+ lg,Latvia,Countries,Europe
98
+ le,Lebanon,Countries,Middle East
99
+ lt,Lesotho,Countries,Africa
100
+ li,Liberia,Countries,Africa
101
+ ly,Libya,Countries,Africa
102
+ ls,Liechtenstein,Countries,Europe
103
+ lh,Lithuania,Countries,Europe
104
+ lu,Luxembourg,Countries,Europe
105
+ mk,Macedonia,Countries,Europe
106
+ ma,Madagascar,Countries,Africa
107
+ mi,Malawi,Countries,Africa
108
+ my,Malaysia,Countries,East & Southeast Asia
109
+ mv,Maldives,Countries,South Asia
110
+ ml,Mali,Countries,Africa
111
+ mt,Malta,Countries,Europe
112
+ rm,Marshall Islands,Countries,Australia-Oceania
113
+ mr,Mauritania,Countries,Africa
114
+ mp,Mauritius,Countries,Africa
115
+ mx,Mexico,Countries,North America
116
+ fm,"Micronesia, Federated States of",Countries,Australia-Oceania
117
+ md,Moldova,Countries,Europe
118
+ mn,Monaco,Countries,Europe
119
+ mg,Mongolia,Countries,East & Southeast Asia
120
+ mj,Montenegro,Countries,Europe
121
+ mo,Morocco,Countries,Africa
122
+ mz,Mozambique,Countries,Africa
123
+ wa,Namibia,Countries,Africa
124
+ nr,Nauru,Countries,Australia-Oceania
125
+ np,Nepal,Countries,South Asia
126
+ nl,Netherlands,Countries,Europe
127
+ nz,New Zealand,Countries,Australia-Oceania
128
+ nu,Nicaragua,Countries,Central America and Caribbean
129
+ ng,Niger,Countries,Africa
130
+ ni,Nigeria,Countries,Africa
131
+ no,Norway,Countries,Europe
132
+ mu,Oman,Countries,Middle East
133
+ pk,Pakistan,Countries,South Asia
134
+ ps,Palau,Countries,Australia-Oceania
135
+ pm,Panama,Countries,Central America and Caribbean
136
+ pp,Papua New Guinea,Countries,East & Southeast Asia
137
+ pa,Paraguay,Countries,South America
138
+ pe,Peru,Countries,South America
139
+ rp,Philippines,Countries,East & Southeast Asia
140
+ pl,Poland,Countries,Europe
141
+ po,Portugal,Countries,Europe
142
+ qa,Qatar,Countries,Middle East
143
+ ro,Romania,Countries,Europe
144
+ rs,Russia,Countries,Central Asia
145
+ rw,Rwanda,Countries,Africa
146
+ sc,Saint Kitts and Nevis,Countries,Central America and Caribbean
147
+ st,Saint Lucia,Countries,Central America and Caribbean
148
+ vc,Saint Vincent and the Grenadines,Countries,Central America and Caribbean
149
+ ws,Samoa,Countries,Australia-Oceania
150
+ sm,San Marino,Countries,Europe
151
+ tp,Sao Tome and Principe,Countries,Africa
152
+ sa,Saudi Arabia,Countries,Middle East
153
+ sg,Senegal,Countries,Africa
154
+ ri,Serbia,Countries,Europe
155
+ se,Seychelles,Countries,Africa
156
+ sl,Sierra Leone,Countries,Africa
157
+ sn,Singapore,Countries,East & Southeast Asia
158
+ lo,Slovakia,Countries,Europe
159
+ si,Slovenia,Countries,Europe
160
+ bp,Solomon Islands,Countries,Australia-Oceania
161
+ so,Somalia,Countries,Africa
162
+ sf,South Africa,Countries,Africa
163
+ od,South Sudan,Countries,Africa
164
+ sp,Spain,Countries,Europe
165
+ ce,Sri Lanka,Countries,South Asia
166
+ su,Sudan,Countries,Africa
167
+ ns,Suriname,Countries,South America
168
+ wz,Swaziland,Countries,Africa
169
+ sw,Sweden,Countries,Europe
170
+ sz,Switzerland,Countries,Europe
171
+ sy,Syria,Countries,Middle East
172
+ ti,Tajikistan,Countries,Central Asia
173
+ tz,Tanzania,Countries,Africa
174
+ th,Thailand,Countries,East & Southeast Asia
175
+ tt,Timor-Leste,Countries,East & Southeast Asia
176
+ to,Togo,Countries,Africa
177
+ tn,Tonga,Countries,Australia-Oceania
178
+ td,Trinidad and Tobago,Countries,Central America and Caribbean
179
+ ts,Tunisia,Countries,Africa
180
+ tu,Turkey,Countries,Middle East
181
+ tx,Turkmenistan,Countries,Central Asia
182
+ tv,Tuvalu,Countries,Australia-Oceania
183
+ ug,Uganda,Countries,Africa
184
+ up,Ukraine,Countries,Europe
185
+ ae,United Arab Emirates,Countries,Middle East
186
+ uk,United Kingdom,Countries,Europe
187
+ us,United States,Countries,North America
188
+ uy,Uruguay,Countries,South America
189
+ uz,Uzbekistan,Countries,Central Asia
190
+ nh,Vanuatu,Countries,Australia-Oceania
191
+ vt,Holy See (Vatican City),Countries,Europe
192
+ ve,Venezuela,Countries,South America
193
+ vm,Vietnam,Countries,East & Southeast Asia
194
+ ym,Yemen,Countries,Middle East
195
+ za,Zambia,Countries,Africa
196
+ zi,Zimbabwe,Countries,Africa
197
+ tw,Taiwan,Other,East & Southeast Asia
198
+ ee,European Union,Other,Europe
199
+ at,Ashmore and Cartier Islands,Dependencies (Australia),Australia-Oceania
200
+ kt,Christmas Island,Dependencies (Australia),Australia-Oceania
201
+ ck,Cocos (Keeling) Islands,Dependencies (Australia),Australia-Oceania
202
+ cr,Coral Sea Islands,Dependencies (Australia),Australia-Oceania
203
+ hm,Heard Island and McDonald Islands,Dependencies (Australia),Antarctica
204
+ nf,Norfolk Island,Dependencies (Australia),Australia-Oceania
205
+ hk,Hong Kong,Dependencies (China),East & Southeast Asia
206
+ mc,Macau,Dependencies (China),East & Southeast Asia
207
+ fo,Faroe Islands,Dependencies (Denmark),Europe
208
+ gl,Greenland,Dependencies (Denmark),North America
209
+ ip,Clipperton Island,Dependencies (France),North America
210
+ fp,French Polynesia,Dependencies (France),Australia-Oceania
211
+ fs,French Southern and Antarctic Lands,Dependencies (France),Antarctica
212
+ nc,New Caledonia,Dependencies (France),Australia-Oceania
213
+ tb,Saint Barthelemy,Dependencies (France),Central America and Caribbean
214
+ rn,Saint Martin,Dependencies (France),Central America and Caribbean
215
+ sb,Saint Pierre and Miquelon,Dependencies (France),North America
216
+ wf,Wallis and Futuna,Dependencies (France),Australia-Oceania
217
+ aa,Aruba,Dependencies (Netherlands),Central America and Caribbean
218
+ uc,Curacao,Dependencies (Netherlands),Central America and Caribbean
219
+ nn,Sint Maarten,Dependencies (Netherlands),Central America and Caribbean
220
+ cw,Cook Islands,Dependencies (New Zealand),Australia-Oceania
221
+ ne,Niue,Dependencies (New Zealand),Australia-Oceania
222
+ tl,Tokelau,Dependencies (New Zealand),Australia-Oceania
223
+ bv,Bouvet Island,Dependencies (Norway),Antarctica
224
+ jn,Jan Mayen,Dependencies (Norway),Europe
225
+ sv,Svalbard,Dependencies (Norway),Europe
226
+ ax,Akrotiri,Dependencies (Great Britain),Europe
227
+ av,Anguilla,Dependencies (Great Britain),Central America and Caribbean
228
+ bd,Bermuda,Dependencies (Great Britain),North America
229
+ io,British Indian Ocean Territory,Dependencies (Great Britain),South Asia
230
+ vi,British Virgin Islands,Dependencies (Great Britain),Central America and Caribbean
231
+ cj,Cayman Islands,Dependencies (Great Britain),Central America and Caribbean
232
+ dx,Dhekelia,Dependencies (Great Britain),Europe
233
+ fk,Falkland Islands (Islas Malvinas),Dependencies (Great Britain),South America
234
+ gi,Gibraltar,Dependencies (Great Britain),Europe
235
+ gk,Guernsey,Dependencies (Great Britain),Europe
236
+ je,Jersey,Dependencies (Great Britain),Europe
237
+ im,Isle of Man,Dependencies (Great Britain),Europe
238
+ mh,Montserrat,Dependencies (Great Britain),Central America and Caribbean
239
+ pc,Pitcairn Islands,Dependencies (Great Britain),Australia-Oceania
240
+ sh,"Saint Helena, Ascension, and Tristan da Cunha",Dependencies (Great Britain),Africa
241
+ sx,South Georgia and South Sandwich Islands,Dependencies (Great Britain),South America
242
+ tk,Turks and Caicos Islands,Dependencies (Great Britain),Central America and Caribbean
243
+ aq,American Samoa,Dependencies (United States),Australia-Oceania
244
+ gq,Guam,Dependencies (United States),Australia-Oceania
245
+ bq,Navassa Island,Dependencies (United States),Central America and Caribbean
246
+ cq,Northern Mariana Islands,Dependencies (United States),Australia-Oceania
247
+ rq,Puerto Rico,Dependencies (United States),Central America and Caribbean
248
+ vq,Virgin Islands,Dependencies (United States),Central America and Caribbean
249
+ wq,Wake Island,Dependencies (United States),Australia-Oceania
250
+ um,United States Pacific Island Wildlife Refuges,Dependencies (United States),Australia-Oceania
251
+ ay,Antarctica,Miscellaneous,Antarctica
252
+ gz,Gaza Strip,Miscellaneous,Middle East
253
+ pf,Paracel Islands,Miscellaneous,East & Southeast Asia
254
+ pg,Spratly Islands,Miscellaneous,East & Southeast Asia
255
+ we,West Bank,Miscellaneous,Middle East
256
+ wi,Western Sahara,Miscellaneous,Africa
257
+ xq,Arctic Ocean,Oceans,Oceans
258
+ zh,Atlantic Ocean,Oceans,Oceans
259
+ xo,Indian Ocean,Oceans,Oceans
260
+ zn,Pacific Ocean,Oceans,Oceans
261
+ oo,Southern Ocean,Oceans,Oceans
262
+ xx,World,World,World
@@ -0,0 +1,280 @@
1
+ Name,GEC,A3,A2,NUM,STANAG,INTERNET
2
+ Afghanistan,AF,AF,AFG,004,AFG,.af
3
+ Akrotiri,AX,-,-,-,-,-
4
+ Albania,AL,AL,ALB,008,ALB,.al
5
+ Algeria,AG,DZ,DZA,012,DZA,.dz
6
+ American Samoa,AQ,AS,ASM,016,ASM,.as
7
+ Andorra,AN,AD,AND,020,AND,.ad
8
+ Angola,AO,AO,AGO,024,AGO,.ao
9
+ Anguilla,AV,AI,AIA,660,AIA,.ai
10
+ Antarctica,AY,AQ,ATA,010,ATA,.aq
11
+ Antigua and Barbuda,AC,AG,ATG,028,ATG,.ag
12
+ Argentina,AR,AR,ARG,032,ARG,.ar
13
+ Armenia,AM,AM,ARM,051,ARM,.am
14
+ Aruba,AA,AW,ABW,533,ABW,.aw
15
+ Ashmore and Cartier Islands,AT,-,-,-,AUS,-
16
+ Australia,AS,AU,AUS,036,AUS,.au
17
+ Austria,AU,AT,AUT,040,AUT,.at
18
+ Azerbaijan,AJ,AZ,AZE,031,AZE,.az
19
+ "Bahamas, The",BF,BS,BHS,044,BHS,.bs
20
+ Bahrain,BA,BH,BHR,048,BHR,.bh
21
+ Baker Island,FQ,-,-,-,UMI,-
22
+ Bangladesh,BG,BD,BGD,050,BGD,.bd
23
+ Barbados,BB,BB,BRB,052,BRB,.bb
24
+ Bassas da India,BS,-,-,-,-,-
25
+ Belarus,BO,BY,BLR,112,BLR,.by
26
+ Belgium,BE,BE,BEL,056,BEL,.be
27
+ Belize,BH,BZ,BLZ,084,BLZ,.bz
28
+ Benin,BN,BJ,BEN,204,BEN,.bj
29
+ Bermuda,BD,BM,BMU,060,BMU,.bm
30
+ Bhutan,BT,BT,BTN,064,BTN,.bt
31
+ Bolivia,BL,BO,BOL,068,BOL,.bo
32
+ Bosnia and Herzegovina,BK,BA,BIH,070,BIH,.ba
33
+ Botswana,BC,BW,BWA,072,BWA,.bw
34
+ Bouvet Island,BV,BV,BVT,074,BVT,.bv
35
+ Brazil,BR,BR,BRA,076,BRA,.br
36
+ British Indian Ocean Territory,IO,IO,IOT,086,IOT,.io
37
+ British Virgin Islands,VI,VG,VGB,092,VGB,.vg
38
+ Brunei,BX,BN,BRN,096,BRN,.bn
39
+ Bulgaria,BU,BG,BGR,100,BGR,.bg
40
+ Burkina Faso,UV,BF,BFA,854,BFA,.bf
41
+ Burma,BM,MM,MMR,104,MMR,.mm
42
+ Burundi,BY,BI,BDI,108,BDI,.bi
43
+ Cabo Verde,CV,CV,CPV,132,CPV,.cv
44
+ Cambodia,CB,KH,KHM,116,KHM,.kh
45
+ Cameroon,CM,CM,CMR,120,CMR,.cm
46
+ Canada,CA,CA,CAN,124,CAN,.ca
47
+ Cayman Islands,CJ,KY,CYM,136,CYM,.ky
48
+ Central African Republic,CT,CF,CAF,140,CAF,.cf
49
+ Chad,CD,TD,TCD,148,TCD,.td
50
+ Chile,CI,CL,CHL,152,CHL,.cl
51
+ China,CH,CN,CHN,156,CHN,.cn
52
+ Christmas Island,KT,CX,CXR,162,CXR,.cx
53
+ Clipperton Island,IP,-,-,-,FYP,-
54
+ Cocos (Keeling) Islands,CK,CC,CCK,166,AUS,.cc
55
+ Colombia,CO,CO,COL,170,COL,.co
56
+ Comoros,CN,KM,COM,174,COM,.km
57
+ "Congo, Democratic Republic of the",CG,CD,COD,180,COD,.cd
58
+ "Congo, Republic of the",CF,CG,COG,178,COG,.cg
59
+ Cook Islands,CW,CK,COK,184,COK,.ck
60
+ Coral Sea Islands,CR,-,-,-,AUS,-
61
+ Costa Rica,CS,CR,CRI,188,CRI,.cr
62
+ Cote d'Ivoire,IV,CI,CIV,384,CIV,.ci
63
+ Croatia,HR,HR,HRV,191,HRV,.hr
64
+ Cuba,CU,CU,CUB,192,CUB,.cu
65
+ Curacao,UC,CW,CUW,531,-,.cw
66
+ Cyprus,CY,CY,CYP,196,CYP,.cy
67
+ Czech Republic,EZ,CZ,CZE,203,CZE,.cz
68
+ Denmark,DA,DK,DNK,208,DNK,.dk
69
+ Dhekelia,DX,-,-,-,-,-
70
+ Djibouti,DJ,DJ,DJI,262,DJI,.dj
71
+ Dominica,DO,DM,DMA,212,DMA,.dm
72
+ Dominican Republic,DR,DO,DOM,214,DOM,.do
73
+ Ecuador,EC,EC,ECU,218,ECU,.ec
74
+ Egypt,EG,EG,EGY,818,EGY,.eg
75
+ El Salvador,ES,SV,SLV,222,SLV,.sv
76
+ Equatorial Guinea,EK,GQ,GNQ,226,GNQ,.gq
77
+ Eritrea,ER,ER,ERI,232,ERI,.er
78
+ Estonia,EN,EE,EST,233,EST,.ee
79
+ Ethiopia,ET,ET,ETH,231,ETH,.et
80
+ Europa Island,EU,-,-,-,-,-
81
+ Falkland Islands (Islas Malvinas),FK,FK,FLK,238,FLK,.fk
82
+ Faroe Islands,FO,FO,FRO,234,FRO,.fo
83
+ Fiji,FJ,FJ,FJI,242,FJI,.fj
84
+ Finland,FI,FI,FIN,246,FIN,.fi
85
+ France,FR,FR,FRA,250,FRA,.fr
86
+ "France, Metropolitan",-,FX,FXX,249,-,.fx
87
+ French Guiana,FG,GF,GUF,254,GUF,.gf
88
+ French Polynesia,FP,PF,PYF,258,PYF,.pf
89
+ French Southern and Antarctic Lands,FS,TF,ATF,260,ATF,.tf
90
+ Gabon,GB,GA,GAB,266,GAB,.ga
91
+ "Gambia, The",GA,GM,GMB,270,GMB,.gm
92
+ Gaza Strip,GZ,PS,PSE,275,PSE,.ps
93
+ Georgia,GG,GE,GEO,268,GEO,.ge
94
+ Germany,GM,DE,DEU,276,DEU,.de
95
+ Ghana,GH,GH,GHA,288,GHA,.gh
96
+ Gibraltar,GI,GI,GIB,292,GIB,.gi
97
+ Glorioso Islands,GO,-,-,-,-,-
98
+ Greece,GR,GR,GRC,300,GRC,.gr
99
+ Greenland,GL,GL,GRL,304,GRL,.gl
100
+ Grenada,GJ,GD,GRD,308,GRD,.gd
101
+ Guadeloupe,GP,GP,GLP,312,GLP,.gp
102
+ Guam,GQ,GU,GUM,316,GUM,.gu
103
+ Guatemala,GT,GT,GTM,320,GTM,.gt
104
+ Guernsey,GK,GG,GGY,831,UK,.gg
105
+ Guinea,GV,GN,GIN,324,GIN,.gn
106
+ Guinea-Bissau,PU,GW,GNB,624,GNB,.gw
107
+ Guyana,GY,GY,GUY,328,GUY,.gy
108
+ Haiti,HA,HT,HTI,332,HTI,.ht
109
+ Heard Island and McDonald Islands,HM,HM,HMD,334,HMD,.hm
110
+ Holy See (Vatican City),VT,VA,VAT,336,VAT,.va
111
+ Honduras,HO,HN,HND,340,HND,.hn
112
+ Hong Kong,HK,HK,HKG,344,HKG,.hk
113
+ Howland Island,HQ,-,-,-,UMI,-
114
+ Hungary,HU,HU,HUN,348,HUN,.hu
115
+ Iceland,IC,IS,ISL,352,ISL,.is
116
+ India,IN,IN,IND,356,IND,.in
117
+ Indonesia,ID,ID,IDN,360,IDN,.id
118
+ Iran,IR,IR,IRN,364,IRN,.ir
119
+ Iraq,IZ,IQ,IRQ,368,IRQ,.iq
120
+ Ireland,EI,IE,IRL,372,IRL,.ie
121
+ Isle of Man,IM,IM,IMN,833,UK,.im
122
+ Israel,IS,IL,ISR,376,ISR,.il
123
+ Italy,IT,IT,ITA,380,ITA,.it
124
+ Jamaica,JM,JM,JAM,388,JAM,.jm
125
+ Jan Mayen,JN,-,-,-,SJM,-
126
+ Japan,JA,JP,JPN,392,JPN,.jp
127
+ Jarvis Island,DQ,-,-,-,UMI,-
128
+ Jersey,JE,JE,JEY,832,UK,.je
129
+ Johnston Atoll,JQ,-,-,-,UMI,-
130
+ Jordan,JO,JO,JOR,400,JOR,.jo
131
+ Juan de Nova Island,JU,-,-,-,-,-
132
+ Kazakhstan,KZ,KZ,KAZ,398,KAZ,.kz
133
+ Kenya,KE,KE,KEN,404,KEN,.ke
134
+ Kingman Reef,KQ,-,-,-,UMI,-
135
+ Kiribati,KR,KI,KIR,296,KIR,.ki
136
+ "Korea, North",KN,KP,PRK,408,PRK,.kp
137
+ "Korea, South",KS,KR,KOR,410,KOR,.kr
138
+ Kosovo,KV,XK,XKS,-,-,-
139
+ Kuwait,KU,KW,KWT,414,KWT,.kw
140
+ Kyrgyzstan,KG,KG,KGZ,417,KGZ,.kg
141
+ Laos,LA,LA,LAO,418,LAO,.la
142
+ Latvia,LG,LV,LVA,428,LVA,.lv
143
+ Lebanon,LE,LB,LBN,422,LBN,.lb
144
+ Lesotho,LT,LS,LSO,426,LSO,.ls
145
+ Liberia,LI,LR,LBR,430,LBR,.lr
146
+ Libya,LY,LY,LBY,434,LBY,.ly
147
+ Liechtenstein,LS,LI,LIE,438,LIE,.li
148
+ Lithuania,LH,LT,LTU,440,LTU,.lt
149
+ Luxembourg,LU,LU,LUX,442,LUX,.lu
150
+ Macau,MC,MO,MAC,446,MAC,.mo
151
+ Macedonia,MK,MK,MKD,807,FYR,.mk
152
+ Madagascar,MA,MG,MDG,450,MDG,.mg
153
+ Malawi,MI,MW,MWI,454,MWI,.mw
154
+ Malaysia,MY,MY,MYS,458,MYS,.my
155
+ Maldives,MV,MV,MDV,462,MDV,.mv
156
+ Mali,ML,ML,MLI,466,MLI,.ml
157
+ Malta,MT,MT,MLT,470,MLT,.mt
158
+ Marshall Islands,RM,MH,MHL,584,MHL,.mh
159
+ Martinique,MB,MQ,MTQ,474,MTQ,.mq
160
+ Mauritania,MR,MR,MRT,478,MRT,.mr
161
+ Mauritius,MP,MU,MUS,480,MUS,.mu
162
+ Mayotte,MF,YT,MYT,175,FRA,.yt
163
+ Mexico,MX,MX,MEX,484,MEX,.mx
164
+ "Micronesia, Federated States of",FM,FM,FSM,583,FSM,.fm
165
+ Midway Islands,MQ,-,-,-,UMI,-
166
+ Moldova,MD,MD,MDA,498,MDA,.md
167
+ Monaco,MN,MC,MCO,492,MCO,.mc
168
+ Mongolia,MG,MN,MNG,496,MNG,.mn
169
+ Montenegro,MJ,ME,MNE,499,MNE,.me
170
+ Montserrat,MH,MS,MSR,500,MSR,.ms
171
+ Morocco,MO,MA,MAR,504,MAR,.ma
172
+ Mozambique,MZ,MZ,MOZ,508,MOZ,.mz
173
+ Myanmar,-,-,-,-,-,-
174
+ Namibia,WA,NA,NAM,516,NAM,.na
175
+ Nauru,NR,NR,NRU,520,NRU,.nr
176
+ Navassa Island,BQ,-,-,-,UMI,-
177
+ Nepal,NP,NP,NPL,524,NPL,.np
178
+ Netherlands,NL,NL,NLD,528,NLD,.nl
179
+ Netherlands Antilles,NT, , , ,ANT,.an
180
+ New Caledonia,NC,NC,NCL,540,NCL,.nc
181
+ New Zealand,NZ,NZ,NZL,554,NZL,.nz
182
+ Nicaragua,NU,NI,NIC,558,NIC,.ni
183
+ Niger,NG,NE,NER,562,NER,.ne
184
+ Nigeria,NI,NG,NGA,566,NGA,.ng
185
+ Niue,NE,NU,NIU,570,NIU,.nu
186
+ Norfolk Island,NF,NF,NFK,574,NFK,.nf
187
+ Northern Mariana Islands,CQ,MP,MNP,580,MNP,.mp
188
+ Norway,NO,NO,NOR,578,NOR,.no
189
+ Oman,MU,OM,OMN,512,OMN,.om
190
+ Pakistan,PK,PK,PAK,586,PAK,.pk
191
+ Palau,PS,PW,PLW,585,PLW,.pw
192
+ Palmyra Atoll,LQ,-,-,-,UMI,-
193
+ Panama,PM,PA,PAN,591,PAN,.pa
194
+ Papua New Guinea,PP,PG,PNG,598,PNG,.pg
195
+ Paracel Islands,PF,-,-,-,-,-
196
+ Paraguay,PA,PY,PRY,600,PRY,.py
197
+ Peru,PE,PE,PER,604,PER,.pe
198
+ Philippines,RP,PH,PHL,608,PHL,.ph
199
+ Pitcairn Islands,PC,PN,PCN,612,PCN,.pn
200
+ Poland,PL,PL,POL,616,POL,.pl
201
+ Portugal,PO,PT,PRT,620,PRT,.pt
202
+ Puerto Rico,RQ,PR,PRI,630,PRI,.pr
203
+ Qatar,QA,QA,QAT,634,QAT,.qa
204
+ Reunion,RE,RE,REU,638,REU,.re
205
+ Romania,RO,RO,ROU,642,ROU,.ro
206
+ Russia,RS,RU,RUS,643,RUS,.ru
207
+ Rwanda,RW,RW,RWA,646,RWA,.rw
208
+ Saint Barthelemy,TB,BL,BLM,652,-,.bl
209
+ "Saint Helena, Ascension, and Tristan da Cunha",SH,SH,SHN,654,SHN,.sh
210
+ Saint Kitts and Nevis,SC,KN,KNA,659,KNA,.kn
211
+ Saint Lucia,ST,LC,LCA,662,LCA,.lc
212
+ Saint Martin,RN,MF,MAF,663,-,.mf
213
+ Saint Pierre and Miquelon,SB,PM,SPM,666,SPM,.pm
214
+ Saint Vincent and the Grenadines,VC,VC,VCT,670,VCT,.vc
215
+ Samoa,WS,WS,WSM,882,WSM,.ws
216
+ San Marino,SM,SM,SMR,674,SMR,.sm
217
+ Sao Tome and Principe,TP,ST,STP,678,STP,.st
218
+ Saudi Arabia,SA,SA,SAU,682,SAU,.sa
219
+ Senegal,SG,SN,SEN,686,SEN,.sn
220
+ Serbia,RI,RS,SRB,688,-,.rs
221
+ Seychelles,SE,SC,SYC,690,SYC,.sc
222
+ Sierra Leone,SL,SL,SLE,694,SLE,.sl
223
+ Singapore,SN,SG,SGP,702,SGP,.sg
224
+ Sint Maarten,NN,SX,SXM,534,-,.sx
225
+ Slovakia,LO,SK,SVK,703,SVK,.sk
226
+ Slovenia,SI,SI,SVN,705,SVN,.si
227
+ Solomon Islands,BP,SB,SLB,090,SLB,.sb
228
+ Somalia,SO,SO,SOM,706,SOM,.so
229
+ South Africa,SF,ZA,ZAF,710,ZAF,.za
230
+ South Georgia and the Islands,SX,GS,SGS,239,SGS,.gs
231
+ South Sudan,OD,SS,SSD,728,-,-
232
+ Spain,SP,ES,ESP,724,ESP,.es
233
+ Spratly Islands,PG,-,-,-,-,-
234
+ Sri Lanka,CE,LK,LKA,144,LKA,.lk
235
+ Sudan,SU,SD,SDN,729,SDN,.sd
236
+ Suriname,NS,SR,SUR,740,SUR,.sr
237
+ Svalbard,SV,SJ,SJM,744,SJM,.sj
238
+ Swaziland,WZ,SZ,SWZ,748,SWZ,.sz
239
+ Sweden,SW,SE,SWE,752,SWE,.se
240
+ Switzerland,SZ,CH,CHE,756,CHE,.ch
241
+ Syria,SY,SY,SYR,760,SYR,.sy
242
+ Taiwan,TW,TW,TWN,158,TWN,.tw
243
+ Tajikistan,TI,TJ,TJK,762,TJK,.tj
244
+ Tanzania,TZ,TZ,TZA,834,TZA,.tz
245
+ Thailand,TH,TH,THA,764,THA,.th
246
+ Timor-Leste,TT,TL,TLS,626,TLS,.tl
247
+ Togo,TO,TG,TGO,768,TGO,.tg
248
+ Tokelau,TL,TK,TKL,772,TKL,.tk
249
+ Tonga,TN,TO,TON,776,TON,.to
250
+ Trinidad and Tobago,TD,TT,TTO,780,TTO,.tt
251
+ Tromelin Island,TE,-,-,-,-,-
252
+ Tunisia,TS,TN,TUN,788,TUN,.tn
253
+ Turkey,TU,TR,TUR,792,TUR,.tr
254
+ Turkmenistan,TX,TM,TKM,795,TKM,.tm
255
+ Turks and Caicos Islands,TK,TC,TCA,796,TCA,.tc
256
+ Tuvalu,TV,TV,TUV,798,TUV,.tv
257
+ Uganda,UG,UG,UGA,800,UGA,.ug
258
+ Ukraine,UP,UA,UKR,804,UKR,.ua
259
+ United Arab Emirates,AE,AE,ARE,784,ARE,.ae
260
+ United Kingdom,UK,GB,GBR,826,GBR,.uk
261
+ United States,US,US,USA,840,USA,.us
262
+ United States Minor Outlying Islands,-,UM,UMI,581,-,.um
263
+ Uruguay,UY,UY,URY,858,URY,.uy
264
+ Uzbekistan,UZ,UZ,UZB,860,UZB,.uz
265
+ Vanuatu,NH,VU,VUT,548,VUT,.vu
266
+ Venezuela,VE,VE,VEN,862,VEN,.ve
267
+ Vietnam,VM,VN,VNM,704,VNM,.vn
268
+ Virgin Islands,VQ,VI,VIR,850,VIR,.vi
269
+ Virgin Islands (UK),-,-,-,-,-,.vg
270
+ Virgin Islands (US),-,-,-,-,-,.vi
271
+ Wake Island,WQ,-,-,-,UMI,-
272
+ Wallis and Futuna,WF,WF,WLF,876,WLF,.wf
273
+ West Bank,WE,PS,PSE,275,PSE,.ps
274
+ Western Sahara,WI,EH,ESH,732,ESH,.eh
275
+ Western Samoa,-,-,-,-,-,.ws
276
+ World,-,-,-,-,-,-
277
+ Yemen,YM,YE,YEM,887,YEM,.ye
278
+ Zaire,-,-,-,-,-,-
279
+ Zambia,ZA,ZM,ZMB,894,ZMB,.zm
280
+ Zimbabwe,ZI,ZW,ZWE,716,ZWE,.zw
@@ -0,0 +1,25 @@
1
+ ## 3rd party gems/libs
2
+ ## require 'props'
3
+
4
+ require 'logutils'
5
+ require 'csvreader'
6
+
7
+
8
+
9
+ # our own code
10
+ require 'factbook-codes/version' # let it always go first
11
+
12
+ require 'factbook-codes/codes'
13
+
14
+
15
+ ## note: make codes available
16
+ module Factbook
17
+ ## note: load on demand only builtin codes, comparisons, etc.
18
+ ## for now
19
+ def self.codes
20
+ @@codes ||= Codes.read_csv( "#{Factbook::Module::Codes.root}/data/codes.csv" );
21
+ end
22
+ end # module Factbook
23
+
24
+
25
+ puts Factbook::Module::Codes.banner
@@ -0,0 +1,121 @@
1
+ ##
2
+ # note:
3
+ # the factbook category/region for world is other entities (on FAQ) and oceans in page
4
+ # changed to world
5
+
6
+
7
+ module Factbook
8
+
9
+ class Codes
10
+
11
+ Code = Struct.new( :code, ## todo: add notes (country affiliation) - why? why not??
12
+ :name,
13
+ :category, ## e.g. Countries, Other, Oceans, World, Dependencies, etc.
14
+ :region, ## e.g. Europe, Oceans, etc.
15
+ )
16
+
17
+ def self.read_csv( path )
18
+ ###
19
+ # note:
20
+ # if you use quotes - NO leading spaces allowed e.g.
21
+ # use au,"Austria",... and NOT
22
+ # au, "Austria", ...
23
+ #
24
+ # for headers - NO leading spaces allowed e.g.
25
+ # use Code,Name,Category,Region,... and NOT
26
+ # Code, Name, Category, Region, ...
27
+
28
+ rows = CsvHash.read( path )
29
+
30
+ pp rows
31
+
32
+ recs = []
33
+ rows.each do |row|
34
+ pp row
35
+ rec = Code.new
36
+ rec.code = row['Code'].strip ## remove leading n trailing whitespaces
37
+ rec.name = row['Name'].strip
38
+
39
+ ## note: for now category and region are optional
40
+ rec.category = row['Category'].strip if row['Category'] && row['Category'].size > 0
41
+ rec.region = row['Region'].strip if row['Region'] && row['Region'].size > 0
42
+
43
+ pp rec
44
+ recs << rec
45
+ end
46
+
47
+ new( recs )
48
+ end
49
+
50
+
51
+ def initialize( codes )
52
+ @codes = codes
53
+ end
54
+
55
+ def size() @codes.size; end
56
+
57
+ def each( &blk ) @codes.each( &blk ); end
58
+ def select( &blk )
59
+ codes = @codes.select( &blk )
60
+ Codes.new( codes ) ## return (again) new Codes obj for easy-chaining - why? why not?
61
+ end
62
+
63
+
64
+ def to_a
65
+ @codes.collect {|code| code.code } ## return array of codes
66
+ end
67
+
68
+ ## def all() self.to_a; end ## note: alias for to_a - use - why? why not??
69
+
70
+ ## "pre-defined" convenience shortcuts
71
+ def countries() category 'Countries'; end
72
+ def world() category 'World'; end
73
+ def oceans() category 'Oceans'; end
74
+ def misc() category 'Miscellaneous'; end
75
+ def others() category 'Other'; end
76
+ def dependencies() category 'Dependencies'; end
77
+ def dependencies_us() category 'Dependencies (United States)'; end
78
+ ## fix/todo: add all dependencies uk (or gb?), fr,cn,au,nz,no,dk,etc.
79
+
80
+ def europe() region 'Europe'; end
81
+ def south_asia() region 'South Asia'; end
82
+ def central_asia() region 'Central Asia'; end
83
+ def east_n_souteast_asia() region 'East & Southeast Asia'; end
84
+ def middle_east() region 'Middle East'; end
85
+ def africa() region 'Africa'; end
86
+ def north_america() region 'North America'; end
87
+ def central_america_n_caribbean() region 'Central America and Caribbean'; end
88
+ def south_america() region 'South America'; end
89
+ def australia_oceania() region 'Australia-Oceania'; end
90
+ def antartica() region 'Antarctica'; end
91
+
92
+ ## note: regions oceans and world - same as category oceans and world
93
+ ## use oceans_ii or world_ii or something ??
94
+ ## use category('World') n region('World')
95
+ ## use category('Oceans') n region('Oceans')
96
+
97
+
98
+ def category( query )
99
+ ## todo/future: allow passing in of regex too (not just string)
100
+ ## note: e.g. Dependencies (France) needs to get escpaed to
101
+ ## Dependencies \(France\) etc.
102
+ filter_regex = /#{Regexp.escape(query)}/i
103
+ codes = @codes.select do |code|
104
+ code.category ? filter_regex.match( code.category ) : false ## note: allow nil for category; will fail on search
105
+ end
106
+ Codes.new( codes ) ## return new Codes obj for easy-chaining
107
+ end
108
+
109
+ def region( query )
110
+ ## todo/future: allow passing in of regex too (not just string)
111
+ filter_regex = /#{Regexp.escape(query)}/i
112
+ codes = @codes.select do |code|
113
+ code.region ? filter_regex.match( code.region ) : false ## note: allow nil for region; will fail on search
114
+ end
115
+ Codes.new( codes ) ## return new Codes obj for easy-chaining
116
+ end
117
+
118
+ end # class codes
119
+
120
+ end # module Factbook
121
+
@@ -0,0 +1,24 @@
1
+
2
+ module Factbook
3
+ module Module
4
+ module Codes
5
+ MAJOR = 0
6
+ MINOR = 1
7
+ PATCH = 0
8
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
9
+
10
+ def self.version
11
+ VERSION
12
+ end
13
+
14
+ def self.banner
15
+ "factbook-codes/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
16
+ end
17
+
18
+ def self.root
19
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
20
+ end
21
+
22
+ end # module Codes
23
+ end # module Module
24
+ end # module Factbook
@@ -0,0 +1,7 @@
1
+ # note: allow require 'factbook/codes' too
2
+ # (in addition to require 'factbook-codes')
3
+
4
+ require_relative '../factbook-codes'
5
+
6
+
7
+
data/test/helper.rb ADDED
@@ -0,0 +1,9 @@
1
+ ## minitest setup
2
+ require 'minitest/autorun'
3
+
4
+
5
+ ## our own code
6
+ require 'factbook/codes'
7
+
8
+
9
+
@@ -0,0 +1,72 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_codes.rb
4
+
5
+
6
+ require 'helper'
7
+
8
+
9
+ class TestCodes < MiniTest::Test
10
+
11
+
12
+ def test_codes
13
+ assert_equal 261, Factbook.codes.size
14
+ assert_equal 261, Factbook.codes.to_a.size
15
+
16
+
17
+ assert_equal 195, Factbook.codes.countries.size
18
+ assert_equal 52, Factbook.codes.dependencies.size
19
+ assert_equal 5, Factbook.codes.oceans.size
20
+ assert_equal 1, Factbook.codes.world.size
21
+ assert_equal 2, Factbook.codes.others.size
22
+ assert_equal 6, Factbook.codes.misc.size
23
+
24
+ assert_equal 8, Factbook.codes.dependencies_us.size
25
+
26
+
27
+ assert_equal 55, Factbook.codes.europe.size
28
+ assert_equal 9, Factbook.codes.south_asia.size
29
+ assert_equal 6, Factbook.codes.central_asia.size
30
+ assert_equal 22, Factbook.codes.east_n_souteast_asia.size
31
+ assert_equal 19, Factbook.codes.middle_east.size
32
+ assert_equal 56, Factbook.codes.africa.size
33
+ assert_equal 7, Factbook.codes.north_america.size
34
+ assert_equal 33, Factbook.codes.central_america_n_caribbean.size
35
+ assert_equal 14, Factbook.codes.south_america.size
36
+ assert_equal 30, Factbook.codes.australia_oceania.size
37
+ assert_equal 4, Factbook.codes.antartica.size
38
+ assert_equal 5, Factbook.codes.region('Oceans').size
39
+ assert_equal 1, Factbook.codes.region('World').size
40
+
41
+ assert_equal 45, Factbook.codes.countries.europe.size
42
+
43
+ assert_equal Factbook.codes.category('Oceans').size, Factbook.codes.region('Oceans').size
44
+ assert_equal Factbook.codes.category('World').size, Factbook.codes.region('World').size
45
+
46
+
47
+ assert_equal 261, Factbook.codes.countries.size +
48
+ Factbook.codes.others.size +
49
+ Factbook.codes.dependencies.size +
50
+ Factbook.codes.misc.size +
51
+ Factbook.codes.oceans.size +
52
+ Factbook.codes.world.size
53
+
54
+ assert_equal 261, Factbook.codes.europe.size +
55
+ Factbook.codes.south_asia.size +
56
+ Factbook.codes.central_asia.size +
57
+ Factbook.codes.east_n_souteast_asia.size +
58
+ Factbook.codes.middle_east.size +
59
+ Factbook.codes.africa.size +
60
+ Factbook.codes.north_america.size +
61
+ Factbook.codes.central_america_n_caribbean.size +
62
+ Factbook.codes.south_america.size +
63
+ Factbook.codes.australia_oceania.size +
64
+ Factbook.codes.antartica.size +
65
+ Factbook.codes.region('Oceans').size +
66
+ Factbook.codes.region('World').size
67
+
68
+ end
69
+
70
+ end # class TestCodes
71
+
72
+
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: factbook-codes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logutils
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: csvreader
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '7'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '4.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: hoe
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.22'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.22'
75
+ description: factbook-codes - world factbook country codes (by region, by category,
76
+ etc.)
77
+ email: openmundi@googlegroups.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files:
81
+ - CHANGELOG.md
82
+ - Manifest.txt
83
+ - README.md
84
+ files:
85
+ - CHANGELOG.md
86
+ - Manifest.txt
87
+ - README.md
88
+ - Rakefile
89
+ - data/codes.csv
90
+ - data/codesxref.csv
91
+ - lib/factbook-codes.rb
92
+ - lib/factbook-codes/codes.rb
93
+ - lib/factbook-codes/version.rb
94
+ - lib/factbook/codes.rb
95
+ - test/helper.rb
96
+ - test/test_codes.rb
97
+ homepage: https://github.com/factbook/factbook
98
+ licenses:
99
+ - Public Domain
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options:
103
+ - "--main"
104
+ - README.md
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 2.2.2
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.1.4
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: factbook-codes - world factbook country codes (by region, by category, etc.)
122
+ test_files: []