world_bank 0.0.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +6 -0
- data/lib/world_bank.rb +6 -4
- data/lib/world_bank/client.rb +27 -54
- data/lib/world_bank/country.rb +337 -11
- data/lib/world_bank/data.rb +73 -0
- data/lib/world_bank/data_query.rb +64 -0
- data/lib/world_bank/income_level.rb +5 -12
- data/lib/world_bank/indicator.rb +52 -11
- data/lib/world_bank/lending_type.rb +4 -11
- data/lib/world_bank/param_query.rb +51 -0
- data/lib/world_bank/query.rb +189 -85
- data/lib/world_bank/region.rb +4 -11
- data/lib/world_bank/source.rb +5 -11
- data/lib/world_bank/topic.rb +8 -15
- data/lib/world_bank/version.rb +1 -1
- data/spec/world_bank/client_spec.rb +6 -74
- data/spec/world_bank/country_spec.rb +24 -39
- data/spec/world_bank/data_query_spec.rb +38 -0
- data/spec/world_bank/income_level_spec.rb +2 -9
- data/spec/world_bank/indicator_spec.rb +2 -2
- data/spec/world_bank/lending_type_spec.rb +2 -8
- data/spec/world_bank/param_query_spec.rb +45 -0
- data/spec/world_bank/query_spec.rb +44 -84
- data/spec/world_bank/region_spec.rb +2 -2
- data/spec/world_bank/source_spec.rb +2 -8
- data/spec/world_bank/topic_spec.rb +11 -17
- data/spec/world_bank_spec.rb +1 -1
- data/world_bank.gemspec +2 -2
- metadata +111 -137
- data/country_aliases +0 -257
- data/notes +0 -33
- data/notes_part_2 +0 -108
- data/projects_notes +0 -11
data/country_aliases
DELETED
@@ -1,257 +0,0 @@
|
|
1
|
-
:AW ABW: :aruba
|
2
|
-
:AF AFG: :afganistan
|
3
|
-
:AO AGO: :angola
|
4
|
-
:AI AIA: :anguilla
|
5
|
-
:AX ALA: :aland_islands
|
6
|
-
:AL ALB: :albania
|
7
|
-
:AD AND: :andorra
|
8
|
-
:AE ARE: :united_arab_emirates
|
9
|
-
:AR ARG: :argentina
|
10
|
-
:AM ARM: :armenia
|
11
|
-
:AS ASM: :american_samoa
|
12
|
-
:AQ ATA: :antarctica
|
13
|
-
:TF ATF: :french_southern_territories
|
14
|
-
:AG ATG: :antigua_and_barbuda
|
15
|
-
:AU AUS: :australia
|
16
|
-
:AT AUT: :austria
|
17
|
-
:AZ AZE: :azerbaijan
|
18
|
-
:BI BDI: :burundi
|
19
|
-
:BE BEL: :belgium
|
20
|
-
:BJ BEN: :benin
|
21
|
-
:BQ BES: :bonaire_saint_eustatius_and_saba
|
22
|
-
:BF BFA: :burkina_faso
|
23
|
-
:BD BGD: :bangladesh
|
24
|
-
:BG BGR: :bulgaria
|
25
|
-
:BH BHR: :bahrain
|
26
|
-
:BS BHS: :bahamas
|
27
|
-
:BA BIH: :bosnia_and_herzegovina
|
28
|
-
:BL BLM: :saint_barthelemy
|
29
|
-
:BY BLR: :belarus
|
30
|
-
:BZ BLZ: :belize
|
31
|
-
:BM BMU: :bermuda
|
32
|
-
:BO BOL: :plurinational_state_of_bolivia
|
33
|
-
:BR BRA: :brazil
|
34
|
-
:BB BRB: :barbados
|
35
|
-
:BN BRN: :brunei_darussalam
|
36
|
-
:BT BTN: :bhutan
|
37
|
-
:BV BVT: :bouvet_island
|
38
|
-
:BW BWA: :botswana
|
39
|
-
:CF CAF: :central_african_republic
|
40
|
-
:CA CAN: :canada
|
41
|
-
:CC CCK: :cocos_keeling_islands
|
42
|
-
:CH CHE: :switzerland
|
43
|
-
:CL CHL: :chile
|
44
|
-
:CN CHN: :china
|
45
|
-
:CI CIV: :cote_divoire
|
46
|
-
:CM CMR: :cameroon
|
47
|
-
:CD COD: :democratic_republic_of_the_congo
|
48
|
-
:CG COG: :congo
|
49
|
-
:CK COK: :cook_islands
|
50
|
-
:CO COL: :colombia
|
51
|
-
:KM COM: :comoros
|
52
|
-
:CV CPV: :cape_verde
|
53
|
-
:CR CRI: :costa_rica
|
54
|
-
:CU CUB: :cuba
|
55
|
-
:CW CUW: :curacao
|
56
|
-
:CX CXR: :christmas_island
|
57
|
-
:KY CYM: :cayman_islands
|
58
|
-
:CY CYP: :cyprus
|
59
|
-
:CZ CZE: :czech_republic
|
60
|
-
:DE DEU: :germany
|
61
|
-
:DJ DJI: :djibouti
|
62
|
-
:DM DMA: :dominca
|
63
|
-
:DK DNK: :denmark
|
64
|
-
:DO DOM: :dominican_republic
|
65
|
-
:DZ DZA: :algeria
|
66
|
-
:EC ECU: :ecuador
|
67
|
-
:EG EGY: :egypt
|
68
|
-
:ER ERI: :eritrea
|
69
|
-
:EH ESH: :western_sahara
|
70
|
-
:ES ESP: :spain
|
71
|
-
:EE EST: :estonia
|
72
|
-
:ET ETH: :ethiopia
|
73
|
-
:FI FIN: :finland
|
74
|
-
:FJ FJI: :fiji
|
75
|
-
:FK FLK: :falkland_islands_malvinas
|
76
|
-
:FR FRA: :france
|
77
|
-
:FO FRO: :faroe_islands
|
78
|
-
:FM FSM: :federated_states_of_micronesia
|
79
|
-
:GA GAB: :gabon
|
80
|
-
:GB GBR: :united_kingdom
|
81
|
-
:GE GEO: :georgia
|
82
|
-
:GG GGY: :guernsey
|
83
|
-
:GH GHA: :ghana
|
84
|
-
:GI GIB: :gibraltar
|
85
|
-
:GN GIN: :guinea
|
86
|
-
:GP GLP: :guadeloupe
|
87
|
-
:GM GMB: :gambia
|
88
|
-
:GW GNB: :guinea_bissau
|
89
|
-
:GQ GNQ: :equatorial_guinea
|
90
|
-
:GR GRC: :greece
|
91
|
-
:GD GRD: :grenada
|
92
|
-
:GL GRL: :greenland
|
93
|
-
:GT GTM: :guatemala
|
94
|
-
:GF GUF: :french_guiana
|
95
|
-
:GU GUM: :guam
|
96
|
-
:GY GUY: :guyana
|
97
|
-
:HK HKG: :hong_kong
|
98
|
-
:HM HMD: :heard_island_mcdonald_islands
|
99
|
-
:HN HND: :honduras
|
100
|
-
:HR HRV: :croatia
|
101
|
-
:HT HTI: :haiti
|
102
|
-
:HU HUN: :hungary
|
103
|
-
:ID IDN: :indonesia
|
104
|
-
:IM IMN: :isle_of_man
|
105
|
-
:IN IND: :india
|
106
|
-
:IO IOT: :british_indian_ocean_territory
|
107
|
-
:IE IRL: :ireland
|
108
|
-
:IR IRN: :islamic_republic_of_iran
|
109
|
-
:IQ IRQ: :iraq
|
110
|
-
:IS ISL: :iceland
|
111
|
-
:IL ISR: :israel
|
112
|
-
:IT ITA: :italy
|
113
|
-
:JM JAM: :jamaica
|
114
|
-
:JE JEY: :jersey
|
115
|
-
:JO JOR: :jordan
|
116
|
-
:JP JPN: :japan
|
117
|
-
:KZ KAZ: :kazakhstan
|
118
|
-
:KE KEN: :kenya
|
119
|
-
:KG KGZ: :kyrgyzstan
|
120
|
-
:KH KHM: :cambodia
|
121
|
-
:KI KIR: :kiribati
|
122
|
-
:KN KNA: :saint_kitts_and_nevis
|
123
|
-
:KR KOR: :republic_of_korea
|
124
|
-
:KW KWT: :kuwait
|
125
|
-
:LA LAO: :lao_peoples_democratic_republic
|
126
|
-
:LB LBN: :lebanon
|
127
|
-
:LR LBR: :liberia
|
128
|
-
:LY LBY: :libyan_arab_jamahiriya
|
129
|
-
:LC LCA: :saint_lucia
|
130
|
-
:LI LIE: :liechtenstein
|
131
|
-
:LK LKA: :sri_lanka
|
132
|
-
:LS LSO: :lesotho
|
133
|
-
:LT LTU: :lithuania
|
134
|
-
:LU LUX: :luxembourg
|
135
|
-
:LV LVA: :latvia
|
136
|
-
:MO MAC: :macao
|
137
|
-
:MF MAF: :saint_martin
|
138
|
-
:MA MAR: :morocco
|
139
|
-
:MC MCO: :monaco
|
140
|
-
:MD MDA: :republic_of_moldova
|
141
|
-
:MG MDG: :madagascar
|
142
|
-
:MV MDV: :maldives
|
143
|
-
:MX MEX: :mexico
|
144
|
-
:MH MHL: :marshall_islands
|
145
|
-
:MK MKD: :the_former_yugoslav_republic_of_macedonia
|
146
|
-
:ML MLI: :mali
|
147
|
-
:MT MLT: :malta
|
148
|
-
:MM MMR: :myanmar
|
149
|
-
:ME MNE: :montenegro
|
150
|
-
:MN MNG: :mongolia
|
151
|
-
:MP MNP: :northern_mariana_islands
|
152
|
-
:MZ MOZ: :mozambique
|
153
|
-
:MR MRT: :mauritania
|
154
|
-
:MS MSR: :montserrat
|
155
|
-
:MQ MTQ: :martinique
|
156
|
-
:MU MUS: :mauritius
|
157
|
-
:MW MWI: :malawi
|
158
|
-
:MY MYS: :malaysia
|
159
|
-
:YT MYT: :mayotte
|
160
|
-
:NA NAM: :namibia
|
161
|
-
:NC NCL: :new_caledonia
|
162
|
-
:NE NER: :niger
|
163
|
-
:NF NFK: :norfolk_island
|
164
|
-
:NG NGA: :nigeria
|
165
|
-
:NI NIC: :nicaragua
|
166
|
-
:NU NIU: :niue
|
167
|
-
:NL NLD: :netherlands
|
168
|
-
:NO NOR: :norway
|
169
|
-
:NP NPL: :nepal
|
170
|
-
:NR NRU: :nauru
|
171
|
-
:NZ NZL: :new_zealand
|
172
|
-
:OM OMN: :oman
|
173
|
-
:PK PAK: :pakistan
|
174
|
-
:PA PAN: :panama
|
175
|
-
:PN PCN: :pitcairn
|
176
|
-
:PE PER: :peru
|
177
|
-
:PH PHL: :philippines
|
178
|
-
:PW PLW: :palau
|
179
|
-
:PG PNG: :papua_new_guinea
|
180
|
-
:PL POL: :poland
|
181
|
-
:PR PRI: :puerto_rico
|
182
|
-
:KP PRK: :democratic_peoples_republic_of_korea
|
183
|
-
:PT PRT: :portugal
|
184
|
-
:PY PRY: :paraguay
|
185
|
-
:PS PSE: :occupied_palestinian_territory
|
186
|
-
:PF PYF: :french_polynesia
|
187
|
-
:QA QAT: :qatar
|
188
|
-
:RE REU: :reunion
|
189
|
-
:RO ROU: :romania
|
190
|
-
:RU RUS: :russian_federation
|
191
|
-
:RW RWA: :rwanda
|
192
|
-
:SA SAU: :saudi_arabia
|
193
|
-
:SD SDN: :sudan
|
194
|
-
:SN SEN: :senegal
|
195
|
-
:SG SGP: :singapore
|
196
|
-
:GS SGS: :south_georgia_and_the_south_sandwich_islands
|
197
|
-
:SH SHN: :saint_helena_ascension_and_tristan_da_cunha
|
198
|
-
:SJ SJM: :svalbard_and_jan_mayen
|
199
|
-
:SB SLB: :soloman_islands
|
200
|
-
:SL SLE: :sierra_leone
|
201
|
-
:SV SLV: :el_salvador
|
202
|
-
:SM SMR: :san_marino
|
203
|
-
:SO SOM: :somalia
|
204
|
-
:PM SPM: :saint_pierre_and_miquelon
|
205
|
-
:RS SRB: :serbia
|
206
|
-
:ST STP: :sao_tome_and_principe
|
207
|
-
:SR SUR: :suriname
|
208
|
-
:SK SVK: :slovakia
|
209
|
-
:SI SVN: :slovenia
|
210
|
-
:SE SWE: :sweden
|
211
|
-
:SZ SWZ: :swaziland
|
212
|
-
:SX SXM: :sint_maarten
|
213
|
-
:SC SYC: :seychelles
|
214
|
-
:SY SYR: :syrian_arab_republic
|
215
|
-
:TC TCA: :turks_caicos_islands
|
216
|
-
:TD TCD: :chad
|
217
|
-
:TG TGO: :togo
|
218
|
-
:TH THA: :thailand
|
219
|
-
:TJ TJK: :tajikistan
|
220
|
-
:TK TKL: :tokelau
|
221
|
-
:TM TKM: :turkmenistan
|
222
|
-
:TL TLS: :timor_leste
|
223
|
-
:TO TON: :tonga
|
224
|
-
:TT TTO: :trinidad_and_tobago
|
225
|
-
:TN TUN: :tunisia
|
226
|
-
:TR TUR: :turkey
|
227
|
-
:TU TUV: :tuvalu
|
228
|
-
:TW TWN: :taiwan_provice_of_china
|
229
|
-
:TZ TZA: :united_republic_of_tanzania
|
230
|
-
:UG UGA: :uganda
|
231
|
-
:UA UKR: :ukraine
|
232
|
-
:UM UMI: :united_states_minor_outlying_islands
|
233
|
-
:UY URY: :uruguay
|
234
|
-
:US USA: :united_states
|
235
|
-
:UZ UZB: :uzbekistan
|
236
|
-
:VA VAT; :holy_see_vatican_city
|
237
|
-
:VC VCT: :saint_vincent_and_the_grenadines
|
238
|
-
:VE VEN: :bolivarian_republic_of_venezuela
|
239
|
-
:VG VGB: :british_virgin_islands
|
240
|
-
:VI VIR: :us_virgin_islands
|
241
|
-
:VN VNM: :viet_nam
|
242
|
-
:VU VUT: :vanuatu
|
243
|
-
:WF WLF: :wallis_and_futuna
|
244
|
-
:WS WSM: :samoa
|
245
|
-
:YE YEM: :yemen
|
246
|
-
:ZA ZAF: :south_africa
|
247
|
-
:ZM ZMB: :zambia
|
248
|
-
:ZW ZWE: :zimbabwe
|
249
|
-
|
250
|
-
The World Bank uses both these 3 and 2 letter abbr. except:
|
251
|
-
alternative 3 letter codes for:
|
252
|
-
Andorra (listed and seems to be accurate), dem. rep. of congo(listed and seems to be accurate), isle of man (not listed at all), romania (not listed at all), timor-leste (ditto), west bank and gaza (ditto)
|
253
|
-
|
254
|
-
alternative 2 letter codes for:
|
255
|
-
dem. rep. of congo(listed and seems to be accurate), serbia, timor-leste, yemen, west bank and gaza
|
256
|
-
|
257
|
-
channel islands (which the world bank lists as JG, CHI, and channel_islands) and kosovo (and isn't listed) do not have iso codes (2 or 3 letters)
|
data/notes
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
global parameters:
|
2
|
-
required: none
|
3
|
-
optional:
|
4
|
-
-date
|
5
|
-
a range sent as date1:date2, set as Date1..Date2?
|
6
|
-
values can be Year or Year-and-Month or Year-and-Quarter and is sent as 2010, 2010M2, 2010Q2 respectively
|
7
|
-
also takes a year-to-date value as YTD:2010 - unsure how to use it....
|
8
|
-
|
9
|
-
-format:
|
10
|
-
string one of: xml, json, jsonP
|
11
|
-
|
12
|
-
-prefix:
|
13
|
-
a prefix needs to be specified if the format is JSONP
|
14
|
-
|
15
|
-
-page:
|
16
|
-
number for the page of results in a large dataset
|
17
|
-
|
18
|
-
-per_page:
|
19
|
-
how many results to return when paging, default is 50
|
20
|
-
|
21
|
-
-most_recent_values:
|
22
|
-
number of the most recent values for the parameters, sent as MRV=
|
23
|
-
|
24
|
-
-gap_fill?:
|
25
|
-
boolean, sent as Gapfill=
|
26
|
-
|
27
|
-
-frequency:
|
28
|
-
one of %w(Y Q M) for Yearly, Quarterly, and Monthly respectively... ly
|
29
|
-
|
30
|
-
-language:
|
31
|
-
can be one of %w(en es fr ar), (or if you're wondering that's english, spanish, french and arabic respectively).
|
32
|
-
sent as api.worldbank.org/{lang}/rest/of/request....
|
33
|
-
default is english
|
data/notes_part_2
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# top level "reference" methods?
|
3
|
-
#
|
4
|
-
WorldBank.sources # => ['Doing Business', 'Something Else'...] array of 16 sources of information the bank used
|
5
|
-
WorldBank.income_levels # => { HIC: 'High Income', HPC: 'Heavily Indebted Poor Countries (HIPC)'...} hash of 9 income levels the bank assigns
|
6
|
-
WorldBank.income_level_ids # => [ 'HIC', 'HPC'...] too much?
|
7
|
-
WorldBank.income_level_names #=> ['High Income', 'Heavily Indebted Poor...'...] probably too far....
|
8
|
-
WorldBank.lending_types # => [ { id: 'IBD', value: 'IBRD' }... ] an array of key: value pairs of the 4 lending types
|
9
|
-
WorldBank.lending_type_ids # => [ 'IBD', 'IDA', 'IDB' 'NC' ]
|
10
|
-
WorldBank.lending_type_names #=> [ 'Not classified', 'Blend', ...]
|
11
|
-
WorldBank.topics # => the 18 high level topics that indicators are grouped into
|
12
|
-
WorldBank.regions # => not an api call... countries can grouped by lending_type, income_level, as well as region_code, region_codes are:
|
13
|
-
# EAP - (developing only) East Asia & Pacific
|
14
|
-
# EAS - (all income levels) ibid
|
15
|
-
# ECA - (developing only) Europe & Central Asia
|
16
|
-
# ECS - (all income levels) ibid
|
17
|
-
# LAC - (developing only) Latin America & Caribbean
|
18
|
-
# LCN - (all income levels) ibid
|
19
|
-
# MNA - (developing only) Middle East & North Africa
|
20
|
-
# MEA - (all income levels) ibid
|
21
|
-
# NAC North America
|
22
|
-
# SAS South Asia
|
23
|
-
# SSA - (developing only) Sub-Saharan Africa
|
24
|
-
# SSF - (all income levels) ibid
|
25
|
-
#
|
26
|
-
WorldBank.countries # => same as Country.all
|
27
|
-
WorldBank.indicators # => same as Indicator.all
|
28
|
-
WorldBank.topics # => same as Topic.all
|
29
|
-
|
30
|
-
|
31
|
-
#
|
32
|
-
# Topics
|
33
|
-
#
|
34
|
-
Topic.all
|
35
|
-
@environment = Topic.find(6)
|
36
|
-
@environment.id # => 6
|
37
|
-
@environment.name # => 'Environment'
|
38
|
-
@environment.note # => 'Natural and man-made environmental resources – fresh...'
|
39
|
-
|
40
|
-
#
|
41
|
-
# Countries
|
42
|
-
#
|
43
|
-
Country.all
|
44
|
-
Country.each
|
45
|
-
Country.each_page # => too much? alias for Enumerable#each_slice?
|
46
|
-
|
47
|
-
Country.find('br')
|
48
|
-
Country.find('bra')
|
49
|
-
|
50
|
-
@brazil = Country.find('brazil')
|
51
|
-
@brazil.name # => 'Brazil'
|
52
|
-
|
53
|
-
# only low and middle income countries are classified by region...
|
54
|
-
#
|
55
|
-
@brazil.region_id # => 'LCN'
|
56
|
-
@brazil.region_value # => 'Latin America & Carribean (all income levels)'
|
57
|
-
@brazil.region # alias for .region_name
|
58
|
-
|
59
|
-
# Major income levels the bank uses are:
|
60
|
-
# "low income" => < $995
|
61
|
-
# "lower middle income" => $996 <=> $3945
|
62
|
-
# "upper middle income => $3946 <=> $12195
|
63
|
-
# "high income" => > $12196
|
64
|
-
# though there are many others...
|
65
|
-
#
|
66
|
-
@brazil.income_level_id # => 'UMC'
|
67
|
-
@brazil.income_level_value # => 'Upper middle income'
|
68
|
-
@brazil.income_level # alias for .income_level_value
|
69
|
-
|
70
|
-
# countries can qualify for two different types of loans (3 labels):
|
71
|
-
# "International Bank for Reconstruction and Development" (IRBD)
|
72
|
-
# "International Development Association" (IDA)
|
73
|
-
# "Blended" (both)
|
74
|
-
# IDA loans have little to no interest and/or are grants, a country must be below $1165 to qualify
|
75
|
-
# Countries may also be of type "Blended" where their income is low enough for IDA, and their credit is high enough of IRBD.
|
76
|
-
# see http://data.worldbank.org/about/country-classifications for more info
|
77
|
-
#
|
78
|
-
@brazil.lending_type_id # => 'IBD'
|
79
|
-
@brazil.lending_type_value # => 'IBRD'
|
80
|
-
@brazil.lending_type # => 'International Bank for Reconstruction and Development Qualified'
|
81
|
-
@brazil.capital # => 'Brasilia'
|
82
|
-
@brazil.capital # alias for .capital_city
|
83
|
-
@brazil.captial_lon # => -47.9292
|
84
|
-
@brazil.capital_lat # => -15.7801
|
85
|
-
@brazil.coords # => [-15.7801, -47.9292] ??? too much?
|
86
|
-
|
87
|
-
|
88
|
-
#
|
89
|
-
# Indicators
|
90
|
-
#
|
91
|
-
Indicators.all # => begins paging through 4073 different indicators
|
92
|
-
Indicators.each
|
93
|
-
Indicators.each_page # => too much? alias for Enumerable#each_slice ?
|
94
|
-
|
95
|
-
@tractors = Indicator.find('AG.AGR.TRAC.NO')
|
96
|
-
@tractors.id # => 'AG.AGR.TRAC.NO' because, you know, that's really helpful to know...
|
97
|
-
@tractors.name # => 'Agricultural Machinery, tractors'
|
98
|
-
@tractors.source # => { id: 2, value: 'World Development Indicators' }
|
99
|
-
@tractors.source_id # => 2
|
100
|
-
@tractors.source_name # => 'World Development Indicators'
|
101
|
-
|
102
|
-
# note the api docs say that source_note, topic_id, and topic_name are available for every record,
|
103
|
-
# pull them down, they're wrong
|
104
|
-
#
|
105
|
-
@tractors.note # => 'Agricultural machinery refers to the number of....'
|
106
|
-
@tractors.note? # => true note may be empty
|
107
|
-
@tractors.source_organization #=> 'Food and Agriculture Organization, electronic files and web'
|
108
|
-
@tractors.topics # => [ { id: 1, value: 'Agricultural & Rural Development' } ] array of applicable topics (may be empty!)
|
data/projects_notes
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
|
2
|
-
Projects API
|
3
|
-
|
4
|
-
search for everything:
|
5
|
-
http://search.worldbank.org/api/projects?qterm=*:*&countrycode[]=AF&format=json&kw=N
|
6
|
-
|
7
|
-
search for only the country afghanistan
|
8
|
-
http://search.worldbank.org/api/projects?qterm=*:*&countrycode[]=AF&format=json&kw=N
|
9
|
-
|
10
|
-
search for several countries:
|
11
|
-
http://search.worldbank.org/api/projects?qterm=*:*&countrycode[]=AF&countrycode[]=DZ&countrycode[]=AS&format=json&kw=N
|