factbook 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +18 -0
- data/README.md +7 -0
- data/data/attributes.yml +337 -0
- data/data/categories.csv +1 -1
- data/lib/factbook.rb +29 -14
- data/lib/factbook/almanac.rb +72 -0
- data/lib/factbook/attributes.rb +74 -0
- data/lib/factbook/builder.rb +2 -2
- data/lib/factbook/builder_item.rb +7 -8
- data/lib/factbook/builder_json.rb +79 -0
- data/lib/factbook/counter.rb +48 -0
- data/lib/factbook/normalize.rb +43 -0
- data/lib/factbook/page.rb +37 -45
- data/lib/factbook/page_info.rb +12 -0
- data/lib/factbook/reader_json.rb +51 -0
- data/lib/factbook/sanitizer.rb +0 -7
- data/lib/factbook/version.rb +1 -1
- data/script/almanac.rb +48 -0
- data/script/attributes.rb +34 -0
- data/script/build.rb +28 -0
- data/script/counter.rb +145 -0
- data/script/json.rb +18 -0
- data/test/data/json/au.json +892 -0
- data/test/test_attribs.rb +33 -2
- data/test/test_attribs_def.rb +20 -0
- data/test/test_counter.rb +31 -0
- data/test/test_json_builder.rb +25 -0
- data/test/test_normalize.rb +23 -0
- metadata +20 -2
data/test/test_attribs.rb
CHANGED
@@ -15,9 +15,29 @@ class TestAttribs < MiniTest::Test
|
|
15
15
|
page
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
18
|
+
def read_test_page_from_json( code )
|
19
|
+
json = File.read( "#{Factbook.root}/test/data/json/#{code}.json" )
|
20
|
+
page = Factbook::Page.new( code, json: json )
|
21
|
+
page
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def test_au_from_html
|
26
|
+
page = read_test_page( 'au' ) # note: use builtin test page (do NOT fetch via internet)
|
27
|
+
|
28
|
+
assert_page_au( page )
|
29
|
+
end
|
20
30
|
|
31
|
+
def xxx_test_au_from_json
|
32
|
+
|
33
|
+
## todo/fix: check some issue with newlines? when comparing background or something ???
|
34
|
+
page = read_test_page_from_json( 'au' )
|
35
|
+
|
36
|
+
assert_page_au( page )
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def assert_page_au( page )
|
21
41
|
########
|
22
42
|
## Introduction
|
23
43
|
assert_equal page.background, "Once the center of power for the large Austro-Hungarian Empire, Austria was reduced to a small republic after its defeat in World War I. Following annexation by Nazi Germany in 1938 and subsequent occupation by the victorious Allies in 1945, Austria's status remained unclear for a decade. A State Treaty signed in 1955 ended the occupation, recognized Austria's independence, and forbade unification with Germany. A constitutional law that same year declared the country's \"perpetual neutrality\" as a condition for Soviet military withdrawal. The Soviet Union's collapse in 1991 and Austria's entry into the European Union in 1995 have altered the meaning of this neutrality. A prosperous, democratic country, Austria entered the EU Economic and Monetary Union in 1999."
|
@@ -46,6 +66,17 @@ class TestAttribs < MiniTest::Test
|
|
46
66
|
assert_equal page.migration_rate, "5.56 migrant(s)/1,000 population (2015 est.)"
|
47
67
|
assert_equal page.major_cities, "VIENNA (capital) 1.753 million (2015)"
|
48
68
|
|
69
|
+
|
70
|
+
####################
|
71
|
+
## Economy
|
72
|
+
assert_equal page.economy_overview, "Austria, with its well-developed market economy, skilled labor force, and high standard of living, is closely tied to other EU economies, especially Germany's. Its economy features a large service sector, a relatively sound industrial sector, and a small, but highly developed agricultural sector. Economic growth was anemic at less than 0.5% in 2013 and 2014, and growth in 2015 is not expected to exceed 0.5%. Austria’s 5.6% unemployment rate, while low by European standards, is at an historic high for Austria. Without extensive vocational training programs and generous early retirement, the unemployment rate would be even higher. Public finances have not stabilized even after a 2012 austerity package of expenditure cuts and new revenues. On the contrary, in 2014, the government created a “bad bank” for the troubled nationalized “Hypo Alpe Adria” bank, pushing the budget deficit up by 0.9% of GDP to 2.4% and public debt to 84.5% of the GDP. Although Austria's fiscal position compares favorably with other euro-zone countries, it faces several external risks, such as Austrian banks' continued exposure to Central and Eastern Europe, repercussions from the Hypo Alpe Adria bank collapse, political and economic uncertainties caused by the European sovereign debt crisis, the current crisis in Russia/Ukraine, the recent appreciation of the Swiss Franc, and political developments in Hungary."
|
73
|
+
assert_equal page.gdp_ppp, "$395.5 billion (2014 est.) ++ $394.1 billion (2013 est.) ++ $393.3 billion (2012 est.)"
|
74
|
+
assert_equal page.gdp_ppp_note, "data are in 2014 US dollars"
|
75
|
+
assert_equal page.gdp, "$437.1 billion (2014 est.)"
|
76
|
+
assert_equal page.gdp_growth, "0.3% (2014 est.) ++ 0.2% (2013 est.) ++ 0.9% (2012 est.)"
|
77
|
+
assert_equal page.gdp_ppp_capita, "$46,400 (2014 est.) ++ $46,300 (2013 est.) ++ $46,200 (2012 est.)"
|
78
|
+
assert_equal page.gdp_ppp_capita_note, "data are in 2014 US dollars"
|
79
|
+
assert_equal page.saving, "25% of GDP (2014 est.) ++ 23.9% of GDP (2013 est.) ++ 26.3% of GDP (2012 est.)"
|
49
80
|
end
|
50
81
|
|
51
82
|
end # class TestAttribs
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_attribs_def.rb
|
6
|
+
|
7
|
+
require 'helper'
|
8
|
+
|
9
|
+
|
10
|
+
class TestAttribsDef < MiniTest::Test
|
11
|
+
|
12
|
+
def test_attribs
|
13
|
+
|
14
|
+
attribs = Factbook.attributes
|
15
|
+
pp attribs
|
16
|
+
|
17
|
+
assert true
|
18
|
+
end
|
19
|
+
|
20
|
+
end # class TestAttribsDef
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_counter.rb
|
6
|
+
|
7
|
+
require 'helper'
|
8
|
+
|
9
|
+
|
10
|
+
class TestCounter < MiniTest::Test
|
11
|
+
|
12
|
+
def read_test_page( code )
|
13
|
+
html = File.read( "#{Factbook.root}/test/data/src/#{code}.html" )
|
14
|
+
page = Factbook::Page.new( code, html: html )
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_counter
|
18
|
+
c = Factbook::Counter.new
|
19
|
+
|
20
|
+
codes = %w(au be)
|
21
|
+
codes.each do |code|
|
22
|
+
c.count( read_test_page( code )) # use builtin test page (do NOT fetch via internet)
|
23
|
+
end
|
24
|
+
|
25
|
+
h = c.data
|
26
|
+
pp h
|
27
|
+
|
28
|
+
assert true ## assume everything ok if we get here
|
29
|
+
end
|
30
|
+
|
31
|
+
end # class TestCounter
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_json_builder.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestJsonBuilder < MiniTest::Test
|
12
|
+
|
13
|
+
def test_read
|
14
|
+
code = 'au'
|
15
|
+
b = Factbook::JsonBuilder.from_file( "#{Factbook.root}/test/data/json/#{code}.json" )
|
16
|
+
|
17
|
+
assert_equal 10, b.sects.size
|
18
|
+
assert_equal 1, b.sects[0].subsects.size ## e.g. Introduction/Background
|
19
|
+
assert_equal 'Central Europe, north of Italy and Slovenia', b.json['Geography']['Location']['text']
|
20
|
+
|
21
|
+
assert true ## assume everthing ok
|
22
|
+
end
|
23
|
+
|
24
|
+
end # class TestJsonBuilder
|
25
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_normalize.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestNormalizer < MiniTest::Test
|
12
|
+
|
13
|
+
include Factbook::NormalizeHelper
|
14
|
+
|
15
|
+
def test_normalize
|
16
|
+
assert_equal 'border countries', normalize_category( 'border countries:' )
|
17
|
+
assert_equal 'border countries', normalize_category( 'border countries: ' )
|
18
|
+
assert_equal 'border countries', normalize_category( 'border countries (8):' )
|
19
|
+
assert_equal 'border countries', normalize_category( 'border countries (10): ' )
|
20
|
+
end
|
21
|
+
|
22
|
+
end # class TestNormalizer
|
23
|
+
|
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.1.
|
4
|
+
version: 1.1.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-11-
|
11
|
+
date: 2015-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -108,19 +108,27 @@ files:
|
|
108
108
|
- Manifest.txt
|
109
109
|
- README.md
|
110
110
|
- Rakefile
|
111
|
+
- data/attributes.yml
|
111
112
|
- data/categories.csv
|
112
113
|
- data/codes.csv
|
113
114
|
- data/codesxref.csv
|
114
115
|
- data/comparisons.csv
|
115
116
|
- lib/factbook.rb
|
117
|
+
- lib/factbook/almanac.rb
|
118
|
+
- lib/factbook/attributes.rb
|
116
119
|
- lib/factbook/builder.rb
|
117
120
|
- lib/factbook/builder_item.rb
|
121
|
+
- lib/factbook/builder_json.rb
|
118
122
|
- lib/factbook/codes.rb
|
119
123
|
- lib/factbook/comparisons.rb
|
124
|
+
- lib/factbook/counter.rb
|
120
125
|
- lib/factbook/db/importer.rb
|
121
126
|
- lib/factbook/db/models.rb
|
122
127
|
- lib/factbook/db/schema.rb
|
128
|
+
- lib/factbook/normalize.rb
|
123
129
|
- lib/factbook/page.rb
|
130
|
+
- lib/factbook/page_info.rb
|
131
|
+
- lib/factbook/reader_json.rb
|
124
132
|
- lib/factbook/sanitizer.rb
|
125
133
|
- lib/factbook/sect.rb
|
126
134
|
- lib/factbook/subsect.rb
|
@@ -128,24 +136,34 @@ files:
|
|
128
136
|
- lib/factbook/utils.rb
|
129
137
|
- lib/factbook/utils_info.rb
|
130
138
|
- lib/factbook/version.rb
|
139
|
+
- script/almanac.rb
|
140
|
+
- script/attributes.rb
|
141
|
+
- script/build.rb
|
142
|
+
- script/counter.rb
|
143
|
+
- script/json.rb
|
131
144
|
- script/testbr.rb
|
132
145
|
- script/testcodes.rb
|
133
146
|
- test/data/au.html
|
134
147
|
- test/data/au.yml
|
135
148
|
- test/data/be.html
|
136
149
|
- test/data/be.yml
|
150
|
+
- test/data/json/au.json
|
137
151
|
- test/data/src/au.html
|
138
152
|
- test/data/src/be.html
|
139
153
|
- test/helper.rb
|
140
154
|
- test/test_attribs.rb
|
155
|
+
- test/test_attribs_def.rb
|
141
156
|
- test/test_builder.rb
|
142
157
|
- test/test_codes.rb
|
143
158
|
- test/test_comparisons.rb
|
144
159
|
- test/test_convert.rb
|
160
|
+
- test/test_counter.rb
|
145
161
|
- test/test_fields.rb
|
146
162
|
- test/test_importer.rb
|
147
163
|
- test/test_item_builder.rb
|
148
164
|
- test/test_json.rb
|
165
|
+
- test/test_json_builder.rb
|
166
|
+
- test/test_normalize.rb
|
149
167
|
- test/test_page.rb
|
150
168
|
- test/test_sanitizer.rb
|
151
169
|
homepage: https://github.com/worlddb/factbook
|