webgen 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3662 -0
- data/Rakefile +8 -1
- data/VERSION +1 -1
- data/data/webgen/website_styles/1024px/src/default.template +1 -1
- data/data/webgen/website_styles/andreas00/src/default.template +1 -1
- data/data/webgen/website_styles/andreas01/src/default.template +2 -1
- data/data/webgen/website_styles/andreas03/src/default.template +1 -1
- data/data/webgen/website_styles/andreas04/src/default.template +1 -1
- data/data/webgen/website_styles/andreas05/src/default.template +1 -1
- data/data/webgen/website_styles/andreas06/src/default.template +1 -1
- data/data/webgen/website_styles/andreas07/src/default.template +1 -1
- data/data/webgen/website_styles/andreas08/src/default.template +1 -1
- data/data/webgen/website_styles/andreas09/src/default.template +1 -1
- data/data/webgen/website_styles/simple/src/default.template +1 -1
- data/doc/contentprocessor/fragments.page +25 -0
- data/doc/extensions.page +1 -1
- data/doc/manual.page +33 -15
- data/doc/reference_configuration.page +339 -62
- data/doc/reference_metainfo.page +11 -2
- data/doc/sourcehandler/feed.page +19 -4
- data/doc/sourcehandler/page.page +0 -16
- data/doc/tag/langbar.page +8 -1
- data/doc/tag/link.page +44 -0
- data/doc/tag/tikz.page +158 -0
- data/lib/webgen/cli.rb +4 -4
- data/lib/webgen/common/sitemap.rb +2 -3
- data/lib/webgen/configuration.rb +3 -1
- data/lib/webgen/contentprocessor.rb +1 -0
- data/lib/webgen/contentprocessor/blocks.rb +0 -2
- data/lib/webgen/contentprocessor/context.rb +0 -3
- data/lib/webgen/contentprocessor/erubis.rb +0 -2
- data/lib/webgen/contentprocessor/fragments.rb +23 -0
- data/lib/webgen/default_config.rb +15 -2
- data/lib/webgen/languages.rb +9 -0
- data/lib/webgen/logger.rb +18 -1
- data/lib/webgen/node.rb +50 -25
- data/lib/webgen/page.rb +26 -16
- data/lib/webgen/path.rb +20 -10
- data/lib/webgen/sourcehandler.rb +85 -69
- data/lib/webgen/sourcehandler/base.rb +38 -15
- data/lib/webgen/sourcehandler/copy.rb +2 -2
- data/lib/webgen/sourcehandler/directory.rb +16 -13
- data/lib/webgen/sourcehandler/feed.rb +6 -12
- data/lib/webgen/sourcehandler/fragment.rb +6 -11
- data/lib/webgen/sourcehandler/memory.rb +41 -0
- data/lib/webgen/sourcehandler/metainfo.rb +21 -21
- data/lib/webgen/sourcehandler/page.rb +7 -27
- data/lib/webgen/sourcehandler/sitemap.rb +0 -2
- data/lib/webgen/sourcehandler/template.rb +0 -4
- data/lib/webgen/sourcehandler/virtual.rb +18 -18
- data/lib/webgen/tag.rb +2 -0
- data/lib/webgen/tag/breadcrumbtrail.rb +1 -4
- data/lib/webgen/tag/coderay.rb +0 -3
- data/lib/webgen/tag/date.rb +0 -2
- data/lib/webgen/tag/executecommand.rb +1 -2
- data/lib/webgen/tag/includefile.rb +1 -3
- data/lib/webgen/tag/langbar.rb +2 -5
- data/lib/webgen/tag/link.rb +23 -0
- data/lib/webgen/tag/menu.rb +1 -4
- data/lib/webgen/tag/metainfo.rb +0 -2
- data/lib/webgen/tag/relocatable.rb +2 -3
- data/lib/webgen/tag/sitemap.rb +0 -3
- data/lib/webgen/tag/tikz.rb +117 -0
- data/lib/webgen/tree.rb +11 -6
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +2 -1
- data/test/test_cli.rb +14 -0
- data/test/test_common_sitemap.rb +4 -4
- data/test/test_contentprocessor_context.rb +1 -1
- data/test/test_contentprocessor_fragments.rb +40 -0
- data/test/test_contentprocessor_redcloth.rb +1 -0
- data/test/test_contentprocessor_tags.rb +1 -1
- data/test/test_languages.rb +12 -0
- data/test/test_logger.rb +19 -0
- data/test/test_node.rb +35 -15
- data/test/test_output_filesystem.rb +1 -1
- data/test/test_page.rb +15 -6
- data/test/test_path.rb +37 -5
- data/test/test_source_filesystem.rb +1 -1
- data/test/test_source_stacked.rb +1 -1
- data/test/test_sourcehandler_base.rb +30 -1
- data/test/test_sourcehandler_copy.rb +1 -1
- data/test/test_sourcehandler_directory.rb +16 -1
- data/test/test_sourcehandler_feed.rb +9 -8
- data/test/test_sourcehandler_fragment.rb +1 -1
- data/test/test_sourcehandler_memory.rb +42 -0
- data/test/test_sourcehandler_metainfo.rb +23 -21
- data/test/test_sourcehandler_page.rb +5 -12
- data/test/test_sourcehandler_template.rb +1 -1
- data/test/test_sourcehandler_virtual.rb +2 -2
- data/test/test_tag_base.rb +0 -1
- data/test/test_tag_breadcrumbtrail.rb +4 -4
- data/test/test_tag_includefile.rb +3 -3
- data/test/test_tag_langbar.rb +12 -7
- data/test/test_tag_link.rb +61 -0
- data/test/test_tag_menu.rb +7 -7
- data/test/test_tag_metainfo.rb +1 -1
- data/test/test_tag_relocatable.rb +1 -1
- data/test/test_tag_tikz.rb +66 -0
- data/test/test_tree.rb +8 -9
- metadata +15 -2
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'test/helper'
|
3
|
+
require 'webgen/page'
|
4
|
+
require 'webgen/tree'
|
5
|
+
require 'webgen/contentprocessor'
|
6
|
+
|
7
|
+
class TestContentProcessorFragments < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
11
|
+
def test_process
|
12
|
+
Webgen::SourceHandler::Main.new
|
13
|
+
@website.blackboard.del_service(:source_paths)
|
14
|
+
@website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/')) }
|
15
|
+
|
16
|
+
obj = Webgen::ContentProcessor::Fragments.new
|
17
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
18
|
+
root.node_info[:src] = '/'
|
19
|
+
processors = { 'fragments' => obj }
|
20
|
+
|
21
|
+
context = Webgen::ContentProcessor::Context.new(:chain => [root], :processors => processors)
|
22
|
+
context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
|
23
|
+
obj.call(context)
|
24
|
+
assert(root.tree['/#test'])
|
25
|
+
assert_equal(3, root.tree.node_access[:alcn].length)
|
26
|
+
root.tree.delete_node('/#test')
|
27
|
+
|
28
|
+
context[:block] = Webgen::Block.new('content', '', {})
|
29
|
+
obj.call(context)
|
30
|
+
assert(root.tree['/#test'])
|
31
|
+
assert_equal(3, root.tree.node_access[:alcn].length)
|
32
|
+
root.tree.delete_node('/#test')
|
33
|
+
|
34
|
+
context[:block] = Webgen::Block.new('other', '', {})
|
35
|
+
obj.call(context)
|
36
|
+
assert(!root.tree['/#test'])
|
37
|
+
assert_equal(2, root.tree.node_access[:alcn].length)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/test/test_languages.rb
CHANGED
@@ -50,4 +50,16 @@ class TestLanguages < Test::Unit::TestCase
|
|
50
50
|
assert_equal(-1, ace <=> eng)
|
51
51
|
end
|
52
52
|
|
53
|
+
def test_hashing
|
54
|
+
de = Webgen::LanguageManager.language_for_code('ger')
|
55
|
+
en = Webgen::LanguageManager.language_for_code('en')
|
56
|
+
h = {'de' => de, en => en}
|
57
|
+
assert_equal(de, h[de])
|
58
|
+
assert_equal(de, h['de'])
|
59
|
+
assert_equal(en, h[en])
|
60
|
+
assert_not_equal(en, h['en']) # bc 'en'.eql?(en) is false
|
61
|
+
assert_equal(Webgen::LanguageManager.language_for_code('en'),
|
62
|
+
Webgen::LanguageManager.language_for_code(en))
|
63
|
+
end
|
64
|
+
|
53
65
|
end
|
data/test/test_logger.rb
CHANGED
@@ -70,4 +70,23 @@ class TestLogger < Test::Unit::TestCase
|
|
70
70
|
assert_equal("ERROR -- hallo\n", l.log_output)
|
71
71
|
end
|
72
72
|
|
73
|
+
def test_run_marks
|
74
|
+
l = Webgen::Logger.new(io = StringIO.new, true)
|
75
|
+
l.mark_new_cycle
|
76
|
+
l.error { 'hallo' }
|
77
|
+
assert_equal("", l.log_output)
|
78
|
+
|
79
|
+
l = Webgen::Logger.new(io = StringIO.new, false)
|
80
|
+
l.error { 'hallo' }
|
81
|
+
l.mark_new_cycle
|
82
|
+
l.error { 'other' }
|
83
|
+
l.mark_new_cycle
|
84
|
+
assert_equal("ERROR -- hallo\n INFO -- Log messages for run 1 are following\n" +
|
85
|
+
"ERROR -- other\n INFO -- Log messages for run 2 are following\n", l.log_output)
|
86
|
+
|
87
|
+
l = Webgen::Logger.new(io = StringIO.new, false)
|
88
|
+
l.mark_new_cycle
|
89
|
+
assert_equal("", l.log_output)
|
90
|
+
end
|
91
|
+
|
73
92
|
end
|
data/test/test_node.rb
CHANGED
@@ -31,7 +31,7 @@ class TestNode < Test::Unit::TestCase
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def test_initialize_and_reinit
|
35
35
|
check_proc = proc do |node, parent, path, cn, lcn, alcn, lang, mi|
|
36
36
|
assert_equal(parent, node.parent)
|
37
37
|
assert_equal(path, node.path)
|
@@ -39,8 +39,9 @@ class TestNode < Test::Unit::TestCase
|
|
39
39
|
assert_equal(lcn, node.lcn)
|
40
40
|
assert_equal(alcn, node.absolute_lcn)
|
41
41
|
assert_equal(lang, node.lang)
|
42
|
-
|
43
|
-
assert(node.
|
42
|
+
assert_kind_of(Webgen::Language, node.lang) if node.lang
|
43
|
+
assert(node.flagged(:dirty))
|
44
|
+
assert(node.flagged(:created))
|
44
45
|
assert_equal(mi, node.meta_info)
|
45
46
|
assert_equal({:used_nodes => Set.new, :used_meta_info_nodes => Set.new}, node.node_info)
|
46
47
|
mi.each {|k,v| assert_equal(v, node[k])}
|
@@ -55,9 +56,13 @@ class TestNode < Test::Unit::TestCase
|
|
55
56
|
|
56
57
|
['http://webgen.rubyforge.org', 'c:\\test'].each_with_index do |abspath, index|
|
57
58
|
cn = 'test' + index.to_s + '.html'
|
58
|
-
|
59
|
-
check_proc.call(
|
59
|
+
c = Webgen::Node.new(node, abspath, cn)
|
60
|
+
check_proc.call(c, node, abspath, cn, cn, '/test/' + cn, nil, {})
|
60
61
|
end
|
62
|
+
|
63
|
+
child.reinit('somename.en.html', {'lang' => 'de', 'title' => 'test'})
|
64
|
+
check_proc.call(child, node, 'somename.en.html', 'somename.page', 'somename.de.page',
|
65
|
+
'/test/somename.de.page', 'de', {'title' => 'test'})
|
61
66
|
end
|
62
67
|
|
63
68
|
def test_type_checkers
|
@@ -77,6 +82,22 @@ class TestNode < Test::Unit::TestCase
|
|
77
82
|
assert_equal(:value, node[:other])
|
78
83
|
end
|
79
84
|
|
85
|
+
def test_flags
|
86
|
+
node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
87
|
+
assert(node.flagged(:created))
|
88
|
+
assert(node.flagged(:dirty))
|
89
|
+
node.unflag(:dirty)
|
90
|
+
assert(!node.flagged(:dirty))
|
91
|
+
node.flag(:a, :b, :c)
|
92
|
+
assert(node.flagged(:a))
|
93
|
+
assert(node.flagged(:b))
|
94
|
+
assert(node.flagged(:c))
|
95
|
+
node.unflag(:a, :b, :c)
|
96
|
+
assert(!node.flagged(:a))
|
97
|
+
assert(!node.flagged(:b))
|
98
|
+
assert(!node.flagged(:c))
|
99
|
+
end
|
100
|
+
|
80
101
|
def test_in_lang
|
81
102
|
nodes = create_default_nodes
|
82
103
|
|
@@ -143,16 +164,16 @@ class TestNode < Test::Unit::TestCase
|
|
143
164
|
|
144
165
|
def test_changed
|
145
166
|
node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|
146
|
-
node.dirty
|
167
|
+
node.unflag(:dirty, :created)
|
147
168
|
|
148
169
|
calls = 0
|
149
|
-
@website.blackboard.add_listener(:node_changed?) {|n| assert(node, n); node.dirty
|
170
|
+
@website.blackboard.add_listener(:node_changed?) {|n| assert(node, n); node.flag(:dirty); calls += 1}
|
150
171
|
node.changed?
|
151
172
|
assert_equal(1, calls)
|
152
173
|
node.changed?
|
153
174
|
assert_equal(1, calls)
|
154
175
|
|
155
|
-
node.dirty
|
176
|
+
node.unflag(:dirty)
|
156
177
|
node.node_info[:used_nodes] << node.absolute_lcn
|
157
178
|
node.node_info[:used_nodes] << 'unknown alcn'
|
158
179
|
node.node_info[:used_nodes] << @tree.dummy_root.absolute_lcn
|
@@ -161,8 +182,8 @@ class TestNode < Test::Unit::TestCase
|
|
161
182
|
|
162
183
|
# Test circular depdendence
|
163
184
|
other_node = Webgen::Node.new(@tree.dummy_root, '/other', 'test.l', {'lang' => 'de', :test => :value})
|
164
|
-
other_node.dirty
|
165
|
-
node.dirty
|
185
|
+
other_node.flag(:dirty, :created)
|
186
|
+
node.flag(:dirty)
|
166
187
|
other_node.node_info[:used_nodes] = [node.absolute_lcn]
|
167
188
|
node.node_info[:used_nodes] = [other_node.absolute_lcn]
|
168
189
|
node.changed?
|
@@ -170,21 +191,20 @@ class TestNode < Test::Unit::TestCase
|
|
170
191
|
|
171
192
|
def test_meta_info_changed
|
172
193
|
node = Webgen::Node.new(@tree.dummy_root, '/', '/')
|
173
|
-
node.dirty
|
194
|
+
node.unflag(:dirty, :created)
|
174
195
|
|
175
196
|
calls = 0
|
176
|
-
@website.blackboard.add_listener(:node_meta_info_changed?) {|n| assert(node, n); node.dirty_meta_info
|
197
|
+
@website.blackboard.add_listener(:node_meta_info_changed?) {|n| assert(node, n); node.flag(:dirty_meta_info); calls += 1}
|
177
198
|
assert(node.meta_info_changed?)
|
178
199
|
assert_equal(1, calls)
|
179
200
|
assert(node.meta_info_changed?)
|
180
201
|
assert_equal(1, calls)
|
181
202
|
|
182
|
-
node.dirty_meta_info
|
203
|
+
node.unflag(:dirty_meta_info)
|
183
204
|
node.node_info[:used_meta_info_nodes] << node.absolute_lcn
|
184
205
|
node.node_info[:used_meta_info_nodes] << 'unknown alcn'
|
185
|
-
node.node_info[:used_meta_info_nodes] << @tree.dummy_root.absolute_lcn
|
186
206
|
assert(node.meta_info_changed?)
|
187
|
-
assert_equal(
|
207
|
+
assert_equal(1, calls)
|
188
208
|
end
|
189
209
|
|
190
210
|
def test_method_missing
|
data/test/test_page.rb
CHANGED
@@ -97,14 +97,14 @@ class TestPage < Test::Unit::TestCase
|
|
97
97
|
--- name:block
|
98
98
|
content doing -
|
99
99
|
with?: with some things
|
100
|
-
--- other:options test1:true test2:false test3:542
|
100
|
+
--- other:options test1:true test2:false test3:542 pipeline:
|
101
101
|
meta_info: {}
|
102
102
|
blocks:
|
103
103
|
- name: block
|
104
104
|
content: "content doing -\\nwith?: with some things"
|
105
105
|
- name: block2
|
106
106
|
content: ''
|
107
|
-
options: {other: options, test1: true, test2: false, test3: 542}
|
107
|
+
options: {other: options, test1: true, test2: false, test3: 542, pipeline: ~}
|
108
108
|
|
109
109
|
# block with seemingly block start line it
|
110
110
|
- in: |
|
@@ -118,7 +118,7 @@ class TestPage < Test::Unit::TestCase
|
|
118
118
|
content: "content\\n----------- some block start???\\nthings"
|
119
119
|
EOF
|
120
120
|
|
121
|
-
|
121
|
+
INVALID_MI=<<EOF
|
122
122
|
# invalid meta info: none specified
|
123
123
|
- "---\\n---"
|
124
124
|
|
@@ -136,7 +136,9 @@ EOF
|
|
136
136
|
: * [ }
|
137
137
|
---
|
138
138
|
asdf kadsfakl
|
139
|
+
EOF
|
139
140
|
|
141
|
+
INVALID_BLOCKS=<<EOF
|
140
142
|
# two blocks with same name
|
141
143
|
- |
|
142
144
|
aasdf
|
@@ -155,16 +157,23 @@ EOF
|
|
155
157
|
EOF
|
156
158
|
|
157
159
|
def test_invalid_pagefiles
|
158
|
-
testdata = YAML::load(
|
160
|
+
testdata = YAML::load(INVALID_MI)
|
161
|
+
testdata.each_with_index do |data, index|
|
162
|
+
assert_raise(Webgen::WebgenPageFormatError, "test mi item #{index}") { Webgen::Page.from_data(data) }
|
163
|
+
assert_raise(Webgen::WebgenPageFormatError, "test mi item #{index}") { Webgen::Page.meta_info_from_data(data) }
|
164
|
+
end
|
165
|
+
testdata = YAML::load(INVALID_BLOCKS)
|
159
166
|
testdata.each_with_index do |data, index|
|
160
|
-
assert_raise(Webgen::WebgenPageFormatError, "test item #{index}") { Webgen::Page.from_data(data) }
|
167
|
+
assert_raise(Webgen::WebgenPageFormatError, "test blocks item #{index}") { Webgen::Page.from_data(data) }
|
161
168
|
end
|
162
169
|
end
|
163
170
|
|
164
171
|
def test_valid_pagefiles
|
165
172
|
YAML::load(VALID).each_with_index do |data, oindex|
|
173
|
+
mi = Webgen::Page.meta_info_from_data(data['in'])
|
174
|
+
assert_equal(data['meta_info'], mi, "test item #{oindex} - meta info directly")
|
166
175
|
d = Webgen::Page.from_data(data['in'])
|
167
|
-
assert_equal(data['meta_info'], d.meta_info, "test item #{oindex} - meta info")
|
176
|
+
assert_equal(data['meta_info'], d.meta_info, "test item #{oindex} - meta info all")
|
168
177
|
assert_equal(data['blocks'].length*2, d.blocks.length)
|
169
178
|
data['blocks'].each_with_index do |b, index|
|
170
179
|
index += 1
|
data/test/test_path.rb
CHANGED
@@ -7,6 +7,7 @@ class TestPath < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
8
8
|
check_proc = proc do |o, path, dir, bn, lang, ext, cn, oi, title|
|
9
9
|
assert_equal(path, o.path)
|
10
|
+
assert_equal(path, o.source_path)
|
10
11
|
assert_equal(dir, o.directory)
|
11
12
|
assert_equal(bn, o.cnbase)
|
12
13
|
assert_equal(lang, o.meta_info['lang'])
|
@@ -38,17 +39,23 @@ class TestPath < Test::Unit::TestCase
|
|
38
39
|
'/', '/', '/', nil, '', '/', nil, '/')
|
39
40
|
check_proc.call(Webgen::Path.new('/dir/'),
|
40
41
|
'/dir/', '/', 'dir', nil, '', 'dir', nil, 'Dir')
|
42
|
+
|
43
|
+
path = Webgen::Path.new('/test/', '/other.path')
|
44
|
+
assert_equal('/other.path', path.source_path)
|
45
|
+
assert_equal('/test/', path.path)
|
41
46
|
end
|
42
47
|
|
43
48
|
def test_mount_at
|
44
49
|
p = Webgen::Path.new('test.de.page')
|
45
50
|
p = p.mount_at('/somedir')
|
46
51
|
assert_equal('/somedir/test.de.page', p.path)
|
52
|
+
assert_equal('/somedir/test.de.page', p.source_path)
|
47
53
|
assert_equal('/somedir/', p.directory)
|
48
54
|
|
49
55
|
p = Webgen::Path.new('/')
|
50
56
|
p = p.mount_at('/somedir')
|
51
57
|
assert_equal('/somedir/', p.path)
|
58
|
+
assert_equal('/somedir/', p.source_path)
|
52
59
|
assert_equal('/', p.directory)
|
53
60
|
assert_equal('somedir', p.cn)
|
54
61
|
assert_equal('Somedir', p.meta_info['title'])
|
@@ -56,6 +63,7 @@ class TestPath < Test::Unit::TestCase
|
|
56
63
|
p = Webgen::Path.new('/source/test.rb')
|
57
64
|
p = p.mount_at('/', '/source/')
|
58
65
|
assert_equal('/test.rb', p.path)
|
66
|
+
assert_equal('/test.rb', p.source_path)
|
59
67
|
assert_equal('/', p.directory)
|
60
68
|
assert_equal('test.rb', p.cn)
|
61
69
|
assert_equal('Test', p.meta_info['title'])
|
@@ -63,9 +71,18 @@ class TestPath < Test::Unit::TestCase
|
|
63
71
|
p = Webgen::Path.new('/source/')
|
64
72
|
p = p.mount_at('/', '/source')
|
65
73
|
assert_equal('/', p.path)
|
74
|
+
assert_equal('/', p.source_path)
|
66
75
|
assert_equal('/', p.directory)
|
67
76
|
assert_equal('/', p.cn)
|
68
77
|
assert_equal('/', p.meta_info['title'])
|
78
|
+
|
79
|
+
p = Webgen::Path.new('/test.rb', '/other.rb')
|
80
|
+
p = p.mount_at('/source/')
|
81
|
+
assert_equal('/source/test.rb', p.path)
|
82
|
+
assert_equal('/other.rb', p.source_path)
|
83
|
+
assert_equal('/source/', p.directory)
|
84
|
+
assert_equal('test.rb', p.cn)
|
85
|
+
assert_equal('Test', p.meta_info['title'])
|
69
86
|
end
|
70
87
|
|
71
88
|
def test_dup
|
@@ -110,11 +127,26 @@ class TestPath < Test::Unit::TestCase
|
|
110
127
|
end
|
111
128
|
|
112
129
|
def test_matching
|
113
|
-
path =
|
114
|
-
assert(path
|
115
|
-
assert(path
|
116
|
-
assert(path
|
117
|
-
assert(path
|
130
|
+
path = '/dir/to/file.de.page'
|
131
|
+
assert(Webgen::Path.match(path, '**/*'))
|
132
|
+
assert(Webgen::Path.match(path, '**/file.de.PAGE'))
|
133
|
+
assert(Webgen::Path.match(path, '/dir/*/file.*.page'))
|
134
|
+
assert(!Webgen::Path.match(path, '**/*.test'))
|
135
|
+
|
136
|
+
path = '/dir/'
|
137
|
+
assert(Webgen::Path.match(path, '/dir/'))
|
138
|
+
assert(Webgen::Path.match(path, '/dir'))
|
139
|
+
|
140
|
+
path = '/dir'
|
141
|
+
assert(Webgen::Path.match(path, '/dir/'))
|
142
|
+
assert(Webgen::Path.match(path, '/dir'))
|
143
|
+
|
144
|
+
path = '/'
|
145
|
+
assert(Webgen::Path.match(path, '/'))
|
146
|
+
assert(!Webgen::Path.match(path, ''))
|
147
|
+
|
148
|
+
path = ''
|
149
|
+
assert(!Webgen::Path.match(path, '/'))
|
118
150
|
end
|
119
151
|
|
120
152
|
def test_introspection
|
data/test/test_source_stacked.rb
CHANGED
@@ -3,11 +3,13 @@ require 'helper'
|
|
3
3
|
require 'webgen/tree'
|
4
4
|
require 'webgen/node'
|
5
5
|
require 'webgen/path'
|
6
|
-
require 'webgen/sourcehandler
|
6
|
+
require 'webgen/sourcehandler'
|
7
7
|
require 'time'
|
8
8
|
|
9
9
|
class TestSourceHandlerBase < Test::Unit::TestCase
|
10
10
|
|
11
|
+
class TestSH; include Webgen::SourceHandler::Base; end
|
12
|
+
|
11
13
|
include Test::WebsiteHelper
|
12
14
|
|
13
15
|
def setup
|
@@ -16,6 +18,33 @@ class TestSourceHandlerBase < Test::Unit::TestCase
|
|
16
18
|
@obj.extend(Webgen::SourceHandler::Base)
|
17
19
|
end
|
18
20
|
|
21
|
+
def test_create_node
|
22
|
+
tree = Webgen::Tree.new
|
23
|
+
path = path_with_meta_info('/path.html')
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
path.instance_eval { @source_path = '/path'}
|
27
|
+
node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
|
28
|
+
assert_equal('/path', node.node_info[:src])
|
29
|
+
assert_equal('Object', node.node_info[:processor])
|
30
|
+
assert_kind_of(Time, node['modified_at'])
|
31
|
+
assert_equal(1, count)
|
32
|
+
|
33
|
+
other_node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
|
34
|
+
assert_equal(node, other_node)
|
35
|
+
assert_equal(1, count)
|
36
|
+
|
37
|
+
node.flag(:reinit)
|
38
|
+
other_node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
|
39
|
+
assert_equal(node, other_node)
|
40
|
+
assert_equal(2, count)
|
41
|
+
|
42
|
+
path.instance_eval { @source_path = '/other' }
|
43
|
+
other_node = @obj.create_node(tree.dummy_root, path) {|n| count +=1 }
|
44
|
+
assert_equal(node, other_node)
|
45
|
+
assert_equal(2, count)
|
46
|
+
end
|
47
|
+
|
19
48
|
def test_node_exists
|
20
49
|
@tree = Webgen::Tree.new
|
21
50
|
node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
|