factbook-readers 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Manifest.txt +3 -25
- data/README.md +11 -69
- data/Rakefile +3 -3
- data/lib/factbook-readers.rb +5 -40
- data/lib/factbook-readers/convert.rb +37 -0
- data/lib/factbook-readers/counter.rb +7 -9
- data/lib/factbook-readers/page.rb +41 -61
- data/lib/factbook-readers/page_info.rb +15 -3
- data/lib/factbook-readers/version.rb +2 -2
- data/test/helper.rb +3 -0
- data/test/test_counter.rb +9 -6
- data/test/test_download.rb +27 -0
- data/test/test_fields.rb +44 -27
- data/test/test_json.rb +4 -4
- data/test/test_page.rb +8 -8
- data/test/test_version.rb +15 -0
- metadata +11 -48
- data/data/categories.csv +0 -164
- data/data/codes.csv +0 -262
- data/data/codesxref.csv +0 -280
- data/data/comparisons.csv +0 -75
- data/lib/factbook-readers/builder.rb +0 -187
- data/lib/factbook-readers/builder_item.rb +0 -201
- data/lib/factbook-readers/builder_json.rb +0 -68
- data/lib/factbook-readers/codes.rb +0 -121
- data/lib/factbook-readers/comparisons.rb +0 -49
- data/lib/factbook-readers/normalize.rb +0 -42
- data/lib/factbook-readers/reader_json.rb +0 -50
- data/lib/factbook-readers/sanitizer.rb +0 -351
- data/lib/factbook-readers/sect.rb +0 -28
- data/lib/factbook-readers/subsect.rb +0 -17
- data/lib/factbook-readers/table.rb +0 -51
- data/lib/factbook-readers/utils.rb +0 -47
- data/lib/factbook-readers/utils_info.rb +0 -128
- data/test/test_builder.rb +0 -30
- data/test/test_codes.rb +0 -72
- data/test/test_comparisons.rb +0 -16
- data/test/test_item_builder.rb +0 -97
- data/test/test_json_builder.rb +0 -23
- data/test/test_normalize.rb +0 -21
- data/test/test_sanitizer.rb +0 -36
- data/test/test_sanitizer_regex.rb +0 -87
data/test/test_json_builder.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_json_builder.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestJsonBuilder < MiniTest::Test
|
10
|
-
|
11
|
-
def test_read
|
12
|
-
code = 'au'
|
13
|
-
b = Factbook::JsonBuilder.from_file( "#{Factbook.root}/test/data/json/#{code}.json" )
|
14
|
-
|
15
|
-
assert_equal 10, b.sects.size
|
16
|
-
assert_equal 1, b.sects[0].subsects.size ## e.g. Introduction/Background
|
17
|
-
assert_equal 'Central Europe, north of Italy and Slovenia', b.json['Geography']['Location']['text']
|
18
|
-
|
19
|
-
assert true ## assume everthing ok
|
20
|
-
end
|
21
|
-
|
22
|
-
end # class TestJsonBuilder
|
23
|
-
|
data/test/test_normalize.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_normalize.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestNormalizer < MiniTest::Test
|
10
|
-
|
11
|
-
include Factbook::NormalizeHelper
|
12
|
-
|
13
|
-
def test_normalize
|
14
|
-
assert_equal 'border countries', normalize_category( 'border countries:' )
|
15
|
-
assert_equal 'border countries', normalize_category( 'border countries: ' )
|
16
|
-
assert_equal 'border countries', normalize_category( 'border countries (8):' )
|
17
|
-
assert_equal 'border countries', normalize_category( 'border countries (10): ' )
|
18
|
-
end
|
19
|
-
|
20
|
-
end # class TestNormalizer
|
21
|
-
|
data/test/test_sanitizer.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_sanitizer.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestSanitizer < MiniTest::Test
|
10
|
-
|
11
|
-
def test_sanitize
|
12
|
-
|
13
|
-
## austria (au)
|
14
|
-
## algeria (ag)
|
15
|
-
## belgium (be)
|
16
|
-
## ['au'].each do |cnty|
|
17
|
-
['au','ag','be'].each do |cnty|
|
18
|
-
|
19
|
-
html_original = File.read( "#{Factbook.root}/test/data/src/#{cnty}.html", 'r:utf-8' ) { |f| r.read }
|
20
|
-
|
21
|
-
html, info, errors = Factbook::Sanitizer.new.sanitize( html_original )
|
22
|
-
|
23
|
-
File.open( "./tmp/#{cnty}.profile.html", 'w' ) do |f|
|
24
|
-
f.write "** info:\n"
|
25
|
-
f.write info.inspect + "\n\n"
|
26
|
-
f.write "** errors:\n"
|
27
|
-
f.write errors.inspect + "\n\n"
|
28
|
-
f.write "** html:\n"
|
29
|
-
f.write html
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
assert true ## assume everthing ok
|
34
|
-
end
|
35
|
-
|
36
|
-
end # class TestSanitizer
|
@@ -1,87 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_sanitizer_regex.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestSanitizerRegex < MiniTest::Test
|
10
|
-
|
11
|
-
def test_area_map
|
12
|
-
|
13
|
-
html =<<HTML
|
14
|
-
<div class='disTable areaComp'>
|
15
|
-
<span class='category tCell' style='margin-bottom:0px; vertical-align:bottom;'>Area comparison map:</span>
|
16
|
-
<span class="tCell"><a data-toggle="modal" href="#areaCompModal"><img src="../graphics/areacomparison_icon.jpg" border="0" style="cursor:pointer; border: 0px solid #CCC;"></a></span></div>
|
17
|
-
|
18
|
-
<div class="modal fade" id="areaCompModal" role="dialog">
|
19
|
-
<div class="wfb-modal-dialog">
|
20
|
-
<div class="modal-content" >
|
21
|
-
<div class="wfb-modal-header" style="border-radius: 4px; font-family: Verdana,Arial,sans-serif; font-size: 14px !important; font-weight: bold; padding: 0.4em 16px 0.4em 1em; background: #cccccc url("..images/ui-bg_highlight-soft_75_cccccc_1x100.png") repeat-x scroll 50% 50%;" >
|
22
|
-
<span style="font-size: 14px !important; margin: 0.1em 16px 0.1em 0;" class="modal-title wfb-title">The World Factbook</span><span style="float: right; margin-top: -4px;">
|
23
|
-
<button type="button" class="close" title="close" data-dismiss="modal">×</button></span>
|
24
|
-
</div>
|
25
|
-
<div class="wfb-modal-body">
|
26
|
-
...
|
27
|
-
<div id='field'
|
28
|
-
HTML
|
29
|
-
|
30
|
-
m = Factbook::Sanitizer::AREA_COMP_CATEGORY_REGEX.match( html )
|
31
|
-
pp m
|
32
|
-
|
33
|
-
assert m.nil? == false
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def test_pop_pyramid
|
38
|
-
|
39
|
-
html =<<HTML
|
40
|
-
<div class='disTable popPyramid'>
|
41
|
-
<span class='category tCell' style='margin-bottom:0px; vertical-align:bottom;'>population pyramid:</span>
|
42
|
-
<span class="tCell"><a data-toggle="modal" href="#popPyramidModal"><img title="" src="../graphics/poppyramid_icon.jpg" style="cursor:pointer; border: 0px solid #CCC;"></span></a></div>
|
43
|
-
|
44
|
-
<div class="modal fade" id="popPyramidModal" role="dialog">
|
45
|
-
<div class="wfb-modal-dialog">
|
46
|
-
<div class="modal-content" >
|
47
|
-
<div class="wfb-modal-header" style="border-radius: 4px; font-family: Verdana,Arial,sans-serif; font-size: 14px !important; font-weight: bold; padding: 0.4em 16px 0.4em 1em; background: #cccccc url("..images/ui-bg_highlight-soft_75_cccccc_1x100.png") repeat-x scroll 50% 50%;" >
|
48
|
-
<span style="font-size: 14px !important; margin: 0.1em 16px 0.1em 0;" class="modal-title wfb-title">The World Factbook</span><span style="float: right; margin-top: -4px;">
|
49
|
-
<button type="button" class="close" title="close" data-dismiss="modal">×</button></span>
|
50
|
-
</div>
|
51
|
-
<div class="wfb-modal-body">
|
52
|
-
...
|
53
|
-
<div id='field'
|
54
|
-
HTML
|
55
|
-
|
56
|
-
m = Factbook::Sanitizer::POP_PYRAMID_CATEGORY_REGEX.match( html )
|
57
|
-
pp m
|
58
|
-
|
59
|
-
assert m.nil? == false
|
60
|
-
end # method test_pop_pyramid
|
61
|
-
|
62
|
-
|
63
|
-
def test_rel_affiliation
|
64
|
-
|
65
|
-
html =<<HTML
|
66
|
-
<div class='disTable relAffiliation'><span class='category tCell' style='margin-bottom:0px; vertical-align:bottom;'>religious affiliation:</span>
|
67
|
-
<span class="tCell"><a data-toggle="modal" href="#relAffiliationModal"><img title="" src="../graphics/middle-east-religion-icon.jpg" style="cursor:pointer; border: 0px solid #CCC;"></span></a></div>
|
68
|
-
|
69
|
-
<div class="modal fade" id="relAffiliationModal" role="dialog">
|
70
|
-
<div class="wfb-modal-dialog">
|
71
|
-
<div class="modal-content" >
|
72
|
-
<div class="wfb-modal-header" style="border-radius: 4px; font-family: Verdana,Arial,sans-serif; font-size: 14px !important; font-weight: bold; padding: 0.4em 16px 0.4em 1em; background: #cccccc url("..images/ui-bg_highlight-soft_75_cccccc_1x100.png") repeat-x scroll 50% 50%;" >
|
73
|
-
<span style="font-size: 14px !important; margin: 0.1em 16px 0.1em 0;" class="modal-title wfb-title">The World Factbook</span><span style="float: right; margin-top: -4px;">
|
74
|
-
<button type="button" class="close" title="close" data-dismiss="modal">×</button></span>
|
75
|
-
</div>
|
76
|
-
<div class="wfb-modal-body">
|
77
|
-
...
|
78
|
-
<div id='field'
|
79
|
-
HTML
|
80
|
-
|
81
|
-
m = Factbook::Sanitizer::REL_AFFILIATION_CATEGORY_REGEX.match( html )
|
82
|
-
pp m
|
83
|
-
|
84
|
-
assert m.nil? == false
|
85
|
-
end # method test_rel_affiliation
|
86
|
-
|
87
|
-
end # class TestSanitizerRegex
|