dokkit 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +125 -0
- data/README.txt +53 -0
- data/Rakefile +25 -167
- data/bin/dokkit +4 -60
- data/lib/dokkit/app.rb +63 -192
- data/lib/dokkit/builtintask.rb +85 -0
- data/lib/dokkit/cachemanager.rb +61 -0
- data/lib/dokkit/cleantask.rb +51 -0
- data/lib/dokkit/consolelog.rb +42 -0
- data/lib/dokkit/defaults.rb +19 -0
- data/lib/dokkit/document.rb +221 -0
- data/lib/dokkit/dokkitlib.rb +68 -0
- data/lib/dokkit/extension/extension.rb +15 -0
- data/lib/dokkit/extension/filehelper.rb +25 -0
- data/lib/dokkit/fileselection.rb +44 -0
- data/lib/dokkit/filters/all.rb +18 -0
- data/lib/dokkit/filters/base.rb +18 -0
- data/lib/dokkit/filters/deplate.rb +21 -25
- data/lib/dokkit/filters/maruku.rb +23 -0
- data/lib/dokkit/filters/nil.rb +23 -0
- data/lib/dokkit/filters.rb +29 -21
- data/lib/dokkit/logger.rb +73 -0
- data/lib/dokkit/model.rb +34 -0
- data/lib/dokkit/models/{Rakefile.tpl → simpledocument/model/Rakefile} +15 -2
- data/lib/dokkit/models/simpledocument/model/doc/configs/simpledocument.yaml +3 -0
- data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.html +9 -0
- data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.latex +8 -0
- data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.text +1 -0
- data/lib/dokkit/models/simpledocument/model/doc/pages/simpledocument.deplate +102 -0
- data/lib/dokkit/models/simpledocument/model/tasks/all.rb +3 -0
- data/lib/dokkit/models/simpledocument/model/tasks/clean.rake +3 -0
- data/lib/dokkit/models/simpledocument/model/tasks/render.rake +8 -0
- data/lib/dokkit/models/simpledocument/model/tasks/setup.rb +9 -0
- data/lib/dokkit/modeltask.rb +83 -0
- data/lib/dokkit/pathhelper.rb +46 -0
- data/lib/dokkit/recursivemerge.rb +59 -0
- data/lib/dokkit/rendertask.rb +101 -0
- data/lib/dokkit/resourcemanager.rb +177 -0
- data/lib/dokkit/taskconfig.rb +39 -0
- data/lib/dokkit/templatetask.rb +37 -0
- data/lib/dokkit.rb +2 -8
- data/spec/app_spec.rb +55 -0
- data/spec/builtintask_spec.rb +114 -0
- data/spec/cachemanager_spec.rb +107 -0
- data/spec/cleantask_spec.rb +72 -0
- data/spec/consolelog_spec.rb +69 -0
- data/{tests/data/projects/simple-document → spec/data/test_build}/Rakefile +8 -8
- data/spec/data/test_build/doc/configs/document_1.yaml +3 -0
- data/spec/data/test_build/doc/configs/required.yaml +3 -0
- data/spec/data/test_build/doc/configs/subdir/document_4.yaml +3 -0
- data/spec/data/test_build/doc/layouts/document_1.html +9 -0
- data/spec/data/test_build/doc/layouts/document_1.latex +8 -0
- data/spec/data/test_build/doc/layouts/document_with_partials.html +9 -0
- data/spec/data/test_build/doc/layouts/layout +0 -0
- data/spec/data/test_build/doc/layouts/layout.html +8 -0
- data/spec/data/test_build/doc/layouts/layout.html.backup +8 -0
- data/spec/data/test_build/doc/layouts/nested.html +3 -0
- data/spec/data/test_build/doc/layouts/partials/partial.html +4 -0
- data/spec/data/test_build/doc/pages/COMMON.yaml +6 -0
- data/spec/data/test_build/doc/pages/document_1 +20 -0
- data/spec/data/test_build/doc/pages/document_1.dep +4 -0
- data/spec/data/test_build/doc/pages/document_1.yaml +11 -0
- data/spec/data/test_build/doc/pages/document_2 +9 -0
- data/spec/data/test_build/doc/pages/document_2.dep +0 -0
- data/spec/data/test_build/doc/pages/document_2.yaml +6 -0
- data/spec/data/test_build/doc/pages/document_3 +13 -0
- data/spec/data/test_build/doc/pages/document_5.exclude +0 -0
- data/spec/data/test_build/doc/pages/document_7 +4 -0
- data/spec/data/test_build/doc/pages/document_7.yaml +5 -0
- data/spec/data/test_build/doc/pages/document_extended +1 -0
- data/spec/data/test_build/doc/pages/document_nested +6 -0
- data/spec/data/test_build/doc/pages/document_nested.yaml +5 -0
- data/spec/data/test_build/doc/pages/document_nolayout.ext +3 -0
- data/spec/data/test_build/doc/pages/document_nolayout.yaml +2 -0
- data/spec/data/test_build/doc/pages/document_with_partials +3 -0
- data/spec/data/test_build/doc/pages/document_with_partials.yaml +2 -0
- data/spec/data/test_build/doc/pages/partials/COMMON.yaml +5 -0
- data/spec/data/test_build/doc/pages/partials/circular_partial +2 -0
- data/spec/data/test_build/doc/pages/partials/circular_partial.yaml +3 -0
- data/spec/data/test_build/doc/pages/partials/partial +2 -0
- data/spec/data/test_build/doc/pages/subdir/COMMON.yaml +2 -0
- data/spec/data/test_build/doc/pages/subdir/document_4 +11 -0
- data/spec/data/test_build/doc/pages/subdir/subdir/COMMON.yaml +2 -0
- data/spec/data/test_build/doc/pages/subdir/subdir/document_6 +3 -0
- data/spec/data/test_build/tasks/all.rb +3 -0
- data/spec/data/test_build/tasks/clean.rake +3 -0
- data/spec/data/test_build/tasks/render.rake +8 -0
- data/spec/data/test_build/tasks/setup.rb +9 -0
- data/spec/data/test_build/tasks/template.rake +3 -0
- data/spec/data/test_build/templates/layouts/layout +0 -0
- data/spec/data/test_build/templates/pages/template +0 -0
- data/spec/document_spec.rb +321 -0
- data/spec/dokkitlib_spec.rb +63 -0
- data/spec/filehelper_spec.rb +34 -0
- data/spec/fileselection_spec.rb +101 -0
- data/spec/filter_base_spec.rb +29 -0
- data/spec/filter_deplate_spec.rb +48 -0
- data/spec/filter_maruku_spec.rb +29 -0
- data/spec/filter_nil_spec.rb +30 -0
- data/spec/filters_spec.rb +37 -0
- data/spec/logger_spec.rb +150 -0
- data/spec/model_spec.rb +45 -0
- data/spec/pathhelper_spec.rb +62 -0
- data/spec/recursivemerge_spec.rb +91 -0
- data/spec/rendertask_spec.rb +374 -0
- data/spec/spec_helper.rb +61 -0
- data/spec/taskconfig_spec.rb +45 -0
- data/spec/templatetask_spec.rb +72 -0
- data/tasks/annotations.rake +30 -0
- data/tasks/doc.rake +49 -0
- data/tasks/gem.rake +89 -0
- data/tasks/manifest.rake +41 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +151 -0
- data/tasks/spec.rake +40 -0
- data/tasks/svn.rake +44 -0
- data/tasks/test.rake +40 -0
- metadata +188 -161
- data/CHANGES +0 -26
- data/LICENSE +0 -674
- data/README +0 -32
- data/lib/dokkit/#render_task_factory.rb# +0 -94
- data/lib/dokkit/dokkittasks.rb +0 -99
- data/lib/dokkit/hash.rb +0 -41
- data/lib/dokkit/models/share/builtin.rf +0 -28
- data/lib/dokkit/page.rb +0 -195
- data/lib/dokkit/render_task_factory.rb +0 -91
- data/tests/data/output/simple_document/README +0 -57
- data/tests/data/output/simple_document/Rakefile +0 -7
- data/tests/data/output/simple_document/doc/config/simple_document.yaml +0 -5
- data/tests/data/output/simple_document/doc/pages/simple_document.dpl +0 -12
- data/tests/data/output/website_project/README +0 -49
- data/tests/data/output/website_project/Rakefile +0 -82
- data/tests/data/output/website_project/doc/layouts/normal.thtml +0 -38
- data/tests/data/output/website_project/doc/pages/COMMON.rb +0 -9
- data/tests/data/output/website_project/doc/pages/deplate.dplhtml +0 -9
- data/tests/data/output/website_project/doc/pages/index.rb +0 -10
- data/tests/data/output/website_project/doc/pages/index.thtml +0 -12
- data/tests/data/output/website_project/doc/res/images/rote-tiny.png +0 -0
- data/tests/data/projects/simple-document/README +0 -57
- data/tests/data/projects/simple-document/doc/config/author.yaml +0 -4
- data/tests/data/projects/simple-document/doc/config/model.yaml +0 -18
- data/tests/data/projects/simple-document/doc/config/simple_document.yaml +0 -6
- data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +0 -8
- data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +0 -10
- data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +0 -8
- data/tests/data/projects/simple-document/doc/layouts/semantic.cache +0 -23
- data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +0 -23
- data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +0 -12
- data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +0 -12
- data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +0 -12
- data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +0 -4
- data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +0 -12
- data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +0 -3
- data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +0 -2
- data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +0 -12
- data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +0 -12
- data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +0 -8
- data/tests/gem_tests.rb +0 -4
- data/tests/spec_page.rb +0 -25
- data/tests/test.rb +0 -2
- data/tests/test_application.rb +0 -40
- data/tests/test_builtin_tasks.rb +0 -37
- data/tests/test_config.rb +0 -108
- data/tests/test_core.rb +0 -12
- data/tests/test_dokkit_commandline.rb +0 -18
- data/tests/test_exception.rb +0 -7
- data/tests/test_filters.rb +0 -46
- data/tests/test_layout.rb +0 -64
- data/tests/test_options.rb +0 -33
- data/tests/test_project_tasks.rb +0 -48
- data/tests/test_recursive_merge.rb +0 -42
- data/tests/test_task_factory.rb +0 -38
- /data/{CONTRIBUTORS → lib/dokkit/models/simpledocument/model/doc/data/css/style.css} +0 -0
- /data/{DONE → spec/data/test_build/doc/data/resource} +0 -0
- /data/{TODO → spec/data/test_build/doc/data/resource.exclude} +0 -0
- /data/{tests/pages/test.dpltex → spec/data/test_build/doc/data/subdir/resource.insubdir} +0 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
#
|
2
|
+
# File 'fileselect_spec.rb' created on 07 feb 2008 at 15:46:04.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/fileselect_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/fileselection'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::FileSelection, ' when initialized' do
|
22
|
+
include SpecPathHelper
|
23
|
+
before(:all) do
|
24
|
+
@initial_dir = Dir.pwd
|
25
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
|
26
|
+
end
|
27
|
+
it 'should set the current dir as default base path' do
|
28
|
+
fs = Dokkit::FileSelection.new
|
29
|
+
fs.base_dir.should == '.'
|
30
|
+
end
|
31
|
+
it 'should set the given directory as the base path for all operations' do
|
32
|
+
fs = Dokkit::FileSelection.new(document_path)
|
33
|
+
fs.base_dir.should == document_path
|
34
|
+
end
|
35
|
+
|
36
|
+
after(:all) do
|
37
|
+
Dir.chdir(@initial_dir)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe Dokkit::FileSelection, ' when extended with ExtMapping' do
|
42
|
+
include SpecPathHelper
|
43
|
+
before(:all) do
|
44
|
+
@initial_dir = Dir.pwd
|
45
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
|
46
|
+
@fs = Dokkit::FileSelection.new(document_path) do |fs|
|
47
|
+
fs.include('*')
|
48
|
+
end
|
49
|
+
@fs.extend Dokkit::ExtMapping
|
50
|
+
end
|
51
|
+
it 'should map an extension for document_1' do
|
52
|
+
@fs.extend(/document_1$/) { "extended" }
|
53
|
+
@fs.extmapping.should have(1).items
|
54
|
+
@fs.extmapping[document_path('document_1')].call.should == "extended"
|
55
|
+
end
|
56
|
+
it 'should map an extension for all documents' do
|
57
|
+
@fs.extend { "extended" }
|
58
|
+
@fs.extmapping.should have(18).items
|
59
|
+
end
|
60
|
+
after(:all) do
|
61
|
+
Dir.chdir(@initial_dir)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe Dokkit::FileSelection, '#files' do
|
66
|
+
include SpecPathHelper
|
67
|
+
before(:all) do
|
68
|
+
@initial_dir = Dir.pwd
|
69
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
|
70
|
+
end
|
71
|
+
it 'should return an array with the list of the included files in the given directory' do
|
72
|
+
Dokkit::FileSelection.new(document_path) do |fs|
|
73
|
+
fs.include('*')
|
74
|
+
end.files.should have(18).items
|
75
|
+
end
|
76
|
+
it 'should not include files that was explicity excluded' do
|
77
|
+
Dokkit::FileSelection.new(document_path) do |fs|
|
78
|
+
fs.exclude('*.exclude')
|
79
|
+
end.files.should_not include(document_path('document_5.exclude'))
|
80
|
+
end
|
81
|
+
it 'should include only the files that was explicity included' do
|
82
|
+
Dokkit::FileSelection.new(document_path) do |fs|
|
83
|
+
fs.include('*.yaml')
|
84
|
+
end.files.should include(document_path('COMMON.yaml'))
|
85
|
+
end
|
86
|
+
it 'should not include the same files' do
|
87
|
+
Dokkit::FileSelection.new(document_path) do |fs|
|
88
|
+
fs.include('*')
|
89
|
+
fs.include('*')
|
90
|
+
end.files.should have(18).items
|
91
|
+
end
|
92
|
+
it 'should not include directory' do
|
93
|
+
Dokkit::FileSelection.new(document_path) do |fs|
|
94
|
+
fs.include('**/*')
|
95
|
+
end.files.should_not include(document_path('subdir'))
|
96
|
+
end
|
97
|
+
after(:all) do
|
98
|
+
Dir.chdir(@initial_dir)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# File 'filter_base_spec.rb' created on 18 feb 2008 at 14:48:04.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/filter_base_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/filters/base'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Filters::Base do
|
22
|
+
before do
|
23
|
+
@filter = Dokkit::Filters::Base.new
|
24
|
+
end
|
25
|
+
it 'should define an instance method to transform the given text' do
|
26
|
+
@result = @filter.filter('text to transform').should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# File 'filter_deplate_spec.rb' created on 18 feb 2008 at 15:22:35.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/filter_deplate_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/filters/deplate'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Filters::DeplateHTML do
|
22
|
+
before do
|
23
|
+
@deplate = Dokkit::Filters::DeplateHTML.new
|
24
|
+
end
|
25
|
+
it 'should transform deplate wiki text in html' do
|
26
|
+
@deplate.filter('* Header').should =~ /\<h1.*\>1 Header\<\/h1\>/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Dokkit::Filters::DeplateLatex do
|
31
|
+
before do
|
32
|
+
@deplate = Dokkit::Filters::DeplateLatex.new
|
33
|
+
end
|
34
|
+
it 'should transform deplate wiki text in tex' do
|
35
|
+
@deplate.filter('* Header').should =~ /\\section\{Header\}/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Dokkit::Filters::DeplateText do
|
40
|
+
before do
|
41
|
+
@deplate = Dokkit::Filters::DeplateText.new
|
42
|
+
end
|
43
|
+
it 'should transform deplate wiki text in plain text' do
|
44
|
+
@deplate.filter('* Header').should =~ /\n1 Header\n=+$/
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# File 'filter_maruku_spec.rb' created on 15 feb 2008 at 22:52:14.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/filter_maruku_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/filters/maruku'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Filters::MarukuHTML do
|
22
|
+
before do
|
23
|
+
@maruku = Dokkit::Filters::MarukuHTML.new
|
24
|
+
end
|
25
|
+
it 'should transform markdown text in html' do
|
26
|
+
@result = @maruku.filter('# Header').should =~ /\<h1.*\>Header\<\/h1\>/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# File 'filter_nil_spec.rb' created on 18 mar 2008 at 12:39:00.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/filter_nil_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/filters/nil'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Filters::Nil do
|
22
|
+
before do
|
23
|
+
@nil = Dokkit::Filters::Nil.new
|
24
|
+
end
|
25
|
+
it 'should not transform source file' do
|
26
|
+
@result = @nil.filter('Do *not* transform this text.').should == 'Do *not* transform this text.'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# File 'filter_spec.rb' created on 15 feb 2008 at 22:25:12.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/filter_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/filters'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Filters do
|
22
|
+
it 'should register new filters' do
|
23
|
+
Filter = mock('Filter')
|
24
|
+
@filter = mock('filter')
|
25
|
+
Filter.should_receive(:new).and_return(@filter)
|
26
|
+
@filter.should_receive(:class).and_return('Filter')
|
27
|
+
Dokkit::Filters.register('filter') do
|
28
|
+
Filter.new
|
29
|
+
end
|
30
|
+
Dokkit::Filters['filter'].class.should == 'Filter'
|
31
|
+
end
|
32
|
+
it 'should raise an error if a non existent filter is called' do
|
33
|
+
lambda {
|
34
|
+
Dokkit::Filters['notexists']
|
35
|
+
}.should raise_error(RuntimeError, /Filter '.*' is not defined!/)
|
36
|
+
end
|
37
|
+
end
|
data/spec/logger_spec.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
#
|
2
|
+
# File 'logger_spec.rb' created on 23 feb 2008 at 15:47:50.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/logger_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/logger'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Log::Logger do
|
22
|
+
before do
|
23
|
+
@logger = Dokkit::Log::Logger.logger
|
24
|
+
@observer = mock('observer')
|
25
|
+
end
|
26
|
+
after do
|
27
|
+
Dokkit::Log::Logger.clear
|
28
|
+
end
|
29
|
+
it 'should be singleton' do
|
30
|
+
@logger.object_id.should == Dokkit::Log::Logger.logger.object_id
|
31
|
+
end
|
32
|
+
it 'should be set with INFO log level by default' do
|
33
|
+
@logger.level.should == Dokkit::Log::INFO
|
34
|
+
end
|
35
|
+
it 'should correct log level out of range' do
|
36
|
+
@logger.level = 5
|
37
|
+
@logger.level.should == Dokkit::Log::DEBUG
|
38
|
+
@logger.level = -1
|
39
|
+
@logger.level.should == Dokkit::Log::ERROR
|
40
|
+
end
|
41
|
+
it 'should add observer to the observers list' do
|
42
|
+
@logger.attach(@observer).should == @observer
|
43
|
+
@logger.observers.should == [@observer]
|
44
|
+
end
|
45
|
+
it 'should remove the given observer from observers list' do
|
46
|
+
@logger.attach(@observer)
|
47
|
+
@logger.detach(@observer).should == @observer
|
48
|
+
@logger.observers.should be_empty
|
49
|
+
end
|
50
|
+
it 'should send updated messages to the observers' do
|
51
|
+
@observer.should_receive(:update)
|
52
|
+
@logger.attach(@observer)
|
53
|
+
@logger.notify
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe Dokkit::Log::Logger, ' when log level changes' do
|
58
|
+
before do
|
59
|
+
@logger = Dokkit::Log::Logger.logger
|
60
|
+
end
|
61
|
+
after do
|
62
|
+
Dokkit::Log::Logger.clear
|
63
|
+
end
|
64
|
+
describe ' to ERROR' do
|
65
|
+
before do
|
66
|
+
@logger.level = Dokkit::Log::ERROR
|
67
|
+
end
|
68
|
+
it 'should send error messages only' do
|
69
|
+
@logger.error('This is an error message.').should == {
|
70
|
+
:text => 'This is an error message.',
|
71
|
+
:level => Dokkit::Log::ERROR
|
72
|
+
}
|
73
|
+
@logger.warn('This is a warning message').should be_nil
|
74
|
+
@logger.info('This is an info message').should be_nil
|
75
|
+
@logger.debug('This is a debug message').should be_nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
describe ' to WARNING' do
|
79
|
+
before do
|
80
|
+
@logger.level = Dokkit::Log::WARNING
|
81
|
+
end
|
82
|
+
it 'should send error and warning messages only' do
|
83
|
+
@logger.error('This is an error message.').should == {
|
84
|
+
:text => 'This is an error message.',
|
85
|
+
:level => Dokkit::Log::ERROR
|
86
|
+
}
|
87
|
+
@logger.warn('This is a warning message.').should == {
|
88
|
+
:text => 'This is a warning message.',
|
89
|
+
:level => Dokkit::Log::WARNING
|
90
|
+
}
|
91
|
+
@logger.info('This is an info message').should be_nil
|
92
|
+
@logger.debug('This is a debug message').should be_nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
describe ' to INFO' do
|
96
|
+
before do
|
97
|
+
@logger.level = Dokkit::Log::INFO
|
98
|
+
end
|
99
|
+
it 'should send error, warning and info messages only' do
|
100
|
+
@logger.error('This is an error message.').should == {
|
101
|
+
:text => 'This is an error message.',
|
102
|
+
:level => Dokkit::Log::ERROR
|
103
|
+
}
|
104
|
+
@logger.warn('This is a warning message.').should == {
|
105
|
+
:text => 'This is a warning message.',
|
106
|
+
:level => Dokkit::Log::WARNING
|
107
|
+
}
|
108
|
+
@logger.info('This is an info message.').should == {
|
109
|
+
:text => 'This is an info message.',
|
110
|
+
:level => Dokkit::Log::INFO
|
111
|
+
}
|
112
|
+
@logger.debug('This is a debug message').should be_nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
describe ' to DEBUG' do
|
116
|
+
before do
|
117
|
+
@logger.level = Dokkit::Log::DEBUG
|
118
|
+
end
|
119
|
+
it 'should send all messages' do
|
120
|
+
@logger.error('This is an error message.').should == {
|
121
|
+
:text => 'This is an error message.',
|
122
|
+
:level => Dokkit::Log::ERROR
|
123
|
+
}
|
124
|
+
@logger.warn('This is a warning message.').should == {
|
125
|
+
:text => 'This is a warning message.',
|
126
|
+
:level => Dokkit::Log::WARNING
|
127
|
+
}
|
128
|
+
@logger.info('This is an info message.').should == {
|
129
|
+
:text => 'This is an info message.',
|
130
|
+
:level => Dokkit::Log::INFO
|
131
|
+
}
|
132
|
+
@logger.debug('This is a debug message.').should == {
|
133
|
+
:text => 'This is a debug message.',
|
134
|
+
:level => Dokkit::Log::DEBUG
|
135
|
+
}
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe Dokkit::Log::LogMessage do
|
141
|
+
before do
|
142
|
+
@message = Dokkit::Log::LogMessage.new('This is a message', Dokkit::Log::INFO)
|
143
|
+
end
|
144
|
+
it 'should be initialized with a message string' do
|
145
|
+
@message.text.should == 'This is a message'
|
146
|
+
end
|
147
|
+
it 'should be initialized with a log level' do
|
148
|
+
@message.level.should == Dokkit::Log::INFO
|
149
|
+
end
|
150
|
+
end
|
data/spec/model_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# File 'model_spec.rb' created on 10 mar 2008 at 13:36:29.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/model_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/model'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::Model, ' when initialized' do
|
22
|
+
include SpecPathHelper
|
23
|
+
before(:all) do
|
24
|
+
@initial_dir = Dir.pwd
|
25
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
|
26
|
+
end
|
27
|
+
before do
|
28
|
+
@model = Dokkit::Model.init do |model|
|
29
|
+
model.config.cache_dir = cache_path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
after(:all) do
|
33
|
+
Dir.chdir(@initial_dir)
|
34
|
+
end
|
35
|
+
it 'should be instantiated only once' do
|
36
|
+
Dokkit::Model.init.object_id.should == @model.object_id
|
37
|
+
end
|
38
|
+
it 'should be initialized with a name' do
|
39
|
+
Dokkit::Model.init('simpledocument').name == 'simpledocument'
|
40
|
+
end
|
41
|
+
it 'should instantiate a TaskConfig object' do
|
42
|
+
@model.config.class.should == Dokkit::TaskConfig
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# File 'pathhelper_spec.rb' created on 15 feb 2008 at 16:36:50.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/pathhelper_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/pathhelper'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Dokkit::PathHelper do
|
22
|
+
include SpecPathHelper
|
23
|
+
before do
|
24
|
+
@config = mock('config')
|
25
|
+
end
|
26
|
+
it 'should define a method to transform source file path and extension' do
|
27
|
+
source_fn = File.join(SpecPathHelper::DOCUMENT_PATH, 'document')
|
28
|
+
filename_helper(source_fn, SpecPathHelper::DOCUMENT_PATH, 'newdir', '.newext').should == 'newdir/document.newext'
|
29
|
+
source_fn = File.join(SpecPathHelper::DOCUMENT_PATH, 'subdir/document')
|
30
|
+
filename_helper(source_fn, SpecPathHelper::DOCUMENT_PATH, 'newdir', '.newext').should == 'newdir/subdir/document.newext'
|
31
|
+
end
|
32
|
+
it 'should return a configuration filename given a source filename' do
|
33
|
+
@config.should_receive(:document_dir).and_return(SpecPathHelper::DOCUMENT_PATH)
|
34
|
+
@config.should_receive(:config_dir).and_return(SpecPathHelper::CONFIG_PATH)
|
35
|
+
source_fn = File.join(SpecPathHelper::DOCUMENT_PATH, 'document')
|
36
|
+
config_fn_helper(source_fn, @config).should == 'doc/configs/document.yaml'
|
37
|
+
end
|
38
|
+
it 'should return a layout filename given a source filename' do
|
39
|
+
@config.should_receive(:document_dir).twice.and_return(SpecPathHelper::DOCUMENT_PATH)
|
40
|
+
@config.should_receive(:layout_dir).twice.and_return(SpecPathHelper::LAYOUT_PATH)
|
41
|
+
source_fn = File.join(SpecPathHelper::DOCUMENT_PATH, 'document')
|
42
|
+
layout_fn_helper(source_fn, '.html', @config).should == 'doc/layouts/document.html'
|
43
|
+
source_fn = File.join(SpecPathHelper::DOCUMENT_PATH, 'subdir/document')
|
44
|
+
layout_fn_helper(source_fn, '.html', @config).should == 'doc/layouts/subdir/document.html'
|
45
|
+
end
|
46
|
+
it 'should return a target filename given a source filename' do
|
47
|
+
@config.should_receive(:document_dir).and_return(SpecPathHelper::DOCUMENT_PATH)
|
48
|
+
@config.should_receive(:output_dir).and_return(SpecPathHelper::OUTPUT_PATH)
|
49
|
+
source_fn = File.join(SpecPathHelper::DOCUMENT_PATH, 'document')
|
50
|
+
output_fn_helper(source_fn, '.html', @config).should == 'output/document.html'
|
51
|
+
end
|
52
|
+
it 'should return a target data filename given a source data filename' do
|
53
|
+
@config.should_receive(:data_dir).and_return(SpecPathHelper::DATA_PATH)
|
54
|
+
@config.should_receive(:output_dir).and_return(SpecPathHelper::OUTPUT_PATH)
|
55
|
+
source_fn = File.join(SpecPathHelper::DATA_PATH, 'resource')
|
56
|
+
data_fn_helper(source_fn, @config).should == 'output/resource'
|
57
|
+
end
|
58
|
+
it 'should define a method to strip extension from file' do
|
59
|
+
strip_ext('test.ext').should == 'test'
|
60
|
+
strip_ext('.test.ext.ext').should == '.test.ext'
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#
|
2
|
+
# File 'recursivemerge_spec.rb' created on 09 feb 2008 at 19:08:20.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/recursivemerge_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit'
|
18
|
+
require 'dokkit/recursivemerge'
|
19
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
20
|
+
|
21
|
+
describe Hash do
|
22
|
+
describe 'when two hash with depth 0 are merged' do
|
23
|
+
before do
|
24
|
+
@h1 = { :a => "a", :b => "b" }
|
25
|
+
@h2 = { :c => "c" }
|
26
|
+
end
|
27
|
+
it 'should return a new hash with :a, :b, :c keys' do
|
28
|
+
@h1.recursive_merge(@h2).should == { :a => "a", :b => "b", :c => "c"}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
describe 'when two hash with depth 1 are merged' do
|
32
|
+
before do
|
33
|
+
@h1 = { :depth1 => { :a => "a", :b => "b" }, :b => "b" }
|
34
|
+
@h2 = { :depth1 => { :a => "a'", :c => "c" }, :b => "b'" }
|
35
|
+
end
|
36
|
+
it 'should return a new hash merging depth 1 values,' do
|
37
|
+
@h1.recursive_merge(@h2).should == { :depth1 => { :a => "a'", :b => "b", :c => "c"}, :b => "b'" }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
describe Hash, 'when two hash with depth 2 and depth 1 are merged' do
|
41
|
+
before do
|
42
|
+
@h1 = { :depth1 => { :depth2 => { :a => "a", :b => "b" } }, :b => "b" }
|
43
|
+
@h2 = { :depth1 => { :a => "a'", :b => "b'", :c => "c"}, :b => "b" }
|
44
|
+
end
|
45
|
+
it 'should return a new hash merging the depth 1 values adding the depth 2 key' do
|
46
|
+
@h1.recursive_merge(@h2).should == { :depth1 => {:depth2 => { :a => "a", :b => "b" }, :a => "a'", :b => "b'", :c => "c"}, :b => "b" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
describe Hash, ' when a block is passed to recursive_merge' do
|
50
|
+
it 'should use the block to store values' do
|
51
|
+
{ :a => 'a' }.recursive_merge({ :a => ['b', 'c'] }) do |key, value, other_value|
|
52
|
+
if(value.class == String && other_value.class == Array)
|
53
|
+
value.to_a.concat(other_value)
|
54
|
+
else
|
55
|
+
store(key, other_value)
|
56
|
+
end
|
57
|
+
end.should == { :a => ['a', 'b', 'c'] }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ConfigHash do
|
63
|
+
describe 'when a string and an array are merged' do
|
64
|
+
before do
|
65
|
+
@h1 = { :a => 'a' }.extend ConfigHash
|
66
|
+
@h2 = { :a => ['b', 'c'] }.extend ConfigHash
|
67
|
+
end
|
68
|
+
it 'should concatenate the string and the array' do
|
69
|
+
@h1.recursive_merge(@h2).should == { :a => ['a', 'b', 'c'] }
|
70
|
+
@h2.recursive_merge(@h1).should == { :a => ['b', 'c', 'a'] }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
describe 'when two array are merged' do
|
74
|
+
before do
|
75
|
+
@h1 = { :a => { :b => ['a', 'b'] } }.extend ConfigHash
|
76
|
+
@h2 = { :a => { :b => ['c', 'd'] } }.extend ConfigHash
|
77
|
+
end
|
78
|
+
it 'should concatenate the arrays' do
|
79
|
+
@h1.recursive_merge(@h2).should == { :a => { :b => ['a', 'b', 'c', 'd'] } }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
describe 'when layout and config keys are merged' do
|
83
|
+
before do
|
84
|
+
@h1 = { :layout => ['layout_1', 'layout_2'], :config => 'config' }.extend ConfigHash
|
85
|
+
@h2 = { :layout => ['layout_3', 'layout_4'], :config => ['config_1', 'config_2'] }.extend ConfigHash
|
86
|
+
end
|
87
|
+
it 'should store the rvalue' do
|
88
|
+
@h1.recursive_merge(@h2).should == { :layout => ['layout_3', 'layout_4'], :config => ['config_1', 'config_2'] }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|