factbook 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24d96765bcda05d51ce7f72baa5f565da45aa85b
4
- data.tar.gz: 7841f960d9905ad051c6ef255f374ed875091f88
3
+ metadata.gz: 7d04215fc02fbf5130eea7d48cc460f0e7df2cb6
4
+ data.tar.gz: eddd7e401104e81b6ab8146c080ace4e83e8f1d0
5
5
  SHA512:
6
- metadata.gz: 93fac1f61de8fcd72e98afb4ed5bb6619cb849fac69ef979c2a5703fd2886a0cf8b6a9c260cb179c3209d6d61a57170ac7dc11e81c59928ec3532efcbf212180
7
- data.tar.gz: 5e84df0a02a7278b9cb54f19fd02364abe302c78a1aa222b334e3844141b13d82c10e1e51b53d5a906bbb8f43ee59cd44b02abde2aff58c6f1cff37355346ce8
6
+ metadata.gz: c68ce2ae5385316adf9d2a9bda234cf96ab8b4d59553a155a159da4fbb1d9bf017d6fc9630dab2e4a15ab691ff36c60752a75e2db9c0f61258d34653f4e0759d
7
+ data.tar.gz: d54e73bf9d52eb7b71eea41f9633bb2b761cc4e3c3bfa292aa3318c527be9b7952524494582b252bd777fa9f1f6fa13b3985f54bff0a3003c04c35f65f9435cc
@@ -2,19 +2,27 @@ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ data/attributes.yml
5
6
  data/categories.csv
6
7
  data/codes.csv
7
8
  data/codesxref.csv
8
9
  data/comparisons.csv
9
10
  lib/factbook.rb
11
+ lib/factbook/almanac.rb
12
+ lib/factbook/attributes.rb
10
13
  lib/factbook/builder.rb
11
14
  lib/factbook/builder_item.rb
15
+ lib/factbook/builder_json.rb
12
16
  lib/factbook/codes.rb
13
17
  lib/factbook/comparisons.rb
18
+ lib/factbook/counter.rb
14
19
  lib/factbook/db/importer.rb
15
20
  lib/factbook/db/models.rb
16
21
  lib/factbook/db/schema.rb
22
+ lib/factbook/normalize.rb
17
23
  lib/factbook/page.rb
24
+ lib/factbook/page_info.rb
25
+ lib/factbook/reader_json.rb
18
26
  lib/factbook/sanitizer.rb
19
27
  lib/factbook/sect.rb
20
28
  lib/factbook/subsect.rb
@@ -22,23 +30,33 @@ lib/factbook/table.rb
22
30
  lib/factbook/utils.rb
23
31
  lib/factbook/utils_info.rb
24
32
  lib/factbook/version.rb
33
+ script/almanac.rb
34
+ script/attributes.rb
35
+ script/build.rb
36
+ script/counter.rb
37
+ script/json.rb
25
38
  script/testbr.rb
26
39
  script/testcodes.rb
27
40
  test/data/au.html
28
41
  test/data/au.yml
29
42
  test/data/be.html
30
43
  test/data/be.yml
44
+ test/data/json/au.json
31
45
  test/data/src/au.html
32
46
  test/data/src/be.html
33
47
  test/helper.rb
34
48
  test/test_attribs.rb
49
+ test/test_attribs_def.rb
35
50
  test/test_builder.rb
36
51
  test/test_codes.rb
37
52
  test/test_comparisons.rb
38
53
  test/test_convert.rb
54
+ test/test_counter.rb
39
55
  test/test_fields.rb
40
56
  test/test_importer.rb
41
57
  test/test_item_builder.rb
42
58
  test/test_json.rb
59
+ test/test_json_builder.rb
60
+ test/test_normalize.rb
43
61
  test/test_page.rb
44
62
  test/test_sanitizer.rb
data/README.md CHANGED
@@ -92,6 +92,10 @@ pp page.resources ## same as page['Geography'][Natural resources']['text
92
92
  ...
93
93
  ```
94
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
+
95
99
  ### Save to disk as JSON
96
100
 
97
101
  ```ruby
@@ -172,6 +176,9 @@ assert_equal 45, Factbook.codes.countries.europe.size
172
176
  ...
173
177
  ```
174
178
 
179
+ See [`data/codes.csv`](data/codes.csv) for the built-in listing of all codes with categories and regions.
180
+
181
+
175
182
 
176
183
  ## The World Factbook Summary (267 Entries)
177
184
 
@@ -0,0 +1,337 @@
1
+ ############################
2
+ # attributes
3
+
4
+ Introduction:
5
+ Background: { name: background }
6
+
7
+ Geography:
8
+ Location: { name: location }
9
+ Geographic coordinates: { name: coords } ## use geo_coords - why, why not??
10
+ Map references: { name: map } ## use map_ref - why, why not??
11
+ Area:
12
+ total: { name: area }
13
+ land: { name: area_land }
14
+ water: { name: area_water }
15
+ note: { name: area_note }
16
+ Area - comparative: { name: area_comparative }
17
+ Land boundaries:
18
+ total: { name: border_land }
19
+ border countries: { name: border_countries } ## todo/fix: remove count from key e.g. border countries (8)
20
+ Coastline: { name: coastline } ## use border_water - why, why not??
21
+ Maritime claims:
22
+ territorial sea: { name: maritime_claims_territorial_sea }
23
+ contiguous zone: { name: maritime_claims_contiguous_zone }
24
+ exclusive economic zone: { name: maritime_claims_exclusive_economic_zone }
25
+ continental shelf: { name: maritime_claims_continental_shelf }
26
+ Climate: { name: climate }
27
+ Terrain: { name: terrain }
28
+ Elevation extremes:
29
+ lowest point: { name: elevation_lowest }
30
+ highest point: { name: elevation_highest }
31
+ Natural resources: { name: resources }
32
+ Land use:
33
+ agricultural land: { name: land_use_agriculture }
34
+ forest: { name: land_use_forest }
35
+ other: { name: land_use_other }
36
+ Irrigated land: { name: land_irrigated }
37
+ Total renewable water resources: { name: water_renewable }
38
+ Freshwater withdrawal (domestic/industrial/agricultural):
39
+ total: { name: water_withdrawal }
40
+ per capita: { name: water_withdrawal_capita }
41
+ Natural hazards:
42
+ name: natural_hazards ## note: "special" attribute case with "mixed" content
43
+ volcanism: { name: natural_hazards_volcanism }
44
+ Environment - current issues: { name: environment_issues }
45
+ Environment - international agreements:
46
+ party to: { name: environment_agreements }
47
+ "signed, but not ratified": { name: environment_agreements_note } ## use _ratified - why, why not??
48
+ Geography - note: { name: geography_note } ## use geo_note or geography - why, why not??
49
+
50
+ People and Society:
51
+ Nationality:
52
+ noun: { name: nationality }
53
+ adjective: { name: nationality_adjective }
54
+ Ethnic groups: { name: ethnic_groups }
55
+ Languages:
56
+ name: languages ## note: "special" attribute case with "mixed" content
57
+ note: { name: languages_note }
58
+ Religions: { name: religions }
59
+ Demographic profile: { name: demographic }
60
+ Population: { name: population }
61
+ Age structure:
62
+ 0-14 years: { name: age_0_14yrs }
63
+ 15-24 years: { name: age_15_24yrs }
64
+ 25-54 years: { name: age_25_54yrs }
65
+ 55-64 years: { name: age_55_64yrs }
66
+ 65 years and over: { name: age_65yrs_plus }
67
+ Dependency ratios:
68
+ total: { name: dependency_ratio }
69
+ youth dependency ratio: { name: dependency_youth_ratio }
70
+ elderly dependency ratio: { name: dependency_elderly_ratio }
71
+ potential support ratio: { name: dependency_support_ratio }
72
+ Median age:
73
+ total: { name: median_age }
74
+ male: { name: median_age_male }
75
+ female: { name: median_age_female }
76
+ Population growth rate: { name: population_growth }
77
+ Birth rate: { name: birth_rate }
78
+ Death rate: { name: death_rate }
79
+ Net migration rate: { name: migration_rate }
80
+ Urbanization:
81
+ urban population: { name: urbanization }
82
+ rate of urbanization: { name: urbanization_growth } ## use _rate - why, why not??
83
+ Major urban areas - population: { name: major_cities }
84
+ Sex ratio:
85
+ at birth: { name: sex_ratio_birth }
86
+ 0-14 years: { name: sex_ratio_0_14yrs }
87
+ 15-24 years: { name: sex_ratio_15_24yrs }
88
+ 25-54 years: { name: sex_ratio_25_54yrs }
89
+ 55-64 years: { name: sex_ratio_55_64yrs }
90
+ 65 years and over: { name: sex_ratio_65yrs_plus }
91
+ total population: { name: sex_ratio }
92
+ Infant mortality rate:
93
+ total: { name: infant_mortality } ## add _rate - why, why not??
94
+ male: { name: infant_mortality_male }
95
+ female: { name: infant_mortality_female }
96
+ Life expectancy at birth:
97
+ total population: { name: life_expectancy }
98
+ male: { name: life_expectancy_male }
99
+ female: { name: life_expectancy_female }
100
+ Total fertility rate: { name: fertility }
101
+ Contraceptive prevalence rate:
102
+ name: contraceptive_rate ## note: "special" attribute case with "mixed" content
103
+ note: { name: contraceptive_rate_note }
104
+ Health expenditures: { name: health_expenditures } ## todo: change to health ??
105
+ Physicians density: { name: density_physicians }
106
+ Hospital bed density: { name: density_hospital_bed }
107
+ Drinking water source:
108
+ improved: { name: drinking_water_improved } ## todo:split into urban/rural/total ??
109
+ unimproved: { name: drinking_water_unimproved }
110
+ Sanitation facility access:
111
+ improved: { name: sanitation_improved } ## todo:split into urban/rural/total ??
112
+ unimproved: { name: sanitation_unimproved }
113
+ HIV/AIDS - adult prevalence rate: { name: aids }
114
+ HIV/AIDS - people living with HIV/AIDS: { name: aids_people }
115
+ HIV/AIDS - deaths: { name: aids_deaths }
116
+ Obesity - adult prevalence rate: { name: obesity }
117
+ Children under the age of 5 years underweight: { name: underweight_children_under_5yrs }
118
+ Education expenditures: { name: education_expenditures } ## change to education ??
119
+ Literacy:
120
+ definition: { name: literacy_def }
121
+ total population: { name: literacy }
122
+ male: { name: literacy_male }
123
+ female: { name: literacy_female }
124
+ School life expectancy (primary to tertiary education):
125
+ total: { name: school_life }
126
+ male: { name: school_life_male }
127
+ female: { name: school_life_female }
128
+ Child labor - children ages 5-14:
129
+ total number: { name: child_labor }
130
+ percentage: { name: child_labor_rate }
131
+ note: { name: child_labor_note }
132
+ "Unemployment, youth ages 15-24":
133
+ total: { name: unemployment_youth }
134
+ male: { name: unemployment_youth_male }
135
+ female: { name: unemployment_youth_female }
136
+
137
+ Government:
138
+ Country name:
139
+ conventional long form: { name: name_long }
140
+ conventional short form: { name: name }
141
+ local long form: { name: name_long_local }
142
+ local short form: { name: name_local }
143
+ note: { name: name_note }
144
+ ## add name_former ( see gm) ?? add abbreviations (see us)
145
+ Government type: { name: government_type }
146
+ Capital:
147
+ name: { name: capital }
148
+ geographic coordinates: { name: capital_coords }
149
+ time difference: { name: capital_time_diff }
150
+ daylight saving time: { name: capital_dst }
151
+ Administrative divisions: { name: admins }
152
+ Independence: { name: independence }
153
+ National holiday: { name: natinal_holiday }
154
+ Constitution: { name: constitution }
155
+ Legal system: { name: legal_system }
156
+ International law organization participation: { name: legal_intl_orgs }
157
+ Suffrage: { name: suffrage }
158
+ ## note: skip Executive,Legislative,Judicial,... entries for now
159
+ International organization participation: { name: intl_orgs }
160
+ Flag description: { name: flag }
161
+ National symbol(s): { name: national_symbols }
162
+ National anthem:
163
+ name: { name: national_anthem}
164
+ lyrics/music: { name: national_anthem_by }
165
+ note: { name: national_anthem_note }
166
+
167
+ Economy:
168
+ Economy - overview: { name: economy_overview }
169
+ GDP (purchasing power parity):
170
+ name: gdp_ppp ## note: "special" attribute case with "mixed" content
171
+ note: { name: gdp_ppp_note }
172
+ GDP (official exchange rate): { name: gdp }
173
+ GDP - real growth rate: { name: gdp_growth }
174
+ GDP - per capita (PPP):
175
+ name: gdp_ppp_capita ## note: "special" attribute case with "mixed" content
176
+ note: { name: gdp_ppp_capita_note }
177
+ Gross national saving: { name: saving }
178
+ "GDP - composition, by end use":
179
+ household consumption: { name: consumption_household }
180
+ government consumption: { name: consumption_government }
181
+ investment in fixed capital: { name: investment_fixed }
182
+ investment in inventories: { name: investment_inventories }
183
+ exports of goods and services: { name: exports_gdp_rate }
184
+ imports of goods and services: { name: imports_gdb_rate }
185
+ "GDP - composition, by sector of origin":
186
+ agriculture: { name: agriculture_gdb_rate }
187
+ industry: { name: industry_gdb_rate }
188
+ services: { name: services_gdb_rate }
189
+ Agriculture - products: { name: agriculture_products }
190
+ Industries: { name: industries }
191
+ Industrial production growth rate: { name: industry_growth }
192
+ Labor force: { name: labor }
193
+ Labor force - by occupation:
194
+ agriculture: { name: labor_agriculture }
195
+ industry: { name: labor_industry }
196
+ services: { name: labor_services }
197
+ Unemployment rate: { name: unemployment }
198
+ Population below poverty line:
199
+ name: poverty ## note: "special" attribute case with "mixed" content
200
+ note: { name: poverty_note }
201
+ Household income or consumption by percentage share:
202
+ "lowest 10%": { name: household_income_lowest } ## use _poorest, _bottom ???
203
+ "highest 10%": { name: household_income_highest } ## use _richest, _top ???
204
+ Distribution of family income - Gini index: { name: gini }
205
+ Budget:
206
+ revenues: { name: budget_revenues }
207
+ expenditures: { name: budget_expenditures }
208
+ Taxes and other revenues: { name: taxes }
209
+ Budget surplus (+) or deficit (-): { name: budget_balance }
210
+ Public debt:
211
+ name: public_debt ## note: "special" attribute case with "mixed" content
212
+ note: { name: public_debt_note }
213
+ Fiscal year: { name: fiscal_year }
214
+ Inflation rate (consumer prices): { name: inflation }
215
+ Central bank discount rate: { name: central_bank_discount_rate } ## use discount_rate - why? why not??
216
+ Commercial bank prime lending rate: { name: prime_rate }
217
+ Stock of narrow money:
218
+ name: narrow_money ## note: "special" attribute case with "mixed" content
219
+ note: { name: narrow_money_note }
220
+ Stock of broad money: { name: broad_money }
221
+ Stock of domestic credit: { name: domestic_credit }
222
+ Market value of publicly traded shares: { name: shares_market_value }
223
+ Current account balance: { name: current_account_balance }
224
+ Exports: { name: exports }
225
+ Exports - commodities: { name: exports_commodities }
226
+ Exports - partners: { name: exports_partners }
227
+ Imports: { name: imports }
228
+ Imports - commodities: { name: imports_commodities }
229
+ Imports - partners: { name: imports_partners }
230
+ Reserves of foreign exchange and gold: { name: foreign_exchange_reserves }
231
+ Debt - external: { name: debt_external }
232
+ Stock of direct foreign investment - at home: { name: direct_foreign_investment_home }
233
+ Stock of direct foreign investment - abroad: { name: direct_foreign_investment_abroad }
234
+ Exchange rates: { name: exchange_rates }
235
+
236
+ Energy:
237
+ Electricity - production: { name: electricity_production }
238
+ Electricity - consumption: { name: electricity_consumption }
239
+ Electricity - exports: { name: electricity_exports }
240
+ Electricity - imports: { name: electricity_imports }
241
+ Electricity - installed generating capacity: { name: electricity_capacity }
242
+ Electricity - from fossil fuels: { name: electricity_fossil }
243
+ Electricity - from nuclear fuels: { name: electricity_nuclear }
244
+ Electricity - from hydroelectric plants: { name: electricity_hydro }
245
+ Electricity - from other renewable sources: { name: electricity_other }
246
+ Crude oil - production: { name: oil_production }
247
+ Crude oil - exports: { name: oil_exports }
248
+ Crude oil - imports: { name: oil_imports }
249
+ Crude oil - proved reserves: { name: oil_reserves }
250
+ Refined petroleum products - production: { name: petroleum_production }
251
+ Refined petroleum products - consumption: { name: petroleum_consumption }
252
+ Refined petroleum products - exports: { name: petroleum_exports }
253
+ Refined petroleum products - imports: { name: petroleum_imports }
254
+ Natural gas - production: { name: natural_gas_production }
255
+ Natural gas - consumption: { name: natural_gas_consumpiton }
256
+ Natural gas - exports: { name: natural_gas_exports }
257
+ Natural gas - imports: { name: natural_gas_imports }
258
+ Natural gas - proved reserves: { name: natural_gas_reserves }
259
+ Carbon dioxide emissions from consumption of energy: { name: carbon_dioxide }
260
+
261
+ Communications:
262
+ Telephones - fixed lines:
263
+ total subscriptions: { name: telephones }
264
+ subscriptions per 100 inhabitants: { name: telephones_subscriptions }
265
+ Telephones - mobile cellular:
266
+ total: { name: telephones_mobile }
267
+ subscriptions per 100 inhabitants: { name: telephones_mobile_subscriptions }
268
+ Telephone system:
269
+ general assessment: { name: telephone_system }
270
+ domestic: { name: telephone_system_domestic }
271
+ international: { name: telephone_system_intl }
272
+ Broadcast media: { name: broadcast_media }
273
+ Radio broadcast stations: { name: radio_broadcast_stations }
274
+ Television broadcast stations: { name: tv_broadcast_stations }
275
+ Internet country code: { name: internet }
276
+ Internet users:
277
+ total: { name: internet_users }
278
+ percent of population: { name: internet_users_rate }
279
+
280
+ Transportation:
281
+ Airports: { name: airports }
282
+ Airports - with paved runways:
283
+ total: { name: airports_paved }
284
+ "over 3,047 m": { name: airports_paved_over_10000ft }
285
+ "2,438 to 3,047 m": { name: airports_paved_8000_10000ft }
286
+ "1,524 to 2,437 m": { name: airports_paved_5000_8000ft }
287
+ "914 to 1,523 m": { name: airports_paved_3000_5000ft }
288
+ "under 914 m": { name: airports_paved_under_3000ft }
289
+ Airports - with unpaved runways:
290
+ total: { name: airports_unpaved }
291
+ "1,524 to 2,437 m": { name: airports_unpaved_5000_8000ft }
292
+ "914 to 1,523 m": { name: airports_unpaved_3000_5000ft }
293
+ "under 914 m": { name: airports_unpaved_under_3000ft }
294
+ Heliports: { name: heliports }
295
+ Pipelines: { name: pipelines }
296
+ Railways:
297
+ total: { name: railways }
298
+ standard gauge: { name: railways_standard_gauge }
299
+ narrow gauge: { name: railways_narrow_gauge }
300
+ broad gauge: { name: railways_broad_gauge }
301
+ dual gauge: { name: railways_dual_gauge }
302
+ Roadways:
303
+ total: { name: roadways }
304
+ paved: { name: roadways_paved }
305
+ unpaved: { name: roadways_unpaved }
306
+ note: { name: roadways_note }
307
+ Waterways: { name: waterways }
308
+ Merchant marine:
309
+ total: { name: merchant_marine }
310
+ by type: { name: merchant_marine_by_type }
311
+ foreign-owned: { name: merchant_marine_foreign }
312
+ registered in other countries: { name: merchant_marine_others }
313
+ Ports and terminals:
314
+ major seaport(s): { name: sea_ports }
315
+ river port(s): { name: river_ports }
316
+
317
+ Military:
318
+ Military branches: { name: military_branches }
319
+ Military service age and obligation: { name: military_age }
320
+ Manpower available for military service:
321
+ males age 16-49: { name: military_manpower_males }
322
+ females age 16-49: { name: military_manpower_females }
323
+ Manpower fit for military service:
324
+ males age 16-49: { name: military_manpower_males_fit }
325
+ females age 16-49: { name: military_manpower_females_fit }
326
+ Manpower reaching militarily significant age annually:
327
+ male: { name: military_manpower_male_annual }
328
+ female: { name: military_manpower_female_annual }
329
+ Military expenditures: { name: military_expenditures }
330
+
331
+ Transnational Issues:
332
+ Disputes - international: { name: disputes }
333
+ Refugees and internally displaced persons:
334
+ refugees (country of origin): { name: refugees }
335
+ IDPs: { name: refugees_idps }
336
+ stateless persons: { name: refugess_stateless }
337
+ Illicit drugs: { name: drugs }
@@ -1,4 +1,4 @@
1
- Num,Category,Name,Key
1
+ Num,Category,Name,Notes
2
2
  ,Introduction,Background,
3
3
  ,Geography,Location,
4
4
  ,Geography,Geographic coordinates,
@@ -10,6 +10,7 @@ require 'pp'
10
10
  require 'json'
11
11
  require 'csv'
12
12
  require 'fileutils'
13
+ require 'erb' ## used by Almanac class (for render)
13
14
 
14
15
 
15
16
  ## 3rd party gems/libs
@@ -25,36 +26,50 @@ require 'active_record' ## add activerecord/db support (NOT optional for now
25
26
  # our own code
26
27
 
27
28
  require 'factbook/version' # let it always go first
29
+
30
+
31
+ require 'factbook/codes'
32
+ require 'factbook/comparisons'
33
+ require 'factbook/attributes'
34
+
35
+ module Factbook
36
+
37
+ ## auto-load builtin codes, comparisons, attributes, etc.
38
+ CODES = Codes.from_csv( "#{Factbook.root}/data/codes.csv" )
39
+ COMPARISONS = Comparisons.from_csv( "#{Factbook.root}/data/comparisons.csv" )
40
+ ATTRIBUTES = Attributes.from_yaml( "#{Factbook.root}/data/attributes.yml" )
41
+
42
+ def self.codes() CODES; end
43
+ def self.comparisons() COMPARISONS; end
44
+ def self.attributes() ATTRIBUTES; end
45
+
46
+ end # module Factbook
47
+
48
+ ## note: make codes, comparisons, attributes available
49
+
28
50
  require 'factbook/utils'
29
51
  require 'factbook/utils_info'
30
52
  require 'factbook/sanitizer'
53
+ require 'factbook/normalize'
31
54
  require 'factbook/builder_item'
32
55
  require 'factbook/builder'
56
+ require 'factbook/builder_json'
33
57
  require 'factbook/page'
58
+ require 'factbook/page_info'
34
59
  require 'factbook/sect'
35
60
  require 'factbook/subsect'
36
61
 
37
- require 'factbook/codes'
38
- require 'factbook/comparisons'
62
+ require 'factbook/reader_json'
63
+ require 'factbook/almanac'
39
64
 
40
65
  require 'factbook/table' ## e.g. TableReader
41
66
 
67
+ require 'factbook/counter'
68
+
42
69
  require 'factbook/db/schema' ## database (sql tables) support
43
70
  require 'factbook/db/models'
44
71
  require 'factbook/db/importer'
45
72
 
46
73
 
47
74
 
48
- module Factbook
49
-
50
- ## auto-load builtin codes and comparisons
51
- CODES = Codes.from_csv( "#{Factbook.root}/data/codes.csv" )
52
- COMPARISONS = Comparisons.from_csv( "#{Factbook.root}/data/comparisons.csv")
53
-
54
- def self.codes() CODES; end
55
- def self.comparisons() COMPARISONS; end
56
-
57
- end # module Factbook
58
-
59
-
60
75
  puts Factbook.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG