webgen 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +34 -1
- data/Rakefile +1 -8
- data/data/webgen/passive_sources/default.metainfo +5 -0
- data/data/webgen/passive_sources/stylesheets/api.css +284 -0
- data/data/webgen/passive_sources/templates/api.template +151 -0
- data/data/webgen/passive_sources/templates/feed.template +4 -0
- data/lib/webgen/bundle/built-in/init.rb +12 -3
- data/lib/webgen/bundle_loader.rb +8 -2
- data/lib/webgen/cli/create_command.rb +3 -1
- data/lib/webgen/cli/show_tree_command.rb +4 -3
- data/lib/webgen/content_processor.rb +2 -2
- data/lib/webgen/content_processor/blocks.rb +2 -2
- data/lib/webgen/content_processor/haml.rb +1 -1
- data/lib/webgen/content_processor/html_head.rb +5 -4
- data/lib/webgen/content_processor/kramdown.rb +3 -1
- data/lib/webgen/content_processor/r_doc.rb +16 -3
- data/lib/webgen/content_processor/sass.rb +3 -3
- data/lib/webgen/content_processor/scss.rb +1 -1
- data/lib/webgen/content_processor/tikz.rb +2 -2
- data/lib/webgen/context/html_head.rb +1 -1
- data/lib/webgen/destination/file_system.rb +2 -1
- data/lib/webgen/item_tracker/node_content.rb +4 -4
- data/lib/webgen/item_tracker/node_meta_info.rb +6 -6
- data/lib/webgen/item_tracker/nodes.rb +1 -1
- data/lib/webgen/node.rb +5 -7
- data/lib/webgen/node_finder.rb +40 -17
- data/lib/webgen/page.rb +10 -0
- data/lib/webgen/path.rb +14 -14
- data/lib/webgen/path_handler.rb +19 -13
- data/lib/webgen/path_handler/api.rb +173 -0
- data/lib/webgen/path_handler/base.rb +33 -11
- data/lib/webgen/path_handler/copy.rb +2 -27
- data/lib/webgen/path_handler/feed.rb +4 -3
- data/lib/webgen/path_handler/meta_info.rb +1 -1
- data/lib/webgen/path_handler/page_utils.rb +4 -3
- data/lib/webgen/path_handler/sitemap.rb +3 -2
- data/lib/webgen/path_handler/virtual.rb +7 -2
- data/lib/webgen/tag.rb +5 -5
- data/lib/webgen/tag/execute_command.rb +1 -1
- data/lib/webgen/tag/include_file.rb +1 -1
- data/lib/webgen/tag/link.rb +2 -2
- data/lib/webgen/tag/menu.rb +1 -1
- data/lib/webgen/tag/meta_info.rb +1 -0
- data/lib/webgen/tag/relocatable.rb +1 -1
- data/lib/webgen/tag/tikz.rb +2 -2
- data/lib/webgen/task/create_website.rb +1 -1
- data/lib/webgen/test_helper.rb +20 -16
- data/lib/webgen/tree.rb +5 -1
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +8 -8
- data/test/webgen/content_processor/test_kramdown.rb +7 -5
- data/test/webgen/content_processor/test_sass.rb +4 -0
- data/test/webgen/content_processor/test_scss.rb +4 -0
- data/test/webgen/content_processor/test_tikz.rb +6 -2
- data/test/webgen/destination/test_file_system.rb +3 -4
- data/test/webgen/item_tracker/test_missing_node.rb +3 -3
- data/test/webgen/item_tracker/test_node_content.rb +9 -12
- data/test/webgen/item_tracker/test_node_meta_info.rb +7 -11
- data/test/webgen/item_tracker/test_nodes.rb +11 -5
- data/test/webgen/path_handler/test_api.rb +111 -0
- data/test/webgen/path_handler/test_page_utils.rb +1 -1
- data/test/webgen/source/test_file_system.rb +3 -3
- data/test/webgen/tag/test_coderay.rb +3 -4
- data/test/webgen/tag/test_meta_info.rb +3 -0
- data/test/webgen/task/test_create_website.rb +2 -2
- data/test/webgen/test_item_tracker.rb +11 -16
- data/test/webgen/test_node.rb +2 -0
- data/test/webgen/test_node_finder.rb +30 -2
- data/test/webgen/test_page.rb +8 -0
- data/test/webgen/test_source.rb +11 -18
- data/test/webgen/test_tag.rb +1 -1
- data/test/webgen/test_tree.rb +8 -8
- metadata +8 -88
- data/ChangeLog +0 -23710
- data/data/webgen/website_bundles/default/README +0 -6
- data/data/webgen/website_bundles/default/src/index.page +0 -15
- data/data/webgen/website_bundles/style/1024px/README +0 -13
- data/data/webgen/website_bundles/style/1024px/src/default.css +0 -188
- data/data/webgen/website_bundles/style/1024px/src/default.template +0 -60
- data/data/webgen/website_bundles/style/1024px/src/images/background.gif +0 -0
- data/data/webgen/website_bundles/style/andreas00/README +0 -13
- data/data/webgen/website_bundles/style/andreas00/src/default.css +0 -290
- data/data/webgen/website_bundles/style/andreas00/src/default.template +0 -60
- data/data/webgen/website_bundles/style/andreas00/src/images/bg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas00/src/images/front.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas00/src/images/menubg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas00/src/images/menubg2.gif +0 -0
- data/data/webgen/website_bundles/style/andreas01/README +0 -14
- data/data/webgen/website_bundles/style/andreas01/src/default.css +0 -310
- data/data/webgen/website_bundles/style/andreas01/src/default.template +0 -62
- data/data/webgen/website_bundles/style/andreas01/src/images/bg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas01/src/images/front.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas01/src/print.css +0 -35
- data/data/webgen/website_bundles/style/andreas03/README +0 -14
- data/data/webgen/website_bundles/style/andreas03/src/default.css +0 -223
- data/data/webgen/website_bundles/style/andreas03/src/default.template +0 -58
- data/data/webgen/website_bundles/style/andreas03/src/images/bodybg.png +0 -0
- data/data/webgen/website_bundles/style/andreas03/src/images/contbg.png +0 -0
- data/data/webgen/website_bundles/style/andreas03/src/images/footerbg.png +0 -0
- data/data/webgen/website_bundles/style/andreas03/src/images/gradient1.png +0 -0
- data/data/webgen/website_bundles/style/andreas03/src/images/gradient2.png +0 -0
- data/data/webgen/website_bundles/style/andreas04/README +0 -15
- data/data/webgen/website_bundles/style/andreas04/src/default.css +0 -290
- data/data/webgen/website_bundles/style/andreas04/src/default.template +0 -81
- data/data/webgen/website_bundles/style/andreas04/src/images/blinkarrow.gif +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/bodybg.png +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/contentbg.png +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/entrybg.png +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/flash.gif +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/flash2.gif +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/globe.gif +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/globebottom.gif +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/linkarrow.gif +0 -0
- data/data/webgen/website_bundles/style/andreas04/src/images/menuhover.png +0 -0
- data/data/webgen/website_bundles/style/andreas05/README +0 -14
- data/data/webgen/website_bundles/style/andreas05/src/default.css +0 -33
- data/data/webgen/website_bundles/style/andreas05/src/default.template +0 -40
- data/data/webgen/website_bundles/style/andreas05/src/images/bodybg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas05/src/images/front.png +0 -0
- data/data/webgen/website_bundles/style/andreas06/README +0 -14
- data/data/webgen/website_bundles/style/andreas06/src/default.css +0 -356
- data/data/webgen/website_bundles/style/andreas06/src/default.template +0 -70
- data/data/webgen/website_bundles/style/andreas06/src/images/bodybg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas06/src/images/boxbg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas06/src/images/greypx.gif +0 -0
- data/data/webgen/website_bundles/style/andreas06/src/images/header.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas06/src/images/innerbg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas06/src/images/leaves.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas06/src/images/tabs.gif +0 -0
- data/data/webgen/website_bundles/style/andreas07/README +0 -15
- data/data/webgen/website_bundles/style/andreas07/src/browserfix.css +0 -7
- data/data/webgen/website_bundles/style/andreas07/src/default.css +0 -92
- data/data/webgen/website_bundles/style/andreas07/src/default.template +0 -42
- data/data/webgen/website_bundles/style/andreas07/src/images/bodybg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas07/src/images/sidebarbg.gif +0 -0
- data/data/webgen/website_bundles/style/andreas08/README +0 -14
- data/data/webgen/website_bundles/style/andreas08/src/default.css +0 -224
- data/data/webgen/website_bundles/style/andreas08/src/default.template +0 -51
- data/data/webgen/website_bundles/style/andreas09/README +0 -14
- data/data/webgen/website_bundles/style/andreas09/src/default.css +0 -308
- data/data/webgen/website_bundles/style/andreas09/src/default.template +0 -68
- data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-black.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-green.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-red.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/bodybg.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/footerbg.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-black.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-green.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-red.jpg +0 -0
- data/data/webgen/website_bundles/style/andreas09/src/images/menuhover.jpg +0 -0
- data/data/webgen/website_bundles/style/simple/README +0 -6
- data/data/webgen/website_bundles/style/simple/src/default.css +0 -84
- data/data/webgen/website_bundles/style/simple/src/default.template +0 -36
@@ -15,7 +15,7 @@ class TestContentProcessorTikz < MiniTest::Unit::TestCase
|
|
15
15
|
template_data = File.read(File.join(Webgen::Utils.data_dir, 'passive_sources', 'templates', 'tikz.template'))
|
16
16
|
node = RenderNode.new(template_data, @website.tree.dummy_root, '/template', '/template')
|
17
17
|
|
18
|
-
@context.node.
|
18
|
+
@context.node.define_singleton_method(:[]) {|ignored| nil}
|
19
19
|
|
20
20
|
call('\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false)
|
21
21
|
refute_nil(@context.content)
|
@@ -28,7 +28,7 @@ class TestContentProcessorTikz < MiniTest::Unit::TestCase
|
|
28
28
|
|
29
29
|
def call(content, path, libs, opts, res, trans)
|
30
30
|
@context.content = content
|
31
|
-
@context.dest_node.
|
31
|
+
@context.dest_node.define_singleton_method(:dest_path) {path}
|
32
32
|
@context.website.config.update('content_processor.tikz.resolution' => res,
|
33
33
|
'content_processor.tikz.transparent' => trans,
|
34
34
|
'content_processor.tikz.libraries' => libs,
|
@@ -37,4 +37,8 @@ class TestContentProcessorTikz < MiniTest::Unit::TestCase
|
|
37
37
|
Webgen::ContentProcessor::Tikz.call(@context)
|
38
38
|
end
|
39
39
|
|
40
|
+
def teardown
|
41
|
+
FileUtils.rm_rf(@website.directory)
|
42
|
+
end
|
43
|
+
|
40
44
|
end
|
@@ -7,9 +7,9 @@ require 'webgen/path'
|
|
7
7
|
class TestDestinationFileSystem < MiniTest::Unit::TestCase
|
8
8
|
|
9
9
|
def setup
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@website.
|
10
|
+
@dir = dir = Dir.mktmpdir('test-webgen')
|
11
|
+
@website = Object.new
|
12
|
+
@website.define_singleton_method(:directory) { dir }
|
13
13
|
end
|
14
14
|
|
15
15
|
def teardown
|
@@ -23,7 +23,6 @@ class TestDestinationFileSystem < MiniTest::Unit::TestCase
|
|
23
23
|
assert_equal('/tmp/hallo', dest.root)
|
24
24
|
dest = Webgen::Destination::FileSystem.new(@website, '../hallo')
|
25
25
|
assert_equal(File.expand_path(File.join(@dir, '../hallo')), dest.root)
|
26
|
-
@website.verify
|
27
26
|
end
|
28
27
|
|
29
28
|
def test_file_methods
|
@@ -17,9 +17,9 @@ class TestItemTrackerMissingNode < MiniTest::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def setup
|
20
|
-
@website =
|
21
|
-
@website.
|
22
|
-
@website.
|
20
|
+
@website = OpenStruct.new
|
21
|
+
@website.tree = StubTree.new
|
22
|
+
@website.blackboard = Webgen::Blackboard.new
|
23
23
|
@obj = Webgen::ItemTracker::MissingNode.new(@website)
|
24
24
|
end
|
25
25
|
|
@@ -6,12 +6,14 @@ require 'webgen/item_tracker/node_content'
|
|
6
6
|
class TestNodeContent < MiniTest::Unit::TestCase
|
7
7
|
|
8
8
|
def setup
|
9
|
-
@website =
|
9
|
+
@website = Object.new
|
10
10
|
@obj = Webgen::ItemTracker::NodeContent.new(@website)
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_item_id
|
14
|
-
|
14
|
+
s = 'id'
|
15
|
+
def s.alcn; self; end
|
16
|
+
assert_equal('id', @obj.item_id(s))
|
15
17
|
end
|
16
18
|
|
17
19
|
def test_item_data
|
@@ -19,19 +21,14 @@ class TestNodeContent < MiniTest::Unit::TestCase
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_item_changed?
|
22
|
-
|
23
|
-
item_tracker
|
24
|
-
ext
|
25
|
-
|
26
|
-
@website.
|
27
|
-
@website.expect(:tree, {'alcn' => :node})
|
24
|
+
ext = OpenStruct.new
|
25
|
+
ext.item_tracker = Object.new
|
26
|
+
ext.item_tracker.define_singleton_method(:node_changed?) {|n| raise unless n == :node; true}
|
27
|
+
@website.define_singleton_method(:ext) { ext }
|
28
|
+
@website.define_singleton_method(:tree) { {'alcn' => :node} }
|
28
29
|
|
29
30
|
assert(@obj.item_changed?('unknown', 'old'))
|
30
31
|
assert(@obj.item_changed?('alcn', 'other'))
|
31
|
-
|
32
|
-
@website.verify
|
33
|
-
item_tracker.verify
|
34
|
-
ext.verify
|
35
32
|
end
|
36
33
|
|
37
34
|
def test_referenced_nodes
|
@@ -6,16 +6,17 @@ require 'webgen/item_tracker/node_meta_info'
|
|
6
6
|
class TestNodeMetaInfo < MiniTest::Unit::TestCase
|
7
7
|
|
8
8
|
def setup
|
9
|
-
@website =
|
10
|
-
@node =
|
11
|
-
@node.
|
12
|
-
@website.
|
9
|
+
@website = Object.new
|
10
|
+
@node = node = Object.new
|
11
|
+
@node.define_singleton_method(:meta_info) { {'key' => 'value'} }
|
12
|
+
@website.define_singleton_method(:tree) { {'alcn' => node} }
|
13
13
|
@obj = Webgen::ItemTracker::NodeMetaInfo.new(@website)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_item_id
|
17
|
-
|
18
|
-
assert_equal(['id',
|
17
|
+
@node.define_singleton_method(:alcn) { 'id' }
|
18
|
+
assert_equal(['id', nil], @obj.item_id(@node))
|
19
|
+
assert_equal(['id', 'key'], @obj.item_id(@node, 'key'))
|
19
20
|
end
|
20
21
|
|
21
22
|
def test_item_data
|
@@ -23,17 +24,12 @@ class TestNodeMetaInfo < MiniTest::Unit::TestCase
|
|
23
24
|
refute_same(@node.meta_info, @obj.item_data('alcn'))
|
24
25
|
assert_equal('value', @obj.item_data('alcn', 'key'))
|
25
26
|
refute_same(@node.meta_info['key'], @obj.item_data('alcn', 'key'))
|
26
|
-
@website.verify
|
27
|
-
@node.verify
|
28
27
|
end
|
29
28
|
|
30
29
|
def test_item_changed?
|
31
|
-
@node.expect(:nil?, false)
|
32
30
|
assert(@obj.item_changed?(['unknown', nil], 'old'))
|
33
31
|
assert(@obj.item_changed?(['alcn', nil], {"key" => 'value', 'other' => 'new'}))
|
34
32
|
assert(@obj.item_changed?(['alcn', 'key'], 'new'))
|
35
|
-
@website.verify
|
36
|
-
@node.verify
|
37
33
|
end
|
38
34
|
|
39
35
|
def test_referenced_nodes
|
@@ -9,7 +9,7 @@ class TestItemTrackerNodes < MiniTest::Unit::TestCase
|
|
9
9
|
include Webgen::TestHelper
|
10
10
|
|
11
11
|
def self.node_list(website, options)
|
12
|
-
website.tree.root.children
|
12
|
+
website.tree.root.children.select {|c| c.alcn =~ /^\/file/}
|
13
13
|
end
|
14
14
|
|
15
15
|
def setup
|
@@ -17,7 +17,7 @@ class TestItemTrackerNodes < MiniTest::Unit::TestCase
|
|
17
17
|
@website.ext.node_finder = Webgen::NodeFinder.new(@website)
|
18
18
|
@obj = Webgen::ItemTracker::Nodes.new(@website)
|
19
19
|
@args1 = [['TestItemTrackerNodes', 'node_list'], {}, :meta_info]
|
20
|
-
@args2 = [:node_finder_option_set, {:opts => {:alcn => '/file*'}, :ref_alcn => '/'}, :meta_info]
|
20
|
+
@args2 = [:node_finder_option_set, {:opts => {:alcn => ['/file.de*', '/file.*.html']}, :ref_alcn => '/'}, :meta_info]
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_item_id
|
@@ -28,10 +28,10 @@ class TestItemTrackerNodes < MiniTest::Unit::TestCase
|
|
28
28
|
def test_item_data
|
29
29
|
setup_default_nodes(@website.tree)
|
30
30
|
|
31
|
-
assert_equal(["/file.en.html", "/file.de.html"
|
31
|
+
assert_equal(["/file.en.html", "/file.de.html"],
|
32
32
|
@obj.item_data(*@args1))
|
33
33
|
|
34
|
-
assert_equal([
|
34
|
+
assert_equal(["/file.en.html",
|
35
35
|
["/file.de.html", ["/file.de.html#frag"]]],
|
36
36
|
@obj.item_data(*@args2))
|
37
37
|
end
|
@@ -39,13 +39,19 @@ class TestItemTrackerNodes < MiniTest::Unit::TestCase
|
|
39
39
|
def test_item_changed?
|
40
40
|
setup_default_nodes(@website.tree)
|
41
41
|
@website.ext.item_tracker = MiniTest::Mock.new
|
42
|
-
|
42
|
+
2.times do
|
43
|
+
@website.ext.item_tracker.expect(:item_changed?, false, [:node_meta_info, @website.tree['/file.en.html']])
|
44
|
+
@website.ext.item_tracker.expect(:item_changed?, false, [:node_meta_info, @website.tree['/file.de.html']])
|
45
|
+
end
|
46
|
+
@website.ext.item_tracker.expect(:item_changed?, false, [:node_meta_info, @website.tree['/file.de.html#frag']])
|
43
47
|
|
44
48
|
[@args1, @args2].each do |args|
|
45
49
|
old_data = @obj.item_data(*args)
|
46
50
|
assert(@obj.item_changed?(args, []))
|
47
51
|
refute(@obj.item_changed?(args, old_data))
|
48
52
|
end
|
53
|
+
|
54
|
+
@website.ext.item_tracker.verify
|
49
55
|
end
|
50
56
|
|
51
57
|
def test_referenced_nodes
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'webgen/test_helper'
|
4
|
+
require 'webgen/path_handler/api'
|
5
|
+
|
6
|
+
class TestPathHandlerApi < MiniTest::Unit::TestCase
|
7
|
+
|
8
|
+
include Webgen::TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
setup_website('website.lang' => 'en')
|
12
|
+
|
13
|
+
@api = Webgen::PathHandler::Api.new(@website)
|
14
|
+
|
15
|
+
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
16
|
+
|
17
|
+
@path = Webgen::Path.new('/test.api', 'dest_path' => '<parent><basename><ext>',
|
18
|
+
'api_name' => 'my_api',
|
19
|
+
'dir_name' => 'my_dir',
|
20
|
+
'prefix_for_link_defs' => true,
|
21
|
+
'rdoc_options' => ['-t', 'Title', __FILE__])
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
FileUtils.rm_rf(@website.directory)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_nodes
|
29
|
+
@website.ext.path_handler = Webgen::PathHandler.new(@website)
|
30
|
+
@website.ext.path_handler.register('Directory')
|
31
|
+
@website.ext.path_handler.register('Page')
|
32
|
+
@website.ext.path_handler.register('Copy')
|
33
|
+
@website.ext.link_definitions = {}
|
34
|
+
@api.create_nodes(@path, nil)
|
35
|
+
|
36
|
+
assert(@website.tree['/my_dir/TestPathHandlerApi.en.html'])
|
37
|
+
assert_equal(['/my_dir/TestPathHandlerApi.en.html', 'TestPathHandlerApi'],
|
38
|
+
@website.ext.link_definitions['my_api:TestPathHandlerApi'])
|
39
|
+
assert(@website.tree['/my_dir/TestPathHandlerApi.en.html#method-i-setup'])
|
40
|
+
assert_equal(['/my_dir/TestPathHandlerApi.en.html#method-i-setup', 'TestPathHandlerApi#setup'],
|
41
|
+
@website.ext.link_definitions['my_api:TestPathHandlerApi#setup'])
|
42
|
+
|
43
|
+
cache_dir = @website.tmpdir(File.join('path_handler.api', 'my_api'))
|
44
|
+
assert(File.directory?(cache_dir))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_rdoc_options
|
48
|
+
data_methods = [:verbosity, :dry_run, :update_output_dir,
|
49
|
+
:force_output, :files]
|
50
|
+
result = [0, false, true, false, [__FILE__]]
|
51
|
+
|
52
|
+
options = @api.send(:rdoc_options, @path['rdoc_options'])
|
53
|
+
assert_equal(result, data_methods.map {|m| options.send(m)})
|
54
|
+
|
55
|
+
options = @api.send(:rdoc_options, @path['rdoc_options'].join(' '))
|
56
|
+
assert_equal(result, data_methods.map {|m| options.send(m)})
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_rdoc_store
|
60
|
+
options = @api.send(:rdoc_options, @path['rdoc_options'])
|
61
|
+
store = @api.send(:rdoc_store, options, 'dir')
|
62
|
+
|
63
|
+
data = [store.dry_run, store.main, store.title, store.path]
|
64
|
+
result = [false, nil, 'Title', 'dir']
|
65
|
+
|
66
|
+
assert_equal(result, data)
|
67
|
+
end
|
68
|
+
|
69
|
+
=begin
|
70
|
+
def create_nodes
|
71
|
+
@path['version'] = 'atom'
|
72
|
+
atom_node = @feed.create_nodes(@path.dup, @path_blocks)
|
73
|
+
@path['version'] = 'rss'
|
74
|
+
rss_node = @feed.create_nodes(@path.dup, @path_blocks)
|
75
|
+
[atom_node, rss_node]
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_create_node
|
79
|
+
atom_node, rss_node = create_nodes
|
80
|
+
|
81
|
+
refute_nil(atom_node)
|
82
|
+
refute_nil(rss_node)
|
83
|
+
refute_nil(atom_node.node_info[:blocks])
|
84
|
+
assert_equal('atom', atom_node['version'])
|
85
|
+
assert_equal('rss', rss_node['version'])
|
86
|
+
|
87
|
+
assert_raises(Webgen::NodeCreationError) do
|
88
|
+
path = Webgen::Path.new('/test_feed_2') { StringIO.new("---\nunknow: yes") }
|
89
|
+
@feed.create_nodes(path, 'unused')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_content
|
94
|
+
@website.ext.content_processor = Webgen::ContentProcessor.new
|
95
|
+
@website.ext.content_processor.register('Erb')
|
96
|
+
@website.ext.content_processor.register('Blocks')
|
97
|
+
|
98
|
+
atom_node, rss_node = create_nodes
|
99
|
+
assert_equal("hallo\n", @feed.content(rss_node))
|
100
|
+
assert(@feed.content(atom_node) =~ /Thomas Leitner/)
|
101
|
+
assert(@feed.content(atom_node) =~ /RealContent/)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_feed_entries
|
105
|
+
atom_node, rss_node = create_nodes
|
106
|
+
assert_equal([@index_en, @file_en], atom_node.feed_entries)
|
107
|
+
assert_equal([@index_en, @file_en], rss_node.feed_entries)
|
108
|
+
end
|
109
|
+
=end
|
110
|
+
|
111
|
+
end
|
@@ -27,7 +27,7 @@ class TestPageUtils < MiniTest::Unit::TestCase
|
|
27
27
|
|
28
28
|
def test_template_chain
|
29
29
|
setup_website('path_handler.default_template' => 'default.template')
|
30
|
-
@website.
|
30
|
+
@website.cache = Webgen::Cache.new
|
31
31
|
@root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
32
32
|
|
33
33
|
default_template = MyHandler::Node.new(@root, 'default.template', '/default.template')
|
@@ -9,9 +9,9 @@ require 'webgen/source/file_system'
|
|
9
9
|
class TestSourceFileSystem < MiniTest::Unit::TestCase
|
10
10
|
|
11
11
|
def setup
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@website.
|
12
|
+
@root = root = File.expand_path(File.dirname(__FILE__))
|
13
|
+
@website = Object.new
|
14
|
+
@website.define_singleton_method(:directory) { root }
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_initialize
|
@@ -9,14 +9,13 @@ class TestTagCoderay < MiniTest::Unit::TestCase
|
|
9
9
|
|
10
10
|
def test_call
|
11
11
|
setup_context
|
12
|
-
@website.ext.content_processor =
|
13
|
-
@website.ext.content_processor.
|
12
|
+
@website.ext.content_processor = Object.new
|
13
|
+
@website.ext.content_processor.define_singleton_method(:call) {|_, context| context}
|
14
14
|
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/', {'title' => 'Hallo'})
|
15
15
|
@context[:chain] = [root]
|
16
16
|
|
17
17
|
assert_result_includes('TestData', @context, 'TestData', 'html', false, 'style')
|
18
|
-
@context
|
19
|
-
assert_result_includes('Hallo', @context, '{title:}', :ruby, true, 'other')
|
18
|
+
assert_result_includes('title', @context, '{title:}', :ruby, true, 'other')
|
20
19
|
assert_result_includes('class="constant"', @context, 'TestData', 'ruby', false, 'other')
|
21
20
|
end
|
22
21
|
|
@@ -20,6 +20,9 @@ class TestTagMetaInfo < MiniTest::Unit::TestCase
|
|
20
20
|
|
21
21
|
@context[:config] = {'tag.meta_info.escape_html' => false}
|
22
22
|
assert_equal("value <br />", Webgen::Tag::MetaInfo.call('key', '', @context))
|
23
|
+
|
24
|
+
@context[:config] = {'tag.meta_info.mi' => 'key'}
|
25
|
+
assert_equal("value <br />", Webgen::Tag::MetaInfo.call('meta_info', '', @context))
|
23
26
|
end
|
24
27
|
|
25
28
|
end
|
@@ -38,8 +38,8 @@ class TestTaskCreateWebsite < MiniTest::Unit::TestCase
|
|
38
38
|
assert(File.directory?(@website.directory))
|
39
39
|
assert(File.directory?(File.join(@website.directory, 'tmp')))
|
40
40
|
assert_equal(tmpdir, File.read(File.join(@website.directory, 'tmp', 'test.txt')))
|
41
|
-
|
42
|
-
|
41
|
+
assert(File.directory?(File.join(@website.directory, 'src')))
|
42
|
+
assert(File.file?(File.join(@website.directory, 'webgen.config')))
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -4,6 +4,7 @@ require 'minitest/autorun'
|
|
4
4
|
require 'webgen/item_tracker'
|
5
5
|
require 'webgen/blackboard'
|
6
6
|
require 'webgen/cache'
|
7
|
+
require 'webgen/node'
|
7
8
|
|
8
9
|
class Webgen::ItemTracker::Sample
|
9
10
|
|
@@ -31,22 +32,19 @@ end
|
|
31
32
|
|
32
33
|
class TestItemTracker < MiniTest::Unit::TestCase
|
33
34
|
|
35
|
+
DummyNode = Struct.new(:alcn)
|
36
|
+
|
34
37
|
Data = {'/alcn' => 'mydata'}
|
35
38
|
|
36
39
|
def test_functionality
|
37
|
-
# Needed
|
38
|
-
website =
|
39
|
-
website.
|
40
|
-
website.
|
41
|
-
|
42
|
-
node.
|
43
|
-
|
44
|
-
node
|
45
|
-
other = MiniTest::Mock.new
|
46
|
-
other.expect(:alcn, '/other')
|
47
|
-
other.expect(:!, false)
|
48
|
-
other.expect(:hash, 12346)
|
49
|
-
website.expect(:tree, {'/alcn' => node, '/other' => other})
|
40
|
+
# Needed stub objects
|
41
|
+
website = Struct.new(:blackboard, :cache, :tree).new
|
42
|
+
website.blackboard = blackboard = Webgen::Blackboard.new
|
43
|
+
website.cache = cache = Webgen::Cache.new
|
44
|
+
|
45
|
+
node = DummyNode.new('/alcn')
|
46
|
+
other = DummyNode.new('/other')
|
47
|
+
website.tree = {'/alcn' => node, '/other' => other}
|
50
48
|
|
51
49
|
tracker = Webgen::ItemTracker.new(website)
|
52
50
|
tracker.register('Sample')
|
@@ -101,9 +99,6 @@ class TestItemTracker < MiniTest::Unit::TestCase
|
|
101
99
|
blackboard.dispatch_msg(:after_all_nodes_written)
|
102
100
|
|
103
101
|
assert(tracker.node_referenced?(node))
|
104
|
-
|
105
|
-
website.verify
|
106
|
-
node.verify
|
107
102
|
end
|
108
103
|
|
109
104
|
end
|
data/test/webgen/test_node.rb
CHANGED
@@ -99,6 +99,8 @@ class TestNode < MiniTest::Unit::TestCase
|
|
99
99
|
|
100
100
|
n = Webgen::Node.new(tree['/'], 'testing', '../../.././dir2')
|
101
101
|
assert_equal('../dir2', tree['/dir/subfile.html'].route_to(n))
|
102
|
+
|
103
|
+
assert_equal('../routed.html', tree['/dir2/index.en.html'].route_to(tree['/file.en.html#nested']))
|
102
104
|
end
|
103
105
|
|
104
106
|
def test_proxy_node
|
@@ -55,12 +55,17 @@ class TestNodeFinder < MiniTest::Unit::TestCase
|
|
55
55
|
],
|
56
56
|
@nf.find({:levels => [2,3]}, tree['/']))
|
57
57
|
|
58
|
-
# test sort
|
58
|
+
# test sort and reverse
|
59
59
|
check.call(%w[/file.en.html /file.de.html /dir/dir/file.html /german.de.html /dir2/index.de.html
|
60
60
|
/dir2/index.en.html /other.html /other.en.html /dir/subfile.html],
|
61
61
|
@nf.find({:alcn => '/**/*.html', :flatten => true, :sort => true}, tree['/']))
|
62
|
+
check.call(%w[/dir/subfile.html /other.en.html /other.html /dir2/index.en.html /dir2/index.de.html
|
63
|
+
/german.de.html /dir/dir/file.html /file.de.html /file.en.html],
|
64
|
+
@nf.find({:alcn => '/**/*.html', :flatten => true, :sort => true, :reverse => true}, tree['/']))
|
62
65
|
check.call(%w[/german.de.html /other.en.html /other.html /file.en.html /file.de.html],
|
63
66
|
@nf.find({:alcn => '/*.html', :flatten => true, :sort => 'sort_info'}, tree['/']))
|
67
|
+
check.call(%w[/file.de.html /file.en.html /other.html /other.en.html /german.de.html],
|
68
|
+
@nf.find({:alcn => '/*.html', :flatten => true, :sort => 'sort_info', :reverse => true}, tree['/']))
|
64
69
|
check.call(%w[/dir/dir/file.html /file.de.html /file.en.html /german.de.html /dir2/index.de.html /dir2/index.en.html
|
65
70
|
/other.html /other.en.html /dir/subfile.html],
|
66
71
|
@nf.find({:alcn => '/**/*.html', :name => 'test', :flatten => true, :sort => 'title'}, tree['/']))
|
@@ -72,6 +77,14 @@ class TestNodeFinder < MiniTest::Unit::TestCase
|
|
72
77
|
tree['/german.de.html'], tree['/other.html'], tree['/other.en.html'],
|
73
78
|
],
|
74
79
|
@nf.find({:levels => [2,4], :sort => true}, tree['/']))
|
80
|
+
assert_equal([tree['/other.en.html'], tree['/other.html'], tree['/german.de.html'],
|
81
|
+
[tree['/dir2/'], [tree['/dir2/index.en.html'], tree['/dir2/index.de.html']]],
|
82
|
+
[tree['/dir/'], [[tree['/dir/subfile.html'], [tree['/dir/subfile.html#frag']]],
|
83
|
+
[tree['/dir/dir/'], [tree['/dir/dir/file.html']]]]],
|
84
|
+
[tree['/file.de.html'], [tree['/file.de.html#frag']]],
|
85
|
+
[tree['/file.en.html'], [[tree['/file.en.html#frag'], [tree['/file.en.html#nested']]]]],
|
86
|
+
],
|
87
|
+
@nf.find({:levels => [2,4], :sort => true, :reverse => true}, tree['/']))
|
75
88
|
|
76
89
|
# test filter: meta info keys/values
|
77
90
|
check.call(['/file.en.html#frag', '/file.de.html#frag', '/dir/subfile.html#frag'],
|
@@ -97,6 +110,11 @@ class TestNodeFinder < MiniTest::Unit::TestCase
|
|
97
110
|
@nf.find({:absolute_levels => [0, 0], :flatten => true}, tree['/dir/']))
|
98
111
|
check.call(%w[/file.en.html#nested /dir/subfile.html#frag /dir/dir/file.html],
|
99
112
|
@nf.find({:absolute_levels => [3,3], :flatten => true}, tree['/dir/']))
|
113
|
+
check.call(%w[/file.en.html#frag /file.en.html#nested /file.de.html#frag /dir/subfile.html
|
114
|
+
/dir/subfile.html#frag /dir/dir/ /dir/dir/file.html /dir2/index.en.html /dir2/index.de.html],
|
115
|
+
@nf.find({:absolute_levels => [2,-1], :flatten => true}, tree['/dir/dir/file.html']))
|
116
|
+
check.call(%w[/file.en.html#frag /file.de.html#frag /dir/subfile.html /dir/dir/ /dir2/index.en.html /dir2/index.de.html],
|
117
|
+
@nf.find({:absolute_levels => [2,-2], :flatten => true}, tree['/dir/dir/file.html']))
|
100
118
|
check.call(%w[/ /file.en.html /file.de.html /other.html /other.en.html /german.de.html /dir/ /dir2/],
|
101
119
|
@nf.find({:absolute_levels => [0,1], :flatten => true}, tree['/dir/']))
|
102
120
|
check.call(%w[/],
|
@@ -110,7 +128,7 @@ class TestNodeFinder < MiniTest::Unit::TestCase
|
|
110
128
|
check.call(%w[/file.en.html /file.de.html /other.en.html /german.de.html /dir2/index.en.html /dir2/index.de.html],
|
111
129
|
@nf.find({:lang => ['en', 'de'], :flatten => true}, tree['/dir/']))
|
112
130
|
check.call(%w[/file.en.html /other.en.html /dir2/index.en.html],
|
113
|
-
@nf.find({:lang =>
|
131
|
+
@nf.find({:lang => 'node', :flatten => true}, tree['/file.en.html']))
|
114
132
|
|
115
133
|
# test filter: ancestors
|
116
134
|
check.call(%w[/ /dir/ /dir/dir/ /dir/dir/file.html],
|
@@ -125,6 +143,16 @@ class TestNodeFinder < MiniTest::Unit::TestCase
|
|
125
143
|
# test filter: siblings
|
126
144
|
check.call(%w[/file.en.html /file.de.html /other.html /other.en.html /german.de.html /dir/ /dir2/],
|
127
145
|
@nf.find({:siblings => true, :flatten => true}, tree['/dir/']))
|
146
|
+
check.call(%w[/dir/subfile.html /dir/dir/ /dir/dir/file.html],
|
147
|
+
@nf.find({:siblings => [2, 3], :flatten => true}, tree['/dir/dir/file.html']))
|
148
|
+
check.call(%w[/dir/subfile.html /dir/dir/ /dir/dir/file.html],
|
149
|
+
@nf.find({:siblings => [2, -1], :flatten => true}, tree['/dir/dir/file.html']))
|
150
|
+
check.call(%w[/file.en.html /file.de.html /other.html /other.en.html /german.de.html
|
151
|
+
/dir/ /dir/subfile.html /dir/dir/ /dir/dir/file.html /dir2/],
|
152
|
+
@nf.find({:siblings => [1, 5], :flatten => true}, tree['/dir/dir/file.html']))
|
153
|
+
check.call(%w[/ /file.en.html /file.de.html /other.html /other.en.html /german.de.html
|
154
|
+
/dir/ /dir/subfile.html /dir/dir/ /dir2/],
|
155
|
+
@nf.find({:siblings => [0, 2], :flatten => true}, tree['/dir/dir/file.html']))
|
128
156
|
|
129
157
|
end
|
130
158
|
|