factbook 1.0.0 → 1.0.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 +4 -4
- data/Manifest.txt +4 -0
- data/README.md +95 -48
- data/data/categories.csv +164 -0
- data/data/codesxref.csv +280 -0
- data/lib/factbook/builder.rb +8 -8
- data/lib/factbook/page.rb +61 -16
- data/lib/factbook/version.rb +1 -1
- data/script/testbr.rb +10 -0
- data/script/testcodes.rb +11 -0
- data/test/test_builder.rb +4 -6
- data/test/test_fields.rb +3 -2
- data/test/test_json.rb +5 -5
- data/test/test_page.rb +2 -8
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9715102d9e477fecc63d0b77e0760c134c349edf
|
4
|
+
data.tar.gz: 26f7ec5f6f517013e96f477682d92b61bfcd3103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 843926700c08da16bb1a7555ed321d187e08cc8403c2855e2c240668462b24d2127622f5cf8d980ca23804cca9a8ef982e910554fab90559d6c776ff97b42217
|
7
|
+
data.tar.gz: 31cf12c0d3e063b84f5be8794b1dcc9ad33ef6bc075bd478a10781c5408feef1766fc83ec6391603eee9eade7ea7d1e1d098ca27c63c90a7364866165d171118
|
data/Manifest.txt
CHANGED
@@ -2,7 +2,9 @@ HISTORY.md
|
|
2
2
|
Manifest.txt
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
|
+
data/categories.csv
|
5
6
|
data/codes.csv
|
7
|
+
data/codesxref.csv
|
6
8
|
data/comparisons.csv
|
7
9
|
lib/factbook.rb
|
8
10
|
lib/factbook/builder.rb
|
@@ -17,6 +19,8 @@ lib/factbook/table.rb
|
|
17
19
|
lib/factbook/utils.rb
|
18
20
|
lib/factbook/utils_info.rb
|
19
21
|
lib/factbook/version.rb
|
22
|
+
script/testbr.rb
|
23
|
+
script/testcodes.rb
|
20
24
|
test/data/au.html
|
21
25
|
test/data/au.yml
|
22
26
|
test/data/be.html
|
data/README.md
CHANGED
@@ -22,80 +22,127 @@ offers free country profiles in the public domain (that is, no copyright(s), no
|
|
22
22
|
### Get country profile page as a hash (that is, structured data e.g. nested key/values)
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
|
26
25
|
page = Factbook::Page.new( 'br' ) # br is the country code for Brazil
|
27
26
|
pp page.data # pretty print hash
|
28
|
-
|
29
27
|
```
|
30
28
|
|
31
|
-
|
29
|
+
resulting in:
|
32
30
|
|
33
31
|
```ruby
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
+
...
|
40
65
|
```
|
41
66
|
|
42
|
-
### Options - Header, "Long" Category / Field Names
|
43
67
|
|
44
|
-
|
68
|
+
### Save to disk as JSON
|
45
69
|
|
46
70
|
```ruby
|
47
|
-
page = Factbook::Page.new( 'br'
|
71
|
+
page = Factbook::Page.new( 'br' )
|
72
|
+
File.open( 'br.json', 'w') do |f|
|
73
|
+
f.write page.to_json
|
74
|
+
end
|
48
75
|
```
|
49
76
|
|
50
|
-
will include a leading header section. Example:
|
51
|
-
|
52
|
-
```json
|
53
|
-
{
|
54
|
-
"Header": {
|
55
|
-
"code": "au",
|
56
|
-
"generator": "factbook/0.1.2",
|
57
|
-
"last_built": "2014-08-24 12:55:39 +0200"
|
58
|
-
}
|
59
|
-
...
|
60
|
-
}
|
61
|
-
```
|
62
77
|
|
63
|
-
|
78
|
+
### Print all codes
|
64
79
|
|
65
80
|
```ruby
|
66
|
-
|
81
|
+
Factbook.codes.each do |code|
|
82
|
+
pp code
|
83
|
+
end
|
67
84
|
```
|
68
85
|
|
69
|
-
|
70
|
-
e.g.
|
86
|
+
resulting in:
|
71
87
|
|
72
88
|
```ruby
|
73
|
-
|
74
|
-
|
75
|
-
|
89
|
+
#<struct Factbook::Codes::Code
|
90
|
+
code="af",
|
91
|
+
name="Afghanistan",
|
92
|
+
category="Countries",
|
93
|
+
region="South Asia">
|
94
|
+
#<struct Factbook::Codes::Code
|
95
|
+
code="al",
|
96
|
+
name="Albania",
|
97
|
+
category="Countries",
|
98
|
+
region="Europe">
|
99
|
+
#<struct Factbook::Codes::Code
|
100
|
+
code="ag",
|
101
|
+
name="Algeria",
|
102
|
+
category="Countries",
|
103
|
+
region="Africa">
|
104
|
+
#<struct Factbook::Codes::Code
|
105
|
+
code="an",
|
106
|
+
name="Andorra",
|
107
|
+
category="Countries",
|
108
|
+
region="Europe">
|
109
|
+
...
|
76
110
|
```
|
77
|
-
becomes
|
78
111
|
|
79
|
-
|
80
|
-
|
81
|
-
page['Economy']['Labor force - by occupation']['agriculture']
|
82
|
-
page['Transportation']['Ports and terminals']['river port(s)']
|
83
|
-
```
|
112
|
+
Note: You can filter codes by category e.g. Countries, Dependencies, Miscellaneous, Oceans, etc.
|
113
|
+
and/or by region e.g. Africa, Europe, South Asia, Central America and Caribbean, etc.
|
84
114
|
|
85
|
-
Note: You can - of course - use the options together e.g.
|
86
115
|
|
87
116
|
```ruby
|
88
|
-
page = Factbook::Page.new( 'br', header: true, fields: 'long' )
|
89
|
-
```
|
90
117
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
118
|
+
assert_equal 261, Factbook.codes.size
|
119
|
+
|
120
|
+
## categories
|
121
|
+
assert_equal 195, Factbook.codes.countries.size
|
122
|
+
assert_equal 52, Factbook.codes.dependencies.size
|
123
|
+
assert_equal 5, Factbook.codes.oceans.size
|
124
|
+
assert_equal 1, Factbook.codes.world.size
|
125
|
+
assert_equal 2, Factbook.codes.others.size
|
126
|
+
assert_equal 6, Factbook.codes.misc.size
|
127
|
+
|
128
|
+
## regions
|
129
|
+
assert_equal 55, Factbook.codes.europe.size
|
130
|
+
assert_equal 9, Factbook.codes.south_asia.size
|
131
|
+
assert_equal 6, Factbook.codes.central_asia.size
|
132
|
+
assert_equal 22, Factbook.codes.east_n_souteast_asia.size
|
133
|
+
assert_equal 19, Factbook.codes.middle_east.size
|
134
|
+
assert_equal 56, Factbook.codes.africa.size
|
135
|
+
assert_equal 7, Factbook.codes.north_america.size
|
136
|
+
assert_equal 33, Factbook.codes.central_america_n_caribbean.size
|
137
|
+
assert_equal 14, Factbook.codes.south_america.size
|
138
|
+
assert_equal 30, Factbook.codes.australia_oceania.size
|
139
|
+
assert_equal 4, Factbook.codes.antartica.size
|
140
|
+
assert_equal 5, Factbook.codes.region('Oceans').size
|
141
|
+
assert_equal 1, Factbook.codes.region('World').size
|
142
|
+
|
143
|
+
## categories + regions
|
144
|
+
assert_equal 45, Factbook.codes.countries.europe.size
|
145
|
+
...
|
99
146
|
```
|
100
147
|
|
101
148
|
|
data/data/categories.csv
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
Num,Category,Name,Key
|
2
|
+
,Introduction,Background,
|
3
|
+
,Geography,Location,
|
4
|
+
,Geography,Geographic coordinates,
|
5
|
+
,Geography,Map references,
|
6
|
+
,Geography,Area,
|
7
|
+
,Geography,Area - comparative,
|
8
|
+
,Geography,Land boundaries,
|
9
|
+
,Geography,Coastline,
|
10
|
+
,Geography,Maritime claims,
|
11
|
+
,Geography,Climate,
|
12
|
+
,Geography,Terrain,
|
13
|
+
,Geography,Elevation extremes,
|
14
|
+
,Geography,Natural resources,
|
15
|
+
,Geography,Land use,
|
16
|
+
,Geography,Irrigated land,
|
17
|
+
,Geography,Total renewable water resources,
|
18
|
+
,Geography,Freshwater withdrawal (domestic/industrial/agricultural),
|
19
|
+
,Geography,Natural hazards,
|
20
|
+
,Geography,Environment - current issues,
|
21
|
+
,Geography,Environment - international agreements,
|
22
|
+
,Geography,Geography - note,
|
23
|
+
,People and Society,Nationality,
|
24
|
+
,People and Society,Ethnic groups,
|
25
|
+
,People and Society,Languages,
|
26
|
+
,People and Society,Religions,
|
27
|
+
,People and Society,Population,
|
28
|
+
,People and Society,Age structure,
|
29
|
+
,People and Society,Dependency ratios,
|
30
|
+
,People and Society,Median age,
|
31
|
+
,People and Society,Population growth rate,
|
32
|
+
,People and Society,Birth rate,
|
33
|
+
,People and Society,Death rate,
|
34
|
+
,People and Society,Net migration rate,
|
35
|
+
,People and Society,Urbanization,
|
36
|
+
,People and Society,Major urban areas - population,
|
37
|
+
,People and Society,Sex ratio,
|
38
|
+
,People and Society,Infant mortality rate,
|
39
|
+
,People and Society,Life expectancy at birth,
|
40
|
+
,People and Society,Total fertility rate,
|
41
|
+
,People and Society,Contraceptive prevalence rate,
|
42
|
+
,People and Society,Health expenditures,
|
43
|
+
,People and Society,Physicians density,
|
44
|
+
,People and Society,Hospital bed density,
|
45
|
+
,People and Society,Drinking water source,
|
46
|
+
,People and Society,Sanitation facility access,
|
47
|
+
,People and Society,HIV/AIDS - adult prevalence rate,
|
48
|
+
,People and Society,HIV/AIDS - people living with HIV/AIDS,
|
49
|
+
,People and Society,HIV/AIDS - deaths,
|
50
|
+
,People and Society,Obesity - adult prevalence rate,
|
51
|
+
,People and Society,Education expenditures,
|
52
|
+
,People and Society,School life expectancy (primary to tertiary education),
|
53
|
+
,People and Society,"Unemployment, youth ages 15-24",
|
54
|
+
,Government,Country name,
|
55
|
+
,Government,Government type,
|
56
|
+
,Government,Capital,
|
57
|
+
,Government,Administrative divisions,
|
58
|
+
,Government,Independence,
|
59
|
+
,Government,National holiday,
|
60
|
+
,Government,Constitution,
|
61
|
+
,Government,Legal system,
|
62
|
+
,Government,International law organization participation,
|
63
|
+
,Government,Suffrage,
|
64
|
+
,Government,Executive branch,
|
65
|
+
,Government,Legislative branch,
|
66
|
+
,Government,Judicial branch,
|
67
|
+
,Government,Political parties and leaders,
|
68
|
+
,Government,Political pressure groups and leaders,
|
69
|
+
,Government,International organization participation,
|
70
|
+
,Government,Diplomatic representation in the US,
|
71
|
+
,Government,Diplomatic representation from the US,
|
72
|
+
,Government,Flag description,
|
73
|
+
,Government,National symbol(s),
|
74
|
+
,Government,National anthem,
|
75
|
+
,Economy,Economy - overview,
|
76
|
+
,Economy,GDP (purchasing power parity),
|
77
|
+
,Economy,GDP (official exchange rate),
|
78
|
+
,Economy,GDP - real growth rate,
|
79
|
+
,Economy,GDP - per capita (PPP),
|
80
|
+
,Economy,Gross national saving,
|
81
|
+
,Economy,"GDP - composition, by end use",
|
82
|
+
,Economy,"GDP - composition, by sector of origin",
|
83
|
+
,Economy,Agriculture - products,
|
84
|
+
,Economy,Industries,
|
85
|
+
,Economy,Industrial production growth rate,
|
86
|
+
,Economy,Labor force,
|
87
|
+
,Economy,Labor force - by occupation,
|
88
|
+
,Economy,Unemployment rate,
|
89
|
+
,Economy,Population below poverty line,
|
90
|
+
,Economy,Household income or consumption by percentage share,
|
91
|
+
,Economy,Distribution of family income - Gini index,
|
92
|
+
,Economy,Budget,
|
93
|
+
,Economy,Taxes and other revenues,
|
94
|
+
,Economy,Budget surplus (+) or deficit (-),
|
95
|
+
,Economy,Public debt,
|
96
|
+
,Economy,Fiscal year,
|
97
|
+
,Economy,Inflation rate (consumer prices),
|
98
|
+
,Economy,Commercial bank prime lending rate,
|
99
|
+
,Economy,Stock of narrow money,
|
100
|
+
,Economy,Stock of broad money,
|
101
|
+
,Economy,Stock of domestic credit,
|
102
|
+
,Economy,Market value of publicly traded shares,
|
103
|
+
,Economy,Current account balance,
|
104
|
+
,Economy,Exports,
|
105
|
+
,Economy,Exports - commodities,
|
106
|
+
,Economy,Exports - partners,
|
107
|
+
,Economy,Imports,
|
108
|
+
,Economy,Imports - commodities,
|
109
|
+
,Economy,Imports - partners,
|
110
|
+
,Economy,Reserves of foreign exchange and gold,
|
111
|
+
,Economy,Debt - external,
|
112
|
+
,Economy,Stock of direct foreign investment - at home,
|
113
|
+
,Economy,Stock of direct foreign investment - abroad,
|
114
|
+
,Economy,Exchange rates,
|
115
|
+
,Energy,Electricity - production,
|
116
|
+
,Energy,Electricity - consumption,
|
117
|
+
,Energy,Electricity - exports,
|
118
|
+
,Energy,Electricity - imports,
|
119
|
+
,Energy,Electricity - installed generating capacity,
|
120
|
+
,Energy,Electricity - from fossil fuels,
|
121
|
+
,Energy,Electricity - from nuclear fuels,
|
122
|
+
,Energy,Electricity - from hydroelectric plants,
|
123
|
+
,Energy,Electricity - from other renewable sources,
|
124
|
+
,Energy,Crude oil - production,
|
125
|
+
,Energy,Crude oil - exports,
|
126
|
+
,Energy,Crude oil - imports,
|
127
|
+
,Energy,Crude oil - proved reserves,
|
128
|
+
,Energy,Refined petroleum products - production,
|
129
|
+
,Energy,Refined petroleum products - consumption,
|
130
|
+
,Energy,Refined petroleum products - exports,
|
131
|
+
,Energy,Refined petroleum products - imports,
|
132
|
+
,Energy,Natural gas - production,
|
133
|
+
,Energy,Natural gas - consumption,
|
134
|
+
,Energy,Natural gas - exports,
|
135
|
+
,Energy,Natural gas - imports,
|
136
|
+
,Energy,Natural gas - proved reserves,
|
137
|
+
,Energy,Carbon dioxide emissions from consumption of energy,
|
138
|
+
,Communications,Telephones - fixed lines,
|
139
|
+
,Communications,Telephones - mobile cellular,
|
140
|
+
,Communications,Telephone system,
|
141
|
+
,Communications,Broadcast media,
|
142
|
+
,Communications,Radio broadcast stations,
|
143
|
+
,Communications,Television broadcast stations,
|
144
|
+
,Communications,Internet country code,
|
145
|
+
,Communications,Internet users,
|
146
|
+
,Transportation,Airports,
|
147
|
+
,Transportation,Airports - with paved runways,
|
148
|
+
,Transportation,Airports - with unpaved runways,
|
149
|
+
,Transportation,Heliports,
|
150
|
+
,Transportation,Pipelines,
|
151
|
+
,Transportation,Railways,
|
152
|
+
,Transportation,Roadways,
|
153
|
+
,Transportation,Waterways,
|
154
|
+
,Transportation,Merchant marine,
|
155
|
+
,Transportation,Ports and terminals,
|
156
|
+
,Military,Military branches,
|
157
|
+
,Military,Military service age and obligation,
|
158
|
+
,Military,Manpower available for military service,
|
159
|
+
,Military,Manpower fit for military service,
|
160
|
+
,Military,Manpower reaching militarily significant age annually,
|
161
|
+
,Military,Military expenditures,
|
162
|
+
,Transnational Issues,Disputes - international,
|
163
|
+
,Transnational Issues,Refugees and internally displaced persons,
|
164
|
+
,Transnational Issues,Illicit drugs,
|
data/data/codesxref.csv
ADDED
@@ -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
|
data/lib/factbook/builder.rb
CHANGED
@@ -18,6 +18,10 @@ end
|
|
18
18
|
|
19
19
|
def self.from_file( path )
|
20
20
|
html_ascii = File.read( path ) ## fix/todo: use ASCII8BIT/binary reader !!!!!
|
21
|
+
self.from_string( html_ascii )
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.from_string( html_ascii ) ## note: expects ASCII-7BIT/BINARY encoding
|
21
25
|
self.new( html_ascii )
|
22
26
|
end
|
23
27
|
|
@@ -27,7 +31,8 @@ attr_reader :html_ascii, ## full "original" 1:1 page in "original/ascii8/bin
|
|
27
31
|
:html_debug, ## html w/ mapping markers - rename to html_markers - why? why not?
|
28
32
|
:page_info, ## incl. country_name, region_name, last_updated etc.
|
29
33
|
:errors, ## encoding erros etc.
|
30
|
-
:
|
34
|
+
:sects
|
35
|
+
|
31
36
|
|
32
37
|
def initialize( html_ascii )
|
33
38
|
@html_ascii = html_ascii
|
@@ -42,8 +47,7 @@ def initialize( html_ascii )
|
|
42
47
|
pp html_sects
|
43
48
|
|
44
49
|
|
45
|
-
|
46
|
-
sects = []
|
50
|
+
@sects = []
|
47
51
|
html_sects.each do |html_sect|
|
48
52
|
html_sect_head = html_sect[0]
|
49
53
|
html_subsects = html_sect[1]
|
@@ -81,15 +85,11 @@ def initialize( html_ascii )
|
|
81
85
|
end
|
82
86
|
end
|
83
87
|
sect.subsects = subsects
|
84
|
-
sects << sect
|
88
|
+
@sects << sect
|
85
89
|
else
|
86
90
|
## warn/fix: no section title found
|
87
91
|
end
|
88
92
|
end
|
89
|
-
page.sects = sects
|
90
|
-
@page = page
|
91
|
-
|
92
|
-
pp page
|
93
93
|
|
94
94
|
self ## return self -- needed?? default (standard) anyway?? check and remove
|
95
95
|
end
|
data/lib/factbook/page.rb
CHANGED
@@ -28,12 +28,47 @@ module Factbook
|
|
28
28
|
class Page
|
29
29
|
include LogUtils::Logging
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
attr_reader :sects ## "structured" access e.g. sects/subsects/etc.
|
32
|
+
attr_reader :data ## "plain" access with vanilla hash
|
33
|
+
|
34
|
+
|
35
|
+
## standard version (note: requires https)
|
36
|
+
SITE_BASE = 'https://www.cia.gov/library/publications/the-world-factbook/geos/{code}.html'
|
37
|
+
|
38
|
+
def initialize( code, opts={} )
|
39
|
+
### keep code - why? why not?? (use page_info/info e.g. info.country_code??)
|
40
|
+
|
41
|
+
if opts[:html] ## note: expects ASCII-7BIT/BINARY encoding
|
42
|
+
## for debugging and testing allow "custom" passed-in html page
|
43
|
+
html = opts[:html]
|
44
|
+
else
|
45
|
+
url_string = SITE_BASE.gsub( '{code}', code )
|
46
|
+
## note: expects ASCII-7BIT/BINARY encoding
|
47
|
+
html = fetch_page( url_string ) ## use PageFetcher class - why?? why not??
|
48
|
+
end
|
49
|
+
|
50
|
+
b = Builder.from_string( html )
|
51
|
+
@sects = b.sects
|
52
|
+
|
53
|
+
@data = {}
|
54
|
+
@sects.each do |sect|
|
55
|
+
@data[ sect.title ] = sect.data
|
56
|
+
end
|
57
|
+
|
58
|
+
self ## return self (check - not needed??)
|
35
59
|
end
|
36
60
|
|
61
|
+
|
62
|
+
def to_json( opts={} ) ## convenience helper for data.to_json; note: pretty print by default!
|
63
|
+
if opts[:minify]
|
64
|
+
data.to_json
|
65
|
+
else
|
66
|
+
## was: -- opts[:pretty] || opts[:pp]
|
67
|
+
JSON.pretty_generate( data ) ## note: pretty print by default!
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
37
72
|
def [](key) ### convenience shortcut
|
38
73
|
# lets you use
|
39
74
|
# page['geo']
|
@@ -45,20 +80,30 @@ class Page
|
|
45
80
|
data[key]
|
46
81
|
end
|
47
82
|
|
48
|
-
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
private
|
84
|
+
def fetch_page( url_string )
|
85
|
+
|
86
|
+
worker = Fetcher::Worker.new
|
87
|
+
response = worker.get_response( url_string )
|
88
|
+
|
89
|
+
if response.code == '200'
|
90
|
+
t = response.body
|
91
|
+
###
|
92
|
+
# NB: Net::HTTP will NOT set encoding UTF-8 etc.
|
93
|
+
# will mostly be ASCII
|
94
|
+
# - try to change encoding to UTF-8 ourselves
|
95
|
+
logger.debug "t.encoding.name (before): #{t.encoding.name}"
|
96
|
+
#####
|
97
|
+
# NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
|
98
|
+
t
|
99
|
+
else
|
100
|
+
logger.error "fetch HTTP - #{response.code} #{response.message}"
|
101
|
+
## todo/fix: raise http exception (see fetcher) -- why? why not??
|
102
|
+
fail "fetch HTTP - #{response.code} #{response.message}"
|
103
|
+
nil
|
58
104
|
end
|
59
|
-
@data
|
60
105
|
end
|
61
|
-
|
106
|
+
|
62
107
|
|
63
108
|
=begin
|
64
109
|
def self.from_url( cc, cn )
|
data/lib/factbook/version.rb
CHANGED
data/script/testbr.rb
ADDED
data/script/testcodes.rb
ADDED
data/test/test_builder.rb
CHANGED
@@ -16,15 +16,13 @@ class TestBuilder < MiniTest::Test
|
|
16
16
|
|
17
17
|
def test_build
|
18
18
|
|
19
|
-
['au','be'].each do |
|
19
|
+
['au','be'].each do |code|
|
20
20
|
## use/fix: ASCII-8BIT (e.g.keep as is) -???
|
21
21
|
## fix/todo: use ASCII8BIT/binary reader ??
|
22
|
-
b = Factbook::Builder.from_file( "#{Factbook.root}/test/data/src/#{
|
22
|
+
b = Factbook::Builder.from_file( "#{Factbook.root}/test/data/src/#{code}.html" )
|
23
|
+
pp b.sects
|
23
24
|
|
24
|
-
|
25
|
-
pp b.page.data
|
26
|
-
|
27
|
-
File.open( "./tmp/#{cc}.debug.html", 'w' ) do |f|
|
25
|
+
File.open( "./tmp/#{code}.debug.html", 'w' ) do |f|
|
28
26
|
f.write b.html_debug
|
29
27
|
end
|
30
28
|
end
|
data/test/test_fields.rb
CHANGED
@@ -10,8 +10,9 @@ require 'helper'
|
|
10
10
|
class TestFields < MiniTest::Test
|
11
11
|
|
12
12
|
def read_test_page( code )
|
13
|
-
|
14
|
-
|
13
|
+
html = File.read( "#{Factbook.root}/test/data/src/#{code}.html" )
|
14
|
+
page = Factbook::Page.new( code, html: html )
|
15
|
+
page
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_fields_full
|
data/test/test_json.rb
CHANGED
@@ -26,9 +26,8 @@ class TestJson < MiniTest::Test
|
|
26
26
|
|
27
27
|
codes.each do |code|
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
page = b.page
|
29
|
+
html = File.read( "#{Factbook.root}/test/data/src/#{code}.html" )
|
30
|
+
page = Factbook::Page.new( code, html: html )
|
32
31
|
|
33
32
|
h = page.data
|
34
33
|
pp h
|
@@ -36,9 +35,10 @@ class TestJson < MiniTest::Test
|
|
36
35
|
### save to json
|
37
36
|
puts "saving a copy to #{code}.json for debugging"
|
38
37
|
File.open( "tmp/#{code}.json", 'w' ) do |f|
|
39
|
-
|
38
|
+
f.write JSON.pretty_generate( h )
|
39
|
+
## f.write page.to_json
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
end # class
|
44
|
+
end # class TestJson
|
data/test/test_page.rb
CHANGED
@@ -27,15 +27,9 @@ class TestPage < MiniTest::Test
|
|
27
27
|
code = rec[0]
|
28
28
|
sects_size = rec[1]
|
29
29
|
|
30
|
-
|
31
|
-
page =
|
30
|
+
html = File.read( "#{Factbook.root}/test/data/src/#{code}.html" )
|
31
|
+
page = Factbook::Page.new( code, html: html )
|
32
32
|
|
33
|
-
## page = Factbook::OldPage.new( code )
|
34
|
-
## page.html = File.read( "#{Factbook.root}/test/data/old/countrytemplate_#{code}.html" )
|
35
|
-
|
36
|
-
## print first 600 chars
|
37
|
-
## pp page.html[0..600]
|
38
|
-
|
39
33
|
assert_equal sects_size, page.sects.size
|
40
34
|
end
|
41
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -94,7 +94,9 @@ files:
|
|
94
94
|
- Manifest.txt
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
+
- data/categories.csv
|
97
98
|
- data/codes.csv
|
99
|
+
- data/codesxref.csv
|
98
100
|
- data/comparisons.csv
|
99
101
|
- lib/factbook.rb
|
100
102
|
- lib/factbook/builder.rb
|
@@ -109,6 +111,8 @@ files:
|
|
109
111
|
- lib/factbook/utils.rb
|
110
112
|
- lib/factbook/utils_info.rb
|
111
113
|
- lib/factbook/version.rb
|
114
|
+
- script/testbr.rb
|
115
|
+
- script/testcodes.rb
|
112
116
|
- test/data/au.html
|
113
117
|
- test/data/au.yml
|
114
118
|
- test/data/be.html
|