dokkit 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +15 -1
- data/LICENSE +673 -19
- data/README +32 -0
- data/Rakefile +59 -25
- data/bin/dokkit +48 -38
- data/lib/dokkit/#render_task_factory.rb# +94 -0
- data/lib/dokkit/app.rb +212 -257
- data/lib/dokkit/deplate/fmt/latex-notemplate.rb +3 -1
- data/lib/dokkit/dokkittasks.rb +45 -15
- data/lib/dokkit/filters/deplate.rb +11 -5
- data/lib/dokkit/hash.rb +41 -0
- data/lib/dokkit/models/Rakefile.tpl +9 -0
- data/lib/dokkit/models/share/builtin.rf +28 -0
- data/lib/dokkit/page.rb +161 -20
- data/lib/dokkit/render_task_factory.rb +91 -0
- data/lib/dokkit.rb +35 -42
- data/tests/data/output/simple_document/README +57 -0
- data/tests/data/output/simple_document/Rakefile +7 -0
- data/tests/data/output/simple_document/doc/config/simple_document.yaml +5 -0
- data/tests/data/output/simple_document/doc/pages/simple_document.dpl +12 -0
- data/{lib/dokkit/projects/website → tests/data/output/website_project}/Rakefile +2 -1
- data/tests/data/projects/simple-document/README +57 -0
- data/tests/data/projects/simple-document/Rakefile +22 -0
- data/tests/data/projects/simple-document/doc/config/author.yaml +4 -0
- data/tests/data/projects/simple-document/doc/config/model.yaml +18 -0
- data/tests/data/projects/simple-document/doc/config/simple_document.yaml +6 -0
- data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +8 -0
- data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +10 -0
- data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +8 -0
- data/tests/data/projects/simple-document/doc/layouts/semantic.cache +23 -0
- data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +23 -0
- data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +4 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +3 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +2 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +8 -0
- data/tests/spec_page.rb +25 -0
- data/tests/test.rb +2 -0
- data/tests/test_application.rb +40 -0
- data/tests/test_builtin_tasks.rb +37 -0
- data/tests/test_config.rb +108 -0
- data/tests/test_core.rb +12 -0
- data/tests/test_dokkit_commandline.rb +18 -0
- data/tests/test_exception.rb +7 -0
- data/tests/test_filters.rb +1 -1
- data/tests/test_layout.rb +64 -0
- data/tests/test_options.rb +33 -0
- data/tests/test_project_tasks.rb +48 -0
- data/tests/test_recursive_merge.rb +42 -0
- data/tests/test_task_factory.rb +38 -0
- metadata +138 -94
- data/Rakefile.old +0 -62
- data/lib/dokkit/builtin.rake +0 -55
- data/lib/dokkit/projects/invoice/Rakefile +0 -100
- data/lib/dokkit/projects/invoice/doc/config/company.yaml +0 -12
- data/lib/dokkit/projects/invoice/doc/config/customer.yaml +0 -4
- data/lib/dokkit/projects/invoice/doc/layouts/invoice.dpltex +0 -90
- data/lib/dokkit/projects/invoice/doc/pages/COMMON.rb +0 -12
- data/lib/dokkit/projects/invoice/doc/pages/invoice.rb +0 -5
- data/lib/dokkit/projects/invoice/doc/pages/invoice.yamltex +0 -16
- data/lib/dokkit/projects/invoice/doc/res/tex/deplate.sty +0 -46
- data/lib/dokkit/projects/invoice/doc/res/tex/images/logo.eps +0 -209
- data/lib/dokkit/projects/invoice/doc/res/tex/include/deplate.sty +0 -46
- data/lib/dokkit/projects/invoice/doc/res/tex/include/layout.inc +0 -24
- data/lib/dokkit/projects/invoice/doc/res/tex/include/macro.inc +0 -67
- data/lib/dokkit/projects/invoice/doc/res/tex/include/packages.inc +0 -51
- data/lib/dokkit/projects/invoice/lib/invoice.rb +0 -104
- data/lib/dokkit/projects/tech_report/README +0 -49
- data/lib/dokkit/projects/tech_report/Rakefile +0 -102
- data/lib/dokkit/projects/tech_report/doc/config/company.yaml +0 -13
- data/lib/dokkit/projects/tech_report/doc/config/tech_report.yaml +0 -3
- data/lib/dokkit/projects/tech_report/doc/layouts/report.dpltex +0 -40
- data/lib/dokkit/projects/tech_report/doc/pages/COMMON.rb +0 -12
- data/lib/dokkit/projects/tech_report/doc/pages/report.dpltex +0 -37
- data/lib/dokkit/projects/tech_report/doc/pages/report.inc +0 -2
- data/lib/dokkit/projects/tech_report/doc/pages/report.rb +0 -3
- data/lib/dokkit/projects/tech_report/doc/res/attachments/attachment_2 +0 -0
- data/lib/dokkit/projects/tech_report/doc/res/tex/images/logo.eps +0 -311
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/deplate.sty +0 -46
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/layout.inc +0 -24
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/macro.inc +0 -67
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/packages.inc +0 -48
- data/lib/dokkit/projects/tech_report/doc/res/tex/report.bib +0 -4
- data/lib/dokkit/projects/tech_report/lib/tech_report.rb +0 -17
- data/lib/dokkit/projects/website/README +0 -49
- /data/{lib/dokkit/projects/invoice → tests/data/output/website_project}/README +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/layouts/normal.thtml +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/COMMON.rb +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/deplate.dplhtml +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.rb +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.thtml +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/res/images/rote-tiny.png +0 -0
- /data/{lib/dokkit/projects/tech_report/doc/res/attachments/attachment_1 → tests/pages/test.dpltex} +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
#----------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# model.yaml created on 19 set 2007 at 22:37:25.
|
4
|
+
# See 'dokkit.rb' or LICENSE for licence information.
|
5
|
+
#
|
6
|
+
# (c)2007 Andrea Fazzi (and contributors).
|
7
|
+
#
|
8
|
+
# This is a config file for the current document. This file is written
|
9
|
+
# using YAML so you can easily modify it using YAML syntax. For further
|
10
|
+
# information about YAML please visit http://yaml.org.
|
11
|
+
#
|
12
|
+
#----------------------------------------------------------------------
|
13
|
+
|
14
|
+
model:
|
15
|
+
name: simpledocument
|
16
|
+
version: 0.1.0
|
17
|
+
language: en
|
18
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
;; Object layouts/
|
2
|
+
;; SEMANTICDB Tags save file
|
3
|
+
(semanticdb-project-database-file "layouts/"
|
4
|
+
:tables (list
|
5
|
+
(semanticdb-table "layout_with_custom_name.html"
|
6
|
+
:major-mode 'html-mode
|
7
|
+
:tags '(("" section nil nil [81 142]) ("" section nil nil [142 147]))
|
8
|
+
:file "layout_with_custom_name.html"
|
9
|
+
:pointmax 194
|
10
|
+
:unmatched-syntax 'nil
|
11
|
+
)
|
12
|
+
(semanticdb-table "another_simple_document.html"
|
13
|
+
:major-mode 'html-mode
|
14
|
+
:tags '(("" section nil nil [64 125]) ("" section nil nil [125 130]))
|
15
|
+
:file "another_simple_document.html"
|
16
|
+
:pointmax 177
|
17
|
+
:unmatched-syntax 'nil
|
18
|
+
)
|
19
|
+
)
|
20
|
+
:file "semantic.cache"
|
21
|
+
:semantic-tag-version "2.0pre3"
|
22
|
+
:semanticdb-version "2.0pre3"
|
23
|
+
)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# COMMON.yaml created on 01 ott 2007 at 15:21:20.
|
4
|
+
# See 'dokkit.rb' or LICENSE for licence information.
|
5
|
+
#
|
6
|
+
# (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
7
|
+
#
|
8
|
+
# This is a config file for the current document. This file is written
|
9
|
+
# using YAML so you can easily modify it using YAML syntax. For further
|
10
|
+
# information about YAML please visit http://yaml.org/.
|
11
|
+
#
|
12
|
+
#-------------------------------------------------------------------------
|
13
|
+
|
14
|
+
document:
|
15
|
+
title: A common title for document in pages dir
|
16
|
+
author:
|
17
|
+
name: John
|
18
|
+
surname: Doe
|
19
|
+
common_key: A common value for documents in pages dir
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
data/tests/spec_page.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require 'dokkit'
|
4
|
+
|
5
|
+
context 'A new page' do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@config_page_complete = { :fn => 'test.dpltex',
|
9
|
+
:layout_dir => 'layouts/',
|
10
|
+
:pages_dir => 'pages/',
|
11
|
+
:config_dir => 'config'
|
12
|
+
}
|
13
|
+
|
14
|
+
@config_page_incomplete = { :fn => 'test.dpltex', :pages_dir => 'pages/' }
|
15
|
+
end
|
16
|
+
|
17
|
+
specify 'should be correctly initialized if fn, layout_dir, pages_dir and config_dir are given' do
|
18
|
+
Rote::Page.new(@config_page_complete)
|
19
|
+
end
|
20
|
+
|
21
|
+
specify 'should have correct defaults for pages_dir, layout_dir and config_dir' do
|
22
|
+
Rote::Page.new(@config_page_incomplete)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/tests/test.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# File 'test_application.rb' created on 22 Oct 2007 at 16:25:05.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this unit test run:
|
8
|
+
#
|
9
|
+
# ruby test/test_application.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'test/unit'
|
14
|
+
require 'dokkit'
|
15
|
+
require 'dokkit/app'
|
16
|
+
|
17
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
18
|
+
|
19
|
+
class TestApplication < Test::Unit::TestCase
|
20
|
+
def setup
|
21
|
+
end
|
22
|
+
def teardown
|
23
|
+
end
|
24
|
+
# The tests below need dokkit-model-simple-document gem to pass.
|
25
|
+
# Run:
|
26
|
+
# $ gem install dokkit-model-simpledocument
|
27
|
+
# to install the simpledocument model.
|
28
|
+
def test_fetch_models
|
29
|
+
assert(File.exists?(Dokkit.fetch_models['simple-document']))
|
30
|
+
end
|
31
|
+
def test_model_dir
|
32
|
+
assert(File.exists?(Dokkit.model_dir('simple-document')))
|
33
|
+
end
|
34
|
+
def test_model_layout_dir
|
35
|
+
assert(File.exists?(Dokkit.model_layout_dir('simple-document')))
|
36
|
+
end
|
37
|
+
def test_config_dir
|
38
|
+
assert(File.exists?(Dokkit.model_config_dir('simple-document')))
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'dokkit'
|
4
|
+
require 'dokkit/app'
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
9
|
+
|
10
|
+
class TestBuiltinTask < Test::Unit::TestCase
|
11
|
+
OUTPUT_DIR = 'tests/data/output'
|
12
|
+
def setup
|
13
|
+
ARGV.clear
|
14
|
+
end
|
15
|
+
def test_builtin_task
|
16
|
+
Dokkit.application.init
|
17
|
+
Dokkit.application.define_builtin_tasks
|
18
|
+
assert_equal('create', Dokkit.application['create'].to_s)
|
19
|
+
end
|
20
|
+
def test_create_default_project_task
|
21
|
+
Dokkit.application.init
|
22
|
+
Dokkit.application.define_builtin_tasks
|
23
|
+
ARGV.push("create", "#{OUTPUT_DIR}/simple_document")
|
24
|
+
Dokkit.application.run
|
25
|
+
dir_content = Dir["#{OUTPUT_DIR}/simple_document/*"]
|
26
|
+
assert(!dir_content.empty? && !dir_content.include?('lib'))
|
27
|
+
end
|
28
|
+
def test_create_website_task
|
29
|
+
Dokkit.application.init
|
30
|
+
Dokkit.application.do_option('--project',"website")
|
31
|
+
Dokkit.application.define_builtin_tasks
|
32
|
+
ARGV.push("create", "#{OUTPUT_DIR}/website_project")
|
33
|
+
Dokkit.application.run
|
34
|
+
assert(Dir["#{OUTPUT_DIR}/website_project/*"].size > 1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'dokkit'
|
4
|
+
require 'dokkit/app'
|
5
|
+
require 'dokkit/page'
|
6
|
+
require 'rake'
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
9
|
+
|
10
|
+
class TestConfig < Test::Unit::TestCase
|
11
|
+
PROJECT_DIR = File.join(Dokkit.tests_dir, 'data/projects/simple-document/')
|
12
|
+
def setup
|
13
|
+
Dir.chdir PROJECT_DIR
|
14
|
+
@simple_document = Rote::Page.new(
|
15
|
+
{
|
16
|
+
:fn => 'simple_document.dpl',
|
17
|
+
:pages_dir => 'doc/pages',
|
18
|
+
:layout_dir => 'doc/layouts',
|
19
|
+
:config_dir => 'doc/config',
|
20
|
+
:layout_defext => '.html',
|
21
|
+
:template_defext => '.dpl'
|
22
|
+
}
|
23
|
+
)
|
24
|
+
|
25
|
+
@simple_document_in_subdir = Rote::Page.new(
|
26
|
+
{
|
27
|
+
:fn => 'subdir/simple_document_in_subdir.dpl',
|
28
|
+
:pages_dir => 'doc/pages',
|
29
|
+
:layout_dir => 'doc/layouts',
|
30
|
+
:config_dir => 'doc/config',
|
31
|
+
:layout_defext => '.html',
|
32
|
+
:template_defext => '.dpl'
|
33
|
+
}
|
34
|
+
)
|
35
|
+
|
36
|
+
@another_simple_document_in_subdir = Rote::Page.new(
|
37
|
+
{
|
38
|
+
:fn => 'subdir/subdir/another_simple_document_in_subdir.dpl',
|
39
|
+
:pages_dir => 'doc/pages',
|
40
|
+
:layout_dir => 'doc/layouts',
|
41
|
+
:config_dir => 'doc/config',
|
42
|
+
:layout_defext => '.html',
|
43
|
+
:template_defext => '.dpl'
|
44
|
+
}
|
45
|
+
)
|
46
|
+
|
47
|
+
@another_simple_document = Rote::Page.new(
|
48
|
+
{
|
49
|
+
:fn => 'another_simple_document.dpl',
|
50
|
+
:pages_dir => 'doc/pages',
|
51
|
+
:layout_dir => 'doc/layouts',
|
52
|
+
:config_dir => 'doc/config',
|
53
|
+
:layout_defext => '.html',
|
54
|
+
:template_defext => '.dpl'
|
55
|
+
}
|
56
|
+
)
|
57
|
+
@yet_another_simple_document = Rote::Page.new(
|
58
|
+
{
|
59
|
+
:fn => 'yet_another_simple_document.dpl',
|
60
|
+
:pages_dir => 'doc/pages',
|
61
|
+
:layout_dir => 'doc/layouts',
|
62
|
+
:config_dir => 'doc/config',
|
63
|
+
:layout_defext => '.html',
|
64
|
+
:template_defext => '.dpl'
|
65
|
+
}
|
66
|
+
)
|
67
|
+
end
|
68
|
+
def test_model_key
|
69
|
+
assert @simple_document.instance_eval { @config['model'] }
|
70
|
+
end
|
71
|
+
def test_model_name_key
|
72
|
+
assert @simple_document.instance_eval { @config['model']['name'] }
|
73
|
+
end
|
74
|
+
def test_model_version_key
|
75
|
+
assert @simple_document.instance_eval { @config['model']['version'] }
|
76
|
+
end
|
77
|
+
def test_simple_document_default_config
|
78
|
+
assert_equal('A simple document', @simple_document.instance_eval { @config['document']['title'] })
|
79
|
+
end
|
80
|
+
def test_simple_document_common
|
81
|
+
assert_nil @simple_document.instance_eval { @config['document']['author']['name'] }
|
82
|
+
assert_equal('A common value for documents in pages dir', @simple_document.instance_eval { @config['document']['common_key'] })
|
83
|
+
end
|
84
|
+
def test_simple_document_in_subdir_config
|
85
|
+
assert_equal('A simple document in a subdirectory', @simple_document_in_subdir.instance_eval { @config['document']['title'] })
|
86
|
+
end
|
87
|
+
def test_simple_document_in_subdir_common
|
88
|
+
assert_equal('A simple document in a subdirectory', @simple_document_in_subdir.instance_eval { @config['document']['title'] })
|
89
|
+
assert_equal('A common value for documents in subdir', @simple_document_in_subdir.instance_eval { @config['document']['common_key'] })
|
90
|
+
assert_equal('John', @simple_document_in_subdir.instance_eval { @config['document']['author']['name'] })
|
91
|
+
end
|
92
|
+
def test_another_simple_document_in_subdir_common
|
93
|
+
assert_equal('A simple document in a subdirectory', @another_simple_document_in_subdir.instance_eval { @config['document']['title'] })
|
94
|
+
assert_equal('A common value for documents in subdir/subdir', @another_simple_document_in_subdir.instance_eval { @config['document']['common_key'] })
|
95
|
+
assert_equal('John', @another_simple_document_in_subdir.instance_eval { @config['document']['author']['name'] })
|
96
|
+
end
|
97
|
+
def test_another_simple_document_layout
|
98
|
+
assert_equal(['another_simple_document.html'], @another_simple_document.instance_eval { @layout_names })
|
99
|
+
end
|
100
|
+
def test_yet_another_simple_document_layout
|
101
|
+
assert_equal(['yet_another_simple_document.html', 'layout_with_custom_name.html'], @yet_another_simple_document.instance_eval { @layout_names })
|
102
|
+
end
|
103
|
+
def test_yet_another_simple_document_common
|
104
|
+
assert_equal('A simple document with layout with custom name', @yet_another_simple_document.instance_eval { @config['document']['title'] })
|
105
|
+
assert_equal('John', @yet_another_simple_document.instance_eval { @config['document']['author']['name'] })
|
106
|
+
assert_equal('john.doe@organization.org', @yet_another_simple_document.instance_eval { @config['document']['author']['email'] })
|
107
|
+
end
|
108
|
+
end
|
data/tests/test_core.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
begin
|
2
|
+
require 'rubygems'
|
3
|
+
rescue LoadError
|
4
|
+
nil
|
5
|
+
end
|
6
|
+
|
7
|
+
# make sure we're testing this version, not an installed Gem!
|
8
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
9
|
+
|
10
|
+
require 'tests/test_builtin_tasks.rb'
|
11
|
+
require 'tests/test_dokkit_commandline.rb'
|
12
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'dokkit'
|
4
|
+
require 'dokkit/app'
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
8
|
+
|
9
|
+
class TestDirectoryOption < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
ARGV.clear
|
12
|
+
ARGV.push('--directory','tests/data/projects/tech_report')
|
13
|
+
end
|
14
|
+
def test_directory_option
|
15
|
+
Dokkit.application.load_rakefile
|
16
|
+
assert_equal('doc', Dokkit.application['doc'].to_s)
|
17
|
+
end
|
18
|
+
end
|
data/tests/test_filters.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# File 'test_layout.rb' created on 15 ott 2007 at 13:24:26.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this unit test run:
|
8
|
+
#
|
9
|
+
# ruby test/test_layout.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'test/unit'
|
14
|
+
require 'dokkit'
|
15
|
+
require 'dokkit/app'
|
16
|
+
require 'dokkit/page'
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
19
|
+
|
20
|
+
class TestLayout < Test::Unit::TestCase
|
21
|
+
PROJECT_DIR = File.join(Dokkit.tests_dir, 'data/projects/simple_document/')
|
22
|
+
def setup
|
23
|
+
Dir.chdir PROJECT_DIR
|
24
|
+
@simple_document = Rote::Page.new(
|
25
|
+
{
|
26
|
+
:fn => 'simple_document.dpl',
|
27
|
+
:pages_dir => 'doc/pages',
|
28
|
+
:layout_dir => 'doc/layouts',
|
29
|
+
:config_dir => 'doc/config',
|
30
|
+
:layout_defext => '.html',
|
31
|
+
:template_defext => '.dpl'
|
32
|
+
}
|
33
|
+
)
|
34
|
+
@simple_document_without_layout = Rote::Page.new(
|
35
|
+
{
|
36
|
+
:fn => 'simple_document_without_layout.dpl',
|
37
|
+
:pages_dir => 'doc/pages',
|
38
|
+
:layout_dir => 'doc/layouts',
|
39
|
+
:config_dir => 'doc/config',
|
40
|
+
:layout_defext => '.html',
|
41
|
+
:template_defext => '.dpl'
|
42
|
+
}
|
43
|
+
)
|
44
|
+
@another_simple_document = Rote::Page.new(
|
45
|
+
{
|
46
|
+
:fn => 'another_simple_document.dpl',
|
47
|
+
:pages_dir => 'doc/pages',
|
48
|
+
:layout_dir => 'doc/layouts',
|
49
|
+
:config_dir => 'doc/config',
|
50
|
+
:layout_defext => '.html',
|
51
|
+
:template_defext => '.dpl'
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
def teardown
|
56
|
+
end
|
57
|
+
def test_default_layout
|
58
|
+
assert_equal(['simple_document.html'], @simple_document.instance_eval { @layout_names })
|
59
|
+
assert_equal(['simple_document.html'], @simple_document_without_layout.instance_eval { @layout_names })
|
60
|
+
end
|
61
|
+
def test_overrided_layout
|
62
|
+
assert_equal(['another_simple_document.html'], @another_simple_document.instance_eval { @layout_names })
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
begin
|
2
|
+
require 'rubygems'
|
3
|
+
rescue LoadError
|
4
|
+
nil
|
5
|
+
end
|
6
|
+
|
7
|
+
# make sure we're testing this version, not an installed Gem!
|
8
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require 'dokkit'
|
12
|
+
require 'dokkit/app'
|
13
|
+
require 'rake'
|
14
|
+
|
15
|
+
# set dokkit_lib path
|
16
|
+
$:.each do |it|
|
17
|
+
if File.exists?(File.join(it,'dokkit/builtin.rake'))
|
18
|
+
DOKKIT_LIB = it
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class TestOption < Test::Unit::TestCase
|
24
|
+
|
25
|
+
def test_change_dir
|
26
|
+
Dokkit::Application.new DOKKIT_LIB do |dokkit|
|
27
|
+
dokkit.do_option('--directory','/home/andrea')
|
28
|
+
dokkit.do_option('--tasks',nil)
|
29
|
+
dokkit.run
|
30
|
+
assert_equal('/home/andrea',Dir.pwd)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# File 'test_project_tasks.rb' created on 09 ott 2007 at 17:04:01.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this unit test run:
|
8
|
+
#
|
9
|
+
# ruby test/test_project_tasks.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'test/unit'
|
14
|
+
require 'dokkit'
|
15
|
+
require 'dokkit/app'
|
16
|
+
require 'rake'
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
|
19
|
+
|
20
|
+
class TestProjectTask < Test::Unit::TestCase
|
21
|
+
PROJECT_DIR = File.join(Dokkit.tests_dir, 'data/projects')
|
22
|
+
def setup
|
23
|
+
end
|
24
|
+
def teardown
|
25
|
+
Dokkit.application.run ['--directory', File.join(PROJECT_DIR, 'simple-document'), 'clobber']
|
26
|
+
end
|
27
|
+
def test_default_render_task
|
28
|
+
Dokkit.application.run ['--directory', File.join(PROJECT_DIR, 'simple-document')]
|
29
|
+
File.open(File.join(PROJECT_DIR, 'simple-document/html/simple_document.html')) do |file|
|
30
|
+
assert_equal('<html>', file.gets.chomp)
|
31
|
+
end
|
32
|
+
File.open(File.join(PROJECT_DIR, 'simple-document/html/another_simple_document.html')) do |file|
|
33
|
+
assert_equal('<html> <!-- Custom layout for simple_document -->', file.gets.chomp)
|
34
|
+
end
|
35
|
+
File.open(File.join(PROJECT_DIR, 'simple-document/html/simple_document_without_layout.html')) do |file|
|
36
|
+
assert_equal('<html>', file.gets.chomp)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
def test_render_tex_task
|
40
|
+
Dokkit.application.run ['--directory', File.join(PROJECT_DIR, 'simple-document'), 'render_tex']
|
41
|
+
File.open(File.join(PROJECT_DIR, 'simple-document/tex/simple_document.tex')) do |file|
|
42
|
+
assert_match(/documentclass/, file.gets.chomp)
|
43
|
+
end
|
44
|
+
File.open(File.join(PROJECT_DIR, 'simple-document/tex/another_simple_document.tex')) do |file|
|
45
|
+
assert_match(/documentclass.*% custom/, file.gets.chomp)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|