gettalong-webgen 0.5.8.20090507 → 0.5.9.20090620
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -6
- data/data/webgen/passive_sources/images/generated_by_webgen.png +0 -0
- data/data/webgen/passive_sources/images/webgen_logo.png +0 -0
- data/data/webgen/passive_sources/templates/atom_feed.template +38 -0
- data/data/webgen/passive_sources/templates/rss_feed.template +28 -0
- data/data/webgen/resources.yaml +2 -1
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +5 -2
- data/doc/contentprocessor/erubis.page +2 -2
- data/doc/extensions.page +1 -1
- data/doc/manual.page +56 -26
- data/doc/reference_configuration.page +36 -1
- data/doc/reference_website_styles.page +1 -1
- data/doc/sourcehandler/feed.page +6 -11
- data/doc/tag/includefile.page +1 -1
- data/lib/webgen/cli/apply_command.rb +1 -1
- data/lib/webgen/cli/utils.rb +2 -2
- data/lib/webgen/common.rb +0 -9
- data/lib/webgen/contentprocessor/blocks.rb +60 -36
- data/lib/webgen/contentprocessor/builder.rb +2 -2
- data/lib/webgen/contentprocessor/erb.rb +3 -2
- data/lib/webgen/contentprocessor/erubis.rb +2 -2
- data/lib/webgen/contentprocessor/haml.rb +2 -2
- data/lib/webgen/contentprocessor/maruku.rb +1 -1
- data/lib/webgen/contentprocessor/sass.rb +2 -2
- data/lib/webgen/contentprocessor/tags.rb +25 -11
- data/lib/webgen/context.rb +4 -1
- data/lib/webgen/context/render.rb +32 -0
- data/lib/webgen/context/tags.rb +20 -0
- data/lib/webgen/default_config.rb +4 -1
- data/lib/webgen/deprecated.rb +37 -4
- data/lib/webgen/node.rb +37 -38
- data/lib/webgen/path.rb +151 -54
- data/lib/webgen/source.rb +6 -6
- data/lib/webgen/source/stacked.rb +13 -5
- data/lib/webgen/sourcehandler.rb +71 -45
- data/lib/webgen/sourcehandler/base.rb +51 -21
- data/lib/webgen/sourcehandler/copy.rb +4 -4
- data/lib/webgen/sourcehandler/directory.rb +3 -9
- data/lib/webgen/sourcehandler/feed.rb +23 -49
- data/lib/webgen/sourcehandler/fragment.rb +10 -8
- data/lib/webgen/sourcehandler/memory.rb +9 -10
- data/lib/webgen/sourcehandler/metainfo.rb +9 -9
- data/lib/webgen/sourcehandler/page.rb +5 -5
- data/lib/webgen/sourcehandler/sitemap.rb +3 -3
- data/lib/webgen/sourcehandler/template.rb +6 -6
- data/lib/webgen/sourcehandler/virtual.rb +19 -17
- data/lib/webgen/tag/base.rb +34 -26
- data/lib/webgen/tag/breadcrumbtrail.rb +3 -3
- data/lib/webgen/tag/executecommand.rb +3 -3
- data/lib/webgen/tag/langbar.rb +2 -2
- data/lib/webgen/tag/link.rb +3 -3
- data/lib/webgen/tag/menu.rb +2 -2
- data/lib/webgen/tag/metainfo.rb +1 -1
- data/lib/webgen/tag/relocatable.rb +17 -21
- data/lib/webgen/tag/tikz.rb +5 -6
- data/lib/webgen/tree.rb +7 -7
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +4 -2
- data/misc/default.css +8 -2
- data/misc/default.template +2 -2
- data/misc/logo.svg +313 -0
- data/misc/style.page +1 -1
- data/test/helper.rb +2 -2
- data/test/test_common_sitemap.rb +1 -1
- data/test/test_contentprocessor_blocks.rb +12 -4
- data/test/test_contentprocessor_builder.rb +2 -1
- data/test/test_contentprocessor_erb.rb +2 -1
- data/test/test_contentprocessor_erubis.rb +1 -1
- data/test/test_contentprocessor_fragments.rb +12 -11
- data/test/test_contentprocessor_haml.rb +2 -1
- data/test/test_contentprocessor_maruku.rb +1 -0
- data/test/test_contentprocessor_rdiscount.rb +1 -0
- data/test/test_contentprocessor_rdoc.rb +1 -0
- data/test/test_contentprocessor_sass.rb +1 -0
- data/test/test_contentprocessor_tags.rb +13 -0
- data/test/test_context.rb +28 -0
- data/test/test_node.rb +40 -20
- data/test/test_path.rb +106 -65
- data/test/test_source_filesystem.rb +1 -1
- data/test/test_source_stacked.rb +19 -6
- data/test/test_sourcehandler_base.rb +53 -47
- data/test/test_sourcehandler_copy.rb +6 -6
- data/test/test_sourcehandler_directory.rb +8 -12
- data/test/test_sourcehandler_feed.rb +10 -6
- data/test/test_sourcehandler_fragment.rb +6 -5
- data/test/test_sourcehandler_main.rb +39 -0
- data/test/test_sourcehandler_memory.rb +4 -4
- data/test/test_sourcehandler_metainfo.rb +10 -10
- data/test/test_sourcehandler_page.rb +9 -9
- data/test/test_sourcehandler_sitemap.rb +4 -4
- data/test/test_sourcehandler_template.rb +14 -14
- data/test/test_sourcehandler_virtual.rb +9 -5
- data/test/test_tag_base.rb +2 -2
- data/test/test_tag_executecommand.rb +1 -1
- data/test/test_tag_link.rb +4 -3
- data/test/test_tag_menu.rb +15 -15
- data/test/test_tag_metainfo.rb +1 -0
- data/test/test_tag_relocatable.rb +2 -1
- data/test/test_tag_tikz.rb +3 -3
- data/test/test_tree.rb +8 -8
- data/test/test_website.rb +15 -0
- metadata +14 -14
- data/test/test_common.rb +0 -18
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
require 'helper'
|
4
5
|
require 'webgen/tree'
|
5
6
|
require 'webgen/contentprocessor'
|
6
7
|
|
@@ -10,7 +11,7 @@ class TestContentProcessorBuilder < Test::Unit::TestCase
|
|
10
11
|
obj = Webgen::ContentProcessor::Builder.new
|
11
12
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
13
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
content = "xml.div(:path => context.node.
|
14
|
+
content = "xml.div(:path => context.node.alcn) { xml.strong('test'); " +
|
14
15
|
"context.website; context; context.ref_node; context.dest_node }"
|
15
16
|
context = Webgen::Context.new(:content => content,
|
16
17
|
:chain => [node])
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
require 'helper'
|
4
5
|
require 'webgen/tree'
|
5
6
|
require 'webgen/contentprocessor'
|
6
7
|
|
@@ -10,7 +11,7 @@ class TestContentProcessorErb < Test::Unit::TestCase
|
|
10
11
|
obj = Webgen::ContentProcessor::Erb.new
|
11
12
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
13
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
content = "<%= context[:doit] %>6\n<%= context.ref_node.
|
14
|
+
content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% website %>"
|
14
15
|
context = Webgen::Context.new(:content => content, :doit => 'hallo',
|
15
16
|
:chain => [node])
|
16
17
|
obj.call(context)
|
@@ -17,7 +17,7 @@ class TestContentProcessorErubis < Test::Unit::TestCase
|
|
17
17
|
node = Webgen::Node.new(root, 'test', 'test')
|
18
18
|
context = Webgen::Context.new(:doit => 'hallo', :chain => [node])
|
19
19
|
|
20
|
-
context.content = "<%= context[:doit] %>6\n<%= context.ref_node.
|
20
|
+
context.content = "<%= context[:doit] %>6\n<%= context.ref_node.alcn %>\n<%= context.node.alcn %>\n<%= context.dest_node.alcn %><% context.website %>"
|
21
21
|
assert_equal("hallo6\n/test\n/test\n/test", obj.call(context).content)
|
22
22
|
|
23
23
|
context.content = '<%= 5* %>'
|
@@ -13,30 +13,31 @@ class TestContentProcessorFragments < Test::Unit::TestCase
|
|
13
13
|
def test_process
|
14
14
|
Webgen::SourceHandler::Main.new
|
15
15
|
@website.blackboard.del_service(:source_paths)
|
16
|
-
@website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/')) }
|
16
|
+
@website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/test.html')) }
|
17
17
|
|
18
18
|
obj = Webgen::ContentProcessor::Fragments.new
|
19
19
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
20
|
-
|
20
|
+
node = Webgen::Node.new(root, '/test.html', 'test.html')
|
21
|
+
node.node_info[:src] = '/test.html'
|
21
22
|
processors = { 'fragments' => obj }
|
22
23
|
|
23
|
-
context = Webgen::Context.new(:chain => [
|
24
|
+
context = Webgen::Context.new(:chain => [node], :processors => processors)
|
24
25
|
context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
|
25
26
|
obj.call(context)
|
26
|
-
assert(root.tree['
|
27
|
-
assert_equal(
|
28
|
-
root.tree.delete_node('
|
27
|
+
assert(root.tree['/test.html#test'])
|
28
|
+
assert_equal(4, root.tree.node_access[:alcn].length)
|
29
|
+
root.tree.delete_node('/test.html#test')
|
29
30
|
|
30
31
|
context[:block] = Webgen::Page::Block.new('content', '', {})
|
31
32
|
obj.call(context)
|
32
|
-
assert(root.tree['
|
33
|
-
assert_equal(
|
34
|
-
root.tree.delete_node('
|
33
|
+
assert(root.tree['/test.html#test'])
|
34
|
+
assert_equal(4, root.tree.node_access[:alcn].length)
|
35
|
+
root.tree.delete_node('/test.html#test')
|
35
36
|
|
36
37
|
context[:block] = Webgen::Page::Block.new('other', '', {})
|
37
38
|
obj.call(context)
|
38
|
-
assert(!root.tree['
|
39
|
-
assert_equal(
|
39
|
+
assert(!root.tree['/test.html#test'])
|
40
|
+
assert_equal(3, root.tree.node_access[:alcn].length)
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
require 'helper'
|
4
5
|
require 'webgen/tree'
|
5
6
|
require 'webgen/contentprocessor'
|
6
7
|
|
@@ -10,7 +11,7 @@ class TestContentProcessorHaml < Test::Unit::TestCase
|
|
10
11
|
obj = Webgen::ContentProcessor::Haml.new
|
11
12
|
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
12
13
|
node = Webgen::Node.new(root, 'test', 'test')
|
13
|
-
content = "#content\n %h1 Hallo\n = [context.node.
|
14
|
+
content = "#content\n %h1 Hallo\n = [context.node.alcn, context.ref_node.alcn, context.dest_node.alcn, context.website, context.dest_node.alcn].join"
|
14
15
|
context = Webgen::Context.new(:content => content,
|
15
16
|
:chain => [node])
|
16
17
|
obj.call(context)
|
@@ -15,6 +15,8 @@ class TestContentProcessorTags < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
def create_tag_params(*args); end
|
17
17
|
|
18
|
+
def create_params_hash(*args); end
|
19
|
+
|
18
20
|
def call(tag, body, context)
|
19
21
|
case tag
|
20
22
|
when 'body'
|
@@ -46,6 +48,17 @@ class TestContentProcessorTags < Test::Unit::TestCase
|
|
46
48
|
@obj.call(context.clone(:content => "test{bodyproc::} \\{other:}{other:} {bodyproc}test")).content)
|
47
49
|
end
|
48
50
|
|
51
|
+
def test_process_tag
|
52
|
+
context = Webgen::Context.new(:chain => [Webgen::Tree.new.dummy_root])
|
53
|
+
context.content = "{test: }"
|
54
|
+
assert_equal('', @obj.process_tag('test', {}, '', context))
|
55
|
+
|
56
|
+
add_test_tag
|
57
|
+
assert_equal('test', @obj.process_tag('test', {'something' => 'new'}, '', context))
|
58
|
+
assert_equal('test', @obj.process_tag('test', '{something: new}', '', context))
|
59
|
+
assert_equal('thebody', @obj.process_tag('body', '{something: new}', 'thebody', context))
|
60
|
+
end
|
61
|
+
|
49
62
|
def test_replace_tags
|
50
63
|
check_returned_tags('sdfsdf{asd', [])
|
51
64
|
check_returned_tags('sdfsdf}asd', [])
|
data/test/test_context.rb
CHANGED
@@ -6,7 +6,10 @@ require 'webgen/context'
|
|
6
6
|
|
7
7
|
class TestContext < Test::Unit::TestCase
|
8
8
|
|
9
|
+
include Test::WebsiteHelper
|
10
|
+
|
9
11
|
def setup
|
12
|
+
super
|
10
13
|
@context = Webgen::Context.new(:content => 'test', :key => :value, :chain => [:first, :last])
|
11
14
|
end
|
12
15
|
|
@@ -39,4 +42,29 @@ class TestContext < Test::Unit::TestCase
|
|
39
42
|
assert_equal(:other, @context.dest_node)
|
40
43
|
end
|
41
44
|
|
45
|
+
def test_tags_methods
|
46
|
+
@context[:chain] = [Webgen::Tree.new.dummy_root]
|
47
|
+
|
48
|
+
klass = Class.new do
|
49
|
+
def set_params(*args); end
|
50
|
+
def create_tag_params(*args); end
|
51
|
+
def create_params_hash(*args); end
|
52
|
+
def call(tag, body, context); 'mivalue'; end
|
53
|
+
end
|
54
|
+
(@website.cache.volatile[:classes] ||= {})['TestTag'] = klass.new
|
55
|
+
@website.config['contentprocessor.tags.map'].update(:default => 'TestTag')
|
56
|
+
|
57
|
+
assert_equal('mivalue', @context.tag('mivalue'))
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_render_methods
|
61
|
+
root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
|
62
|
+
node = Webgen::Node.new(root, 'test', 'test')
|
63
|
+
node.node_info[:page] = Webgen::Page.from_data("--- name:content\ndata\n--- name:other\nother")
|
64
|
+
@context[:chain] = [root, node]
|
65
|
+
|
66
|
+
assert_equal('data', @context.render_block('content'))
|
67
|
+
assert_equal('other', @context.render_block(:name => 'other'))
|
68
|
+
end
|
69
|
+
|
42
70
|
end
|
data/test/test_node.rb
CHANGED
@@ -11,7 +11,7 @@ class TestNode < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
def setup
|
13
13
|
super
|
14
|
-
@tree =
|
14
|
+
@tree = @website.tree
|
15
15
|
end
|
16
16
|
|
17
17
|
def create_default_nodes
|
@@ -39,7 +39,7 @@ class TestNode < Test::Unit::TestCase
|
|
39
39
|
assert_equal(path, node.path)
|
40
40
|
assert_equal(cn, node.cn)
|
41
41
|
assert_equal(lcn, node.lcn)
|
42
|
-
assert_equal(alcn, node.
|
42
|
+
assert_equal(alcn, node.alcn)
|
43
43
|
assert_equal(lang, node.lang)
|
44
44
|
assert_kind_of(Webgen::Language, node.lang) if node.lang
|
45
45
|
assert(node.flagged?(:dirty))
|
@@ -49,22 +49,22 @@ class TestNode < Test::Unit::TestCase
|
|
49
49
|
mi.each {|k,v| assert_equal(v, node[k])}
|
50
50
|
end
|
51
51
|
|
52
|
-
node = Webgen::Node.new(@tree.dummy_root, '
|
53
|
-
check_proc.call(node, @tree.dummy_root, '
|
52
|
+
node = Webgen::Node.new(@tree.dummy_root, '/', '/', {'lang' => 'de', :test => :value})
|
53
|
+
check_proc.call(node, @tree.dummy_root, '/', '/', '/', '/', nil, {:test => :value})
|
54
54
|
|
55
55
|
child = Webgen::Node.new(node, 'somename.html', 'somename.page', {'lang' => 'de'})
|
56
56
|
check_proc.call(child, node, 'somename.html', 'somename.page', 'somename.de.page',
|
57
|
-
'/
|
57
|
+
'/somename.de.page', 'de', {})
|
58
58
|
|
59
59
|
['http://webgen.rubyforge.org', 'c:\\test'].each_with_index do |abspath, index|
|
60
60
|
cn = 'test' + index.to_s + '.html'
|
61
61
|
c = Webgen::Node.new(node, abspath, cn)
|
62
|
-
check_proc.call(c, node, abspath, cn, cn, '/
|
62
|
+
check_proc.call(c, node, abspath, cn, cn, '/' + cn, nil, {})
|
63
63
|
end
|
64
64
|
|
65
65
|
child.reinit('somename.en.html', {'lang' => 'de', 'title' => 'test'})
|
66
66
|
check_proc.call(child, node, 'somename.en.html', 'somename.page', 'somename.de.page',
|
67
|
-
'/
|
67
|
+
'/somename.de.page', 'de', {'title' => 'test'})
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_type_checkers
|
@@ -156,12 +156,26 @@ class TestNode < Test::Unit::TestCase
|
|
156
156
|
assert_equal(nodes[:dir2_index_en], nodes[:dir2].resolve('index.html', 'en'))
|
157
157
|
|
158
158
|
assert_equal(nodes[:dir], nodes[:somename_en].resolve('/dir/'))
|
159
|
+
assert_equal(nodes[:dir], nodes[:somename_en].resolve('/dir'))
|
159
160
|
assert_equal(nodes[:root], nodes[:somename_en].resolve('/'))
|
160
161
|
end
|
161
162
|
|
163
|
+
def test_resolve_passive_nodes
|
164
|
+
nodes = create_default_nodes
|
165
|
+
|
166
|
+
assert_nil(nodes[:root].resolve('/images/webgen_logo.png'))
|
167
|
+
|
168
|
+
shm = Webgen::SourceHandler::Main.new
|
169
|
+
@website.config['passive_sources'] << ['/', "Webgen::Source::Resource", "webgen-passive-sources"]
|
170
|
+
node = nodes[:root].resolve('/images/webgen_logo.png')
|
171
|
+
assert_not_nil(node)
|
172
|
+
assert_equal('/images/webgen_logo.png', node.alcn)
|
173
|
+
assert_equal(['/images/', '/images/webgen_logo.png'].to_set, node.node_info[:used_meta_info_nodes])
|
174
|
+
end
|
175
|
+
|
162
176
|
def test_introspection
|
163
|
-
node = Webgen::Node.new(@tree.dummy_root, '
|
164
|
-
assert(node.inspect =~ /alcn
|
177
|
+
node = Webgen::Node.new(@tree.dummy_root, '/', '/', {'lang' => 'de', :test => :value})
|
178
|
+
assert(node.inspect =~ /alcn=\//)
|
165
179
|
end
|
166
180
|
|
167
181
|
def test_changed
|
@@ -177,16 +191,16 @@ class TestNode < Test::Unit::TestCase
|
|
177
191
|
|
178
192
|
# Test :used_nodes array checking
|
179
193
|
node.unflag(:dirty)
|
180
|
-
node.node_info[:used_nodes] << node.
|
194
|
+
node.node_info[:used_nodes] << node.alcn
|
181
195
|
node.node_info[:used_nodes] << 'unknown alcn'
|
182
|
-
node.node_info[:used_nodes] << @tree.dummy_root.
|
196
|
+
node.node_info[:used_nodes] << @tree.dummy_root.alcn
|
183
197
|
assert(node.changed?)
|
184
198
|
assert_equal(1, calls)
|
185
199
|
|
186
200
|
# Test :used_nodes array checking
|
187
201
|
node.unflag(:dirty)
|
188
202
|
node.node_info[:used_nodes] = Set.new
|
189
|
-
node.node_info[:used_meta_info_nodes] << node.
|
203
|
+
node.node_info[:used_meta_info_nodes] << node.alcn
|
190
204
|
assert(node.changed?)
|
191
205
|
assert_equal(2, calls)
|
192
206
|
node.unflag(:dirty)
|
@@ -198,8 +212,8 @@ class TestNode < Test::Unit::TestCase
|
|
198
212
|
other_node = Webgen::Node.new(@tree.dummy_root, '/other', 'test.l', {'lang' => 'de', :test => :value})
|
199
213
|
other_node.flag(:dirty, :created)
|
200
214
|
node.flag(:dirty)
|
201
|
-
other_node.node_info[:used_nodes] = [node.
|
202
|
-
node.node_info[:used_nodes] = [other_node.
|
215
|
+
other_node.node_info[:used_nodes] = [node.alcn]
|
216
|
+
node.node_info[:used_nodes] = [other_node.alcn]
|
203
217
|
node.changed?
|
204
218
|
end
|
205
219
|
|
@@ -234,12 +248,6 @@ class TestNode < Test::Unit::TestCase
|
|
234
248
|
assert(node !~ '**/*.test')
|
235
249
|
end
|
236
250
|
|
237
|
-
def test_absolute_name
|
238
|
-
root = Webgen::Node.new(@tree.dummy_root, '/', '/')
|
239
|
-
node = Webgen::Node.new(root, 'somepath', 'somefile.html', {'lang' => 'de'})
|
240
|
-
assert_equal('/somefile.de.html', node.absolute_lcn)
|
241
|
-
end
|
242
|
-
|
243
251
|
def test_route_to
|
244
252
|
nodes = create_default_nodes
|
245
253
|
|
@@ -363,5 +371,17 @@ class TestNode < Test::Unit::TestCase
|
|
363
371
|
nodes[:somename_en_frag].link_to(nodes[:somename_en_frag]))
|
364
372
|
end
|
365
373
|
|
374
|
+
def test_url
|
375
|
+
assert_equal("webgen://webgen.localhost/hallo", Webgen::Node.url("hallo").to_s)
|
376
|
+
assert_equal("webgen://webgen.localhost/hallo%20du", Webgen::Node.url("hallo du").to_s)
|
377
|
+
assert_equal("webgen://webgen.localhost/hall%C3%B6chen", Webgen::Node.url("hallöchen").to_s)
|
378
|
+
assert_equal("webgen://webgen.localhost/hallo#du", Webgen::Node.url("hallo#du").to_s)
|
379
|
+
|
380
|
+
assert_equal("webgen://webgen.localhost/test", Webgen::Node.url("/test").to_s)
|
381
|
+
assert_equal("http://example.com/test", Webgen::Node.url("http://example.com/test").to_s)
|
382
|
+
|
383
|
+
assert_equal("test", Webgen::Node.url("test", false).to_s)
|
384
|
+
assert_equal("http://example.com/test", Webgen::Node.url("http://example.com/test", false).to_s)
|
385
|
+
end
|
366
386
|
|
367
387
|
end
|
data/test/test_path.rb
CHANGED
@@ -6,75 +6,105 @@ require 'stringio'
|
|
6
6
|
|
7
7
|
class TestPath < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def
|
10
|
-
check_proc = proc do |o,
|
11
|
-
|
12
|
-
assert_equal(path, o.source_path)
|
13
|
-
assert_equal(
|
14
|
-
assert_equal(bn, o.
|
9
|
+
def test_initialize_and_accessors
|
10
|
+
check_proc = proc do |o, ppath, bn, lang, ext, cn, lcn, acn, alcn, oi, title|
|
11
|
+
assert_kind_of(String, o.path)
|
12
|
+
assert_equal(o.path, o.source_path)
|
13
|
+
assert_equal(ppath, o.parent_path)
|
14
|
+
assert_equal(bn, o.basename)
|
15
15
|
assert_equal(lang, o.meta_info['lang'])
|
16
16
|
assert_equal(ext, o.ext)
|
17
17
|
assert_equal(cn, o.cn)
|
18
|
+
assert_equal(lcn, o.lcn)
|
19
|
+
assert_equal(acn, o.acn)
|
20
|
+
assert_equal(alcn, o.alcn)
|
18
21
|
assert_equal(oi, o.meta_info['sort_info'])
|
19
22
|
assert_equal(title, o.meta_info['title'])
|
20
23
|
end
|
21
|
-
check_proc.call(Webgen::Path.new('5.base_name-one.de.page'),
|
22
|
-
'5.base_name-one.de.page', './', 'base_name-one', 'de', 'page', 'base_name-one.page', 5, 'Base name one')
|
23
|
-
check_proc.call(Webgen::Path.new('dir/default.png'),
|
24
|
-
'dir/default.png', 'dir/', 'default', nil, 'png', 'default.png', nil, 'Default')
|
25
|
-
check_proc.call(Webgen::Path.new('default.en.png'),
|
26
|
-
'default.en.png', './', 'default', 'en', 'png', 'default.png', nil, 'Default')
|
27
|
-
check_proc.call(Webgen::Path.new('default.deu.png'),
|
28
|
-
'default.deu.png', './', 'default', 'de', 'png', 'default.png', nil, 'Default')
|
29
|
-
check_proc.call(Webgen::Path.new('default.template'),
|
30
|
-
'default.template', './', 'default', nil, 'template', 'default.template', nil, 'Default')
|
31
|
-
check_proc.call(Webgen::Path.new('default.en.tar.bz2'),
|
32
|
-
'default.en.tar.bz2', './', 'default', 'en', 'tar.bz2', 'default.tar.bz2', nil, 'Default')
|
33
|
-
check_proc.call(Webgen::Path.new('default.tar.bz2'),
|
34
|
-
'default.tar.bz2', './', 'default', nil, 'tar.bz2', 'default.tar.bz2', nil, 'Default')
|
35
|
-
check_proc.call(Webgen::Path.new('default'),
|
36
|
-
'default', './', 'default', nil, '', 'default', nil, 'Default')
|
37
|
-
check_proc.call(Webgen::Path.new('.htaccess'),
|
38
|
-
'.htaccess', './', '', nil, 'htaccess', '.htaccess', nil, '')
|
39
24
|
|
25
|
+
# Check directory paths
|
40
26
|
check_proc.call(Webgen::Path.new('/'),
|
41
|
-
'
|
42
|
-
check_proc.call(Webgen::Path.new('/
|
43
|
-
'/
|
27
|
+
'', '/', nil, '', '/', '/', '/', '/', nil, '/')
|
28
|
+
check_proc.call(Webgen::Path.new('/directory/'),
|
29
|
+
'/', 'directory', nil, '', 'directory/', 'directory/', '/directory/', '/directory/', nil, 'Directory')
|
30
|
+
check_proc.call(Webgen::Path.new('/dir1/dir2.ext/'),
|
31
|
+
'/dir1/', 'dir2.ext', nil, '', 'dir2.ext/', 'dir2.ext/', '/dir1/dir2.ext/', '/dir1/dir2.ext/', nil, 'Dir2.ext')
|
32
|
+
|
33
|
+
# Check file paths
|
34
|
+
check_proc.call(Webgen::Path.new('/5.b_n-one.de.page'),
|
35
|
+
'/', 'b_n-one', 'de', 'page', 'b_n-one.page', 'b_n-one.de.page', '/b_n-one.page', '/b_n-one.de.page', 5, 'B n one')
|
36
|
+
check_proc.call(Webgen::Path.new('/dir/default.png'),
|
37
|
+
'/dir/', 'default', nil, 'png', 'default.png', 'default.png', '/dir/default.png', '/dir/default.png', nil, 'Default')
|
38
|
+
check_proc.call(Webgen::Path.new('/default.deu.png'),
|
39
|
+
'/', 'default', 'de', 'png', 'default.png', 'default.de.png', '/default.png', '/default.de.png', nil, 'Default')
|
40
|
+
check_proc.call(Webgen::Path.new('/default.en.tar.bz2'),
|
41
|
+
'/', 'default', 'en', 'tar.bz2', 'default.tar.bz2', 'default.en.tar.bz2', '/default.tar.bz2', '/default.en.tar.bz2', nil, 'Default')
|
42
|
+
check_proc.call(Webgen::Path.new('/default.deu.'),
|
43
|
+
'/', 'default', 'de', '', 'default', 'default.de', '/default', '/default.de', nil, 'Default')
|
44
|
+
check_proc.call(Webgen::Path.new('/default'),
|
45
|
+
'/', 'default', nil, '', 'default', 'default', '/default', '/default', nil, 'Default')
|
46
|
+
check_proc.call(Webgen::Path.new('/.htaccess'),
|
47
|
+
'/', '.htaccess', nil, '', '.htaccess', '.htaccess', '/.htaccess', '/.htaccess', nil, '.htaccess')
|
48
|
+
check_proc.call(Webgen::Path.new('/.htaccess.page'),
|
49
|
+
'/', '.htaccess', nil, 'page', '.htaccess.page', '.htaccess.page', '/.htaccess.page', '/.htaccess.page', nil, '.htaccess')
|
50
|
+
check_proc.call(Webgen::Path.new('/.htaccess.en.'),
|
51
|
+
'/', '.htaccess', 'en', '', '.htaccess', '.htaccess.en', '/.htaccess', '/.htaccess.en', nil, '.htaccess')
|
52
|
+
check_proc.call(Webgen::Path.new('/.htaccess.en.page'),
|
53
|
+
'/', '.htaccess', 'en', 'page', '.htaccess.page', '.htaccess.en.page', '/.htaccess.page', '/.htaccess.en.page', nil, '.htaccess')
|
54
|
+
|
55
|
+
# Check fragment paths
|
56
|
+
assert_raises(RuntimeError) { Webgen::Path.new("/#hallo")}
|
57
|
+
assert_raises(RuntimeError) { Webgen::Path.new("/#hallo#done")}
|
58
|
+
check_proc.call(Webgen::Path.new('/file#hallo'),
|
59
|
+
'/file', '#hallo', nil, '', '#hallo', '#hallo', '/file#hallo', '/file#hallo', nil, '#hallo')
|
60
|
+
check_proc.call(Webgen::Path.new('/file.en.page#hallo'),
|
61
|
+
'/file.en.page', '#hallo', nil, '', '#hallo', '#hallo', '/file.page#hallo', '/file.en.page#hallo', nil, '#hallo')
|
62
|
+
|
63
|
+
# Check general exceptions
|
64
|
+
assert_raise(RuntimeError) { Webgen::Path.new('/no_basename#') }
|
65
|
+
assert_raise(RuntimeError) { Webgen::Path.new('relative.page') }
|
44
66
|
|
45
67
|
path = Webgen::Path.new('/test/', '/other.path')
|
46
68
|
assert_equal('/other.path', path.source_path)
|
47
69
|
assert_equal('/test/', path.path)
|
70
|
+
assert_equal(false, path.passive?)
|
48
71
|
end
|
49
72
|
|
50
73
|
def test_mount_at
|
51
|
-
p = Webgen::Path.new('test.de.page')
|
52
|
-
|
74
|
+
p = Webgen::Path.new('/test.de.page')
|
75
|
+
assert_raise(ArgumentError) { p.mount_at('no_start_slash/') }
|
76
|
+
assert_raise(ArgumentError) { p.mount_at('/no_end_slash') }
|
77
|
+
assert_raise(ArgumentError) { p.mount_at('/no_with_hash#_char/') }
|
78
|
+
assert_raise(ArgumentError) { p.mount_at('/', 'no_start_slash/') }
|
79
|
+
assert_raise(ArgumentError) { p.mount_at('/', '/no_end_slash') }
|
80
|
+
assert_raise(ArgumentError) { p.mount_at('/', '/no_with_hash#_char/') }
|
81
|
+
|
82
|
+
p = p.mount_at('/somedir/')
|
53
83
|
assert_equal('/somedir/test.de.page', p.path)
|
54
84
|
assert_equal('/somedir/test.de.page', p.source_path)
|
55
|
-
assert_equal('/somedir/', p.
|
85
|
+
assert_equal('/somedir/', p.parent_path)
|
56
86
|
|
57
87
|
p = Webgen::Path.new('/')
|
58
|
-
p = p.mount_at('/somedir')
|
88
|
+
p = p.mount_at('/somedir/')
|
59
89
|
assert_equal('/somedir/', p.path)
|
60
90
|
assert_equal('/somedir/', p.source_path)
|
61
|
-
assert_equal('/', p.
|
62
|
-
assert_equal('somedir', p.cn)
|
91
|
+
assert_equal('/', p.parent_path)
|
92
|
+
assert_equal('somedir/', p.cn)
|
63
93
|
assert_equal('Somedir', p.meta_info['title'])
|
64
94
|
|
65
95
|
p = Webgen::Path.new('/source/test.rb')
|
66
96
|
p = p.mount_at('/', '/source/')
|
67
97
|
assert_equal('/test.rb', p.path)
|
68
98
|
assert_equal('/test.rb', p.source_path)
|
69
|
-
assert_equal('/', p.
|
99
|
+
assert_equal('/', p.parent_path)
|
70
100
|
assert_equal('test.rb', p.cn)
|
71
101
|
assert_equal('Test', p.meta_info['title'])
|
72
102
|
|
73
103
|
p = Webgen::Path.new('/source/')
|
74
|
-
p = p.mount_at('/', '/source')
|
104
|
+
p = p.mount_at('/', '/source/')
|
75
105
|
assert_equal('/', p.path)
|
76
106
|
assert_equal('/', p.source_path)
|
77
|
-
assert_equal('
|
107
|
+
assert_equal('', p.parent_path)
|
78
108
|
assert_equal('/', p.cn)
|
79
109
|
assert_equal('/', p.meta_info['title'])
|
80
110
|
|
@@ -82,53 +112,53 @@ class TestPath < Test::Unit::TestCase
|
|
82
112
|
p = p.mount_at('/source/')
|
83
113
|
assert_equal('/source/test.rb', p.path)
|
84
114
|
assert_equal('/other.rb', p.source_path)
|
85
|
-
assert_equal('/source/', p.
|
115
|
+
assert_equal('/source/', p.parent_path)
|
86
116
|
assert_equal('test.rb', p.cn)
|
87
117
|
assert_equal('Test', p.meta_info['title'])
|
88
118
|
end
|
89
119
|
|
90
120
|
def test_dup
|
91
|
-
p = Webgen::Path.new('test.de.page')
|
121
|
+
p = Webgen::Path.new('/test.de.page')
|
92
122
|
dupped = p.dup
|
93
123
|
dupped.meta_info['title'] = 'changed'
|
94
124
|
assert_equal('Test', p.meta_info['title'])
|
95
125
|
end
|
96
126
|
|
97
127
|
def test_io
|
98
|
-
p = Webgen::Path.new('test.de.page')
|
128
|
+
p = Webgen::Path.new('/test.de.page')
|
99
129
|
assert_raise(RuntimeError) { p.io }
|
100
|
-
p = Webgen::Path.new('test.de.page') { StringIO.new('hallo') }
|
130
|
+
p = Webgen::Path.new('/test.de.page') { StringIO.new('hallo') }
|
101
131
|
assert_equal('hallo', p.io.data)
|
102
132
|
assert_equal('hallo', p.io.stream {|f| f.read })
|
103
133
|
end
|
104
134
|
|
105
|
-
def test_lcn
|
106
|
-
p = Webgen::Path.new('test.de.page')
|
107
|
-
assert_equal('test.page', p.cn)
|
108
|
-
assert_equal('test.de.page', p.lcn)
|
109
|
-
p = Webgen::Path.new('test.page')
|
110
|
-
assert_equal('test.page', p.cn)
|
111
|
-
assert_equal('test.page', p.lcn)
|
112
|
-
end
|
113
|
-
|
114
135
|
def test_equality
|
115
|
-
p = Webgen::Path.new('test.de.page')
|
116
|
-
assert_equal('test.de.page', p)
|
117
|
-
assert_equal(Webgen::Path.new('test.de.page'), p)
|
136
|
+
p = Webgen::Path.new('/test.de.page')
|
137
|
+
assert_equal('/test.de.page', p)
|
138
|
+
assert_equal(Webgen::Path.new('/test.de.page'), p)
|
118
139
|
assert_not_equal(5, p)
|
119
140
|
end
|
120
141
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
124
|
-
assert_equal(
|
125
|
-
assert_equal(
|
126
|
-
|
127
|
-
h = { p => :newvalue}
|
128
|
-
assert_nil(h['test.de.page'])
|
142
|
+
def test_comparison
|
143
|
+
p1 = Webgen::Path.new('/test.de.page')
|
144
|
+
p2 = Webgen::Path.new('/test.en.page')
|
145
|
+
assert_equal(0, p1 <=> p1)
|
146
|
+
assert_equal(-1, p1 <=> p2)
|
147
|
+
assert_equal(1, p2 <=> p1)
|
129
148
|
end
|
130
149
|
|
131
|
-
|
150
|
+
# Problem with hashing under 1.8.6 when changing from 'test.de.page' to '/test.de.page'...
|
151
|
+
# def test_hashing
|
152
|
+
# path = Webgen::Path.new('test.de.page')
|
153
|
+
# h = { 'test.de.page' => :value }
|
154
|
+
# assert_equal(:value, h['test.de.page'])
|
155
|
+
# assert_equal(:value, h[path])
|
156
|
+
# assert(path <=> 'test.de.page')
|
157
|
+
# h = { p => :newvalue}
|
158
|
+
# assert_nil(h['test.de.page'])
|
159
|
+
# end
|
160
|
+
|
161
|
+
def test_match
|
132
162
|
path = '/dir/to/file.de.page'
|
133
163
|
assert(Webgen::Path.match(path, '**/*'))
|
134
164
|
assert(Webgen::Path.match(path, '**/file.de.PAGE'))
|
@@ -151,14 +181,25 @@ class TestPath < Test::Unit::TestCase
|
|
151
181
|
assert(!Webgen::Path.match(path, '/'))
|
152
182
|
end
|
153
183
|
|
184
|
+
def test_apath
|
185
|
+
assert_raise(ArgumentError) { Webgen::Path.make_absolute('test', 'test') }
|
186
|
+
assert_equal('/', Webgen::Path.make_absolute('/', '/'))
|
187
|
+
assert_equal('/dir', Webgen::Path.make_absolute('/other', '/dir'))
|
188
|
+
assert_equal('/other/dir', Webgen::Path.make_absolute('/other', 'dir'))
|
189
|
+
assert_equal('/test/dir', Webgen::Path.make_absolute('/other', '../test/dir'))
|
190
|
+
assert_equal('/', Webgen::Path.make_absolute('/', '/..'))
|
191
|
+
assert_equal('/dir', Webgen::Path.make_absolute('/', '/../dir/.'))
|
192
|
+
end
|
193
|
+
|
194
|
+
|
154
195
|
def test_introspection
|
155
|
-
p = Webgen::Path.new('test.de.page')
|
156
|
-
assert_equal('test.de.page', p.to_s)
|
157
|
-
assert(p.inspect.include?('test.de.page'))
|
196
|
+
p = Webgen::Path.new('/test.de.page')
|
197
|
+
assert_equal('/test.de.page', p.to_s)
|
198
|
+
assert(p.inspect.include?('/test.de.page'))
|
158
199
|
end
|
159
200
|
|
160
201
|
def test_changed?
|
161
|
-
p = Webgen::Path.new('test.de.page')
|
202
|
+
p = Webgen::Path.new('/test.de.page')
|
162
203
|
assert(p.changed?)
|
163
204
|
end
|
164
205
|
|