dokkit 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +90 -105
- data/README.txt +27 -7
- data/Rakefile +2 -3
- data/bin/dokkit +3 -2
- data/lib/dokkit/application.rb +159 -0
- data/lib/dokkit/cache/cache.rb +53 -0
- data/lib/dokkit/{models/simpledocument/model/Rakefile → cache.rb} +3 -15
- data/lib/dokkit/environment/basic.rb +156 -0
- data/lib/dokkit/environment/helpers/extmap.rb +29 -0
- data/lib/dokkit/environment/helpers/fileselection.rb +53 -0
- data/lib/dokkit/environment/helpers.rb +20 -0
- data/{spec/data/test_build/Rakefile → lib/dokkit/environment.rb} +4 -15
- data/lib/dokkit/factory/factory.rb +56 -0
- data/lib/dokkit/factory.rb +9 -0
- data/lib/dokkit/filters/deplate.rb +25 -20
- data/lib/dokkit/filters/maruku.rb +6 -5
- data/lib/dokkit/filters/nil.rb +7 -6
- data/lib/dokkit/filters.rb +5 -27
- data/lib/dokkit/hash.rb +82 -0
- data/lib/dokkit/{logger.rb → logging/logger.rb} +30 -24
- data/lib/dokkit/logging/observers/console.rb +52 -0
- data/lib/dokkit/{extension/extension.rb → logging/observers.rb} +7 -5
- data/lib/dokkit/logging.rb +11 -0
- data/lib/dokkit/models/simple/Rakefile +6 -0
- data/lib/dokkit/models/simple/doc/data/html/css/style.css +3 -0
- data/lib/dokkit/models/simple/doc/data/latex/deplate.sty +46 -0
- data/lib/dokkit/models/simple/doc/layouts/simple.html +9 -0
- data/lib/dokkit/models/simple/doc/layouts/simple.latex +11 -0
- data/lib/dokkit/models/simple/doc/pages/simple.deplate +80 -0
- data/lib/dokkit/models/simple/setup/setup.rb +10 -0
- data/lib/dokkit/resource/data.rb +36 -0
- data/lib/dokkit/resource/document.rb +385 -0
- data/lib/dokkit/resource/extensions/builtin.rb +19 -0
- data/lib/dokkit/resource/extensions/html.rb +22 -0
- data/lib/dokkit/resource/extensions/url.rb +25 -0
- data/lib/dokkit/{filters/base.rb → resource/extensions.rb} +7 -8
- data/lib/dokkit/resource/filenamehelper.rb +28 -0
- data/lib/dokkit/resource.rb +11 -0
- data/lib/dokkit/tasklib/clean.rb +73 -0
- data/lib/dokkit/tasklib/render.rb +137 -0
- data/lib/dokkit/tasklib.rb +11 -0
- data/lib/dokkit.rb +26 -29
- data/spec/dokkit/application_spec.rb +141 -0
- data/spec/dokkit/cache/cache_spec.rb +87 -0
- data/spec/dokkit/dokkit_spec.rb +20 -0
- data/spec/dokkit/environment/basic_spec.rb +135 -0
- data/spec/dokkit/environment/helpers/extmap_spec.rb +52 -0
- data/spec/dokkit/environment/helpers/fileselection_spec.rb +80 -0
- data/spec/dokkit/environment/test_data/doc/pages/document_1.yaml +3 -0
- data/spec/dokkit/factory/factory_spec.rb +69 -0
- data/spec/{filter_deplate_spec.rb → dokkit/filters/deplate_spec.rb} +7 -8
- data/spec/{filter_maruku_spec.rb → dokkit/filters/maruku_spec.rb} +3 -4
- data/spec/{filter_nil_spec.rb → dokkit/filters/nil_spec.rb} +3 -4
- data/spec/{recursivemerge_spec.rb → dokkit/hash_spec.rb} +25 -27
- data/spec/{logger_spec.rb → dokkit/logging/logger_spec.rb} +35 -47
- data/spec/{consolelog_spec.rb → dokkit/logging/observers/console_spec.rb} +14 -15
- data/spec/dokkit/resource/data_spec.rb +32 -0
- data/spec/dokkit/resource/document_spec.rb +485 -0
- data/spec/dokkit/resource/extensions/html_spec.rb +35 -0
- data/spec/dokkit/resource/extensions/url_spec.rb +29 -0
- data/spec/{filehelper_spec.rb → dokkit/resource/filenamehelper_spec.rb} +12 -13
- data/spec/dokkit/resource/test_data/doc/configs/config_1.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/configs/config_2.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/configs/required.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/configs/subdir/document.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/layouts/container.html +6 -0
- data/spec/dokkit/resource/test_data/doc/layouts/layout.html +6 -0
- data/spec/{data/test_build/doc/layouts → dokkit/resource/test_data/doc/layouts/nested}/nested.html +2 -1
- data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.html +6 -0
- data/spec/dokkit/resource/test_data/doc/pages/COMMON.yaml +4 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_config.ext +7 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_errors.ext +12 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_targets.ext +19 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nested_layout.ext +13 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nil_target.ext +5 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_not_defined_target.ext +6 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_one_target.ext +8 -0
- data/spec/dokkit/resource/test_data/doc/pages/subdir/COMMON.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.ext +8 -0
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.yaml +5 -0
- data/spec/dokkit/tasklib/clean_spec.rb +75 -0
- data/spec/dokkit/tasklib/render_spec.rb +125 -0
- data/spec/dokkit/tasklib/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model1/doc/pages/model1 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model2/doc/pages/model2 +0 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +120 -47
- metadata +94 -117
- data/lib/dokkit/app.rb +0 -131
- data/lib/dokkit/builtintask.rb +0 -85
- data/lib/dokkit/cachemanager.rb +0 -61
- data/lib/dokkit/cleantask.rb +0 -51
- data/lib/dokkit/consolelog.rb +0 -42
- data/lib/dokkit/defaults.rb +0 -19
- data/lib/dokkit/deplate/fmt/html-notemplate.rb +0 -21
- data/lib/dokkit/deplate/fmt/latex-notemplate.rb +0 -24
- data/lib/dokkit/document.rb +0 -221
- data/lib/dokkit/dokkitlib.rb +0 -68
- data/lib/dokkit/extension/filehelper.rb +0 -25
- data/lib/dokkit/fileselection.rb +0 -44
- data/lib/dokkit/filters/all.rb +0 -18
- data/lib/dokkit/model.rb +0 -34
- data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.html +0 -9
- data/lib/dokkit/models/simpledocument/model/doc/pages/simpledocument.deplate +0 -102
- data/lib/dokkit/models/simpledocument/model/tasks/all.rb +0 -3
- data/lib/dokkit/models/simpledocument/model/tasks/clean.rake +0 -3
- data/lib/dokkit/models/simpledocument/model/tasks/render.rake +0 -8
- data/lib/dokkit/models/simpledocument/model/tasks/setup.rb +0 -9
- data/lib/dokkit/modeltask.rb +0 -83
- data/lib/dokkit/pathhelper.rb +0 -46
- data/lib/dokkit/recursivemerge.rb +0 -59
- data/lib/dokkit/rendertask.rb +0 -101
- data/lib/dokkit/resourcemanager.rb +0 -177
- data/lib/dokkit/taskconfig.rb +0 -39
- data/lib/dokkit/templatetask.rb +0 -37
- data/spec/app_spec.rb +0 -55
- data/spec/builtintask_spec.rb +0 -114
- data/spec/cachemanager_spec.rb +0 -107
- data/spec/cleantask_spec.rb +0 -72
- data/spec/data/test_build/doc/configs/document_1.yaml +0 -3
- data/spec/data/test_build/doc/configs/required.yaml +0 -3
- data/spec/data/test_build/doc/configs/subdir/document_4.yaml +0 -3
- data/spec/data/test_build/doc/layouts/document_1.html +0 -9
- data/spec/data/test_build/doc/layouts/document_with_partials.html +0 -9
- data/spec/data/test_build/doc/layouts/layout.html +0 -8
- data/spec/data/test_build/doc/layouts/layout.html.backup +0 -8
- data/spec/data/test_build/doc/layouts/partials/partial.html +0 -4
- data/spec/data/test_build/doc/pages/COMMON.yaml +0 -6
- data/spec/data/test_build/doc/pages/document_1 +0 -20
- data/spec/data/test_build/doc/pages/document_1.dep +0 -4
- data/spec/data/test_build/doc/pages/document_1.yaml +0 -11
- data/spec/data/test_build/doc/pages/document_2 +0 -9
- data/spec/data/test_build/doc/pages/document_2.yaml +0 -6
- data/spec/data/test_build/doc/pages/document_3 +0 -13
- data/spec/data/test_build/doc/pages/document_7 +0 -4
- data/spec/data/test_build/doc/pages/document_7.yaml +0 -5
- data/spec/data/test_build/doc/pages/document_extended +0 -1
- data/spec/data/test_build/doc/pages/document_nested +0 -6
- data/spec/data/test_build/doc/pages/document_nested.yaml +0 -5
- data/spec/data/test_build/doc/pages/document_nolayout.ext +0 -3
- data/spec/data/test_build/doc/pages/document_nolayout.yaml +0 -2
- data/spec/data/test_build/doc/pages/document_with_partials +0 -3
- data/spec/data/test_build/doc/pages/document_with_partials.yaml +0 -2
- data/spec/data/test_build/doc/pages/partials/COMMON.yaml +0 -5
- data/spec/data/test_build/doc/pages/partials/circular_partial +0 -2
- data/spec/data/test_build/doc/pages/partials/circular_partial.yaml +0 -3
- data/spec/data/test_build/doc/pages/partials/partial +0 -2
- data/spec/data/test_build/doc/pages/subdir/COMMON.yaml +0 -2
- data/spec/data/test_build/doc/pages/subdir/document_4 +0 -11
- data/spec/data/test_build/doc/pages/subdir/subdir/COMMON.yaml +0 -2
- data/spec/data/test_build/doc/pages/subdir/subdir/document_6 +0 -3
- data/spec/data/test_build/tasks/all.rb +0 -3
- data/spec/data/test_build/tasks/clean.rake +0 -3
- data/spec/data/test_build/tasks/render.rake +0 -8
- data/spec/data/test_build/tasks/setup.rb +0 -9
- data/spec/data/test_build/tasks/template.rake +0 -3
- data/spec/document_spec.rb +0 -321
- data/spec/dokkitlib_spec.rb +0 -63
- data/spec/fileselection_spec.rb +0 -101
- data/spec/filter_base_spec.rb +0 -29
- data/spec/filters_spec.rb +0 -37
- data/spec/model_spec.rb +0 -45
- data/spec/pathhelper_spec.rb +0 -62
- data/spec/rendertask_spec.rb +0 -374
- data/spec/taskconfig_spec.rb +0 -45
- data/spec/templatetask_spec.rb +0 -72
- /data/lib/dokkit/models/{simpledocument/model/doc/configs/simpledocument.yaml → simple/doc/configs/simple.yaml} +0 -0
- /data/lib/dokkit/models/{simpledocument/model/doc/layouts/simpledocument.text → simple/doc/layouts/simple.text} +0 -0
- /data/{lib/dokkit/models/simpledocument/model/doc/data/css/style.css → spec/dokkit/environment/helpers/test_data/doc/pages/document_1.ext_1} +0 -0
- /data/spec/{data/test_build/doc/data/resource → dokkit/environment/helpers/test_data/doc/pages/document_2} +0 -0
- /data/spec/{data/test_build/doc/data/resource.exclude → dokkit/environment/helpers/test_data/doc/pages/document_3.ext_3} +0 -0
- /data/spec/{data/test_build/doc/data/subdir/resource.insubdir → dokkit/environment/test_data/doc/data/data} +0 -0
- /data/spec/{data/test_build/doc/layouts/layout → dokkit/environment/test_data/doc/pages/document_1} +0 -0
- /data/spec/{data/test_build/doc/pages/document_2.dep → dokkit/environment/test_data/doc/pages/document_2} +0 -0
- /data/spec/{data/test_build/doc/pages/document_5.exclude → dokkit/environment/test_data/doc/pages/subdir/document_1} +0 -0
- /data/{lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.latex → spec/dokkit/resource/test_data/doc/layouts/layout.latex} +0 -0
- /data/spec/{data/test_build/doc/layouts/document_1.latex → dokkit/resource/test_data/doc/layouts/subdir/document.latex} +0 -0
- /data/spec/{data/test_build/templates/layouts/layout → dokkit/tasklib/test_data/doc/data/data_1} +0 -0
- /data/spec/{data/test_build/templates/pages/template → dokkit/tasklib/test_data/doc/pages/document_1} +0 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
layout: layout
|
3
|
+
format:
|
4
|
+
- latex
|
5
|
+
- text
|
6
|
+
- custom:
|
7
|
+
filter:
|
8
|
+
- maruku-html
|
9
|
+
ext: html
|
10
|
+
---
|
11
|
+
|
12
|
+
This document can be rendered in the format below:
|
13
|
+
|
14
|
+
* html
|
15
|
+
* latex
|
16
|
+
* text
|
17
|
+
* custom
|
18
|
+
|
19
|
+
The custom format use maruku filter for html rendering.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
layout:
|
3
|
+
- clear
|
4
|
+
- nested/nested
|
5
|
+
- container
|
6
|
+
---
|
7
|
+
|
8
|
+
This is a document thai uses a nested layout inside a layout that acts as container.
|
9
|
+
Layouts are rendered in the same order of the array values above. That is:
|
10
|
+
|
11
|
+
result in result in
|
12
|
+
document_with_nested_layout ========> doc/layouts/nested/nested.html ========> doc/layouts/container.html
|
13
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# File 'clean_spec.rb' created on 14 apr 2008 at 16:00:41.
|
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/clean_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
13
|
+
|
14
|
+
require 'rubygems'
|
15
|
+
require 'rake'
|
16
|
+
require 'spec'
|
17
|
+
require 'dokkit/tasklib/clean'
|
18
|
+
require 'spec/spec_helper.rb'
|
19
|
+
|
20
|
+
describe Dokkit::TaskLib::Clean do
|
21
|
+
include SpecHelper::Logger
|
22
|
+
before(:all) do
|
23
|
+
@initial_dir = Dir.pwd
|
24
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
25
|
+
end
|
26
|
+
after(:all) do
|
27
|
+
Dir.chdir(@initial_dir)
|
28
|
+
end
|
29
|
+
before do
|
30
|
+
@logger = logger
|
31
|
+
@rake = Rake.application
|
32
|
+
@clean = Dokkit::TaskLib::Clean.new(@logger, { :output_dir => 'output', :cache_dir => '.cache'} )
|
33
|
+
end
|
34
|
+
after do
|
35
|
+
Rake.application.clear
|
36
|
+
end
|
37
|
+
it 'should define a clean:output task' do
|
38
|
+
@rake.tasks.should include(task('clean:output'))
|
39
|
+
end
|
40
|
+
it 'should define a clean:cache task' do
|
41
|
+
@rake.tasks.should include(task('clean:cache'))
|
42
|
+
end
|
43
|
+
it 'should define a clean:all task' do
|
44
|
+
@rake.tasks.should include(task('clean:all'))
|
45
|
+
end
|
46
|
+
describe ' when clean:output is invoked' do
|
47
|
+
before do
|
48
|
+
mkdir 'output'
|
49
|
+
end
|
50
|
+
after do
|
51
|
+
rm_rf 'output'
|
52
|
+
end
|
53
|
+
it 'should remove output directory' do
|
54
|
+
@logger.stub!(:info)
|
55
|
+
@rake['clean:output'].execute({ })
|
56
|
+
File.exists?('output').should be_false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
describe ' when clean:cache is invoked' do
|
60
|
+
before do
|
61
|
+
mkdir '.cache'
|
62
|
+
end
|
63
|
+
after do
|
64
|
+
rm_rf '.cache'
|
65
|
+
end
|
66
|
+
it 'should remove cache directory' do
|
67
|
+
@logger.stub!(:info)
|
68
|
+
@rake['clean:cache'].execute({ })
|
69
|
+
File.exists?('.cache').should be_false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#
|
2
|
+
# File 'rendertask_spec.rb' created on 18 feb 2008 at 19:55:16.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2006, 2007, 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
# To execute this spec run:
|
8
|
+
#
|
9
|
+
# spec spec/render_spec.rb
|
10
|
+
#
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
13
|
+
|
14
|
+
require 'rubygems'
|
15
|
+
require 'spec'
|
16
|
+
require 'dokkit/tasklib/render'
|
17
|
+
require 'spec/spec_helper.rb'
|
18
|
+
|
19
|
+
describe Dokkit::TaskLib::Render do
|
20
|
+
include SpecHelper::Resource, SpecHelper::Logger
|
21
|
+
before(:all) do
|
22
|
+
@initial_dir = Dir.pwd
|
23
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
24
|
+
end
|
25
|
+
after(:all) do
|
26
|
+
Dir.chdir(@initial_dir)
|
27
|
+
end
|
28
|
+
before do
|
29
|
+
@rake = Rake.application
|
30
|
+
@document_1 = document_1
|
31
|
+
@document_2 = document_2
|
32
|
+
@data_1 = data_1
|
33
|
+
@resource_factory = resource_factory
|
34
|
+
@logger = logger
|
35
|
+
@render = Dokkit::TaskLib::Render.new(@logger, @resource_factory, ['doc/pages/document_1', 'doc/pages/document_2'], ['doc/data/data_1'])
|
36
|
+
end
|
37
|
+
after do
|
38
|
+
Rake.application.clear
|
39
|
+
end
|
40
|
+
it 'should define a render:doc task' do
|
41
|
+
@rake['render:doc'].should
|
42
|
+
end
|
43
|
+
it 'should define a render:data task' do
|
44
|
+
@rake['render:data'].should
|
45
|
+
end
|
46
|
+
it 'should define a render:all task' do
|
47
|
+
@rake['render:all'].prerequisites.should == ['render:doc', 'render:data']
|
48
|
+
end
|
49
|
+
describe ' when render:doc invoked' do
|
50
|
+
before do
|
51
|
+
@logger.stub!(:info)
|
52
|
+
@resource_factory.stub!(:get).and_return(@document_1, @document_2)
|
53
|
+
end
|
54
|
+
before do
|
55
|
+
@rake['render:doc'].execute({ })
|
56
|
+
end
|
57
|
+
after do
|
58
|
+
rm_rf 'output'
|
59
|
+
end
|
60
|
+
it 'should create the output directory' do
|
61
|
+
File.exists?('output').should be_true
|
62
|
+
end
|
63
|
+
it 'should create document_1.html' do
|
64
|
+
File.exists?('document_1.html')
|
65
|
+
end
|
66
|
+
it 'should create document_2.html' do
|
67
|
+
File.exists?('document_2.html')
|
68
|
+
end
|
69
|
+
it 'should create document_2.text' do
|
70
|
+
File.exists?('document_2.html')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
describe ' when render:data invoked' do
|
74
|
+
before do
|
75
|
+
@logger.stub!(:info)
|
76
|
+
@resource_factory.stub!(:get).and_return(@data_1)
|
77
|
+
end
|
78
|
+
before do
|
79
|
+
@rake['render:data'].execute({ })
|
80
|
+
end
|
81
|
+
after do
|
82
|
+
rm_rf 'output'
|
83
|
+
end
|
84
|
+
it 'should create the output directory' do
|
85
|
+
File.exists?('output').should be_true
|
86
|
+
end
|
87
|
+
it 'should copy data_1' do
|
88
|
+
File.exists?('data_1')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
describe ' when doc/data/data_1 has been changed' do
|
92
|
+
before do
|
93
|
+
@logger.stub!(:info)
|
94
|
+
@resource_factory.stub!(:get).and_return(@data_1)
|
95
|
+
@rake['render:data'].execute({ })
|
96
|
+
end
|
97
|
+
after do
|
98
|
+
rm_rf 'output'
|
99
|
+
end
|
100
|
+
it 'should re-render output/data_1' do
|
101
|
+
File.utime(0, Time.now, data_path('data_1'))
|
102
|
+
@logger.should_receive(:info).with(/copy/i)
|
103
|
+
@rake['render:data'].execute({ })
|
104
|
+
end
|
105
|
+
end
|
106
|
+
describe ' when doc/pages/document_1 has been changed' do
|
107
|
+
before do
|
108
|
+
@logger.stub!(:info)
|
109
|
+
@resource_factory.stub!(:get).and_return(@document_1)
|
110
|
+
@rake['render:doc'].execute({ })
|
111
|
+
end
|
112
|
+
after do
|
113
|
+
rm_rf 'output'
|
114
|
+
end
|
115
|
+
it 'should re-render output/document_1' do
|
116
|
+
File.utime(0, Time.now + 2, document_path('document_1'))
|
117
|
+
# FIXME: logger should receive *exactly* 2 times :info message
|
118
|
+
# but actually it receives four.. maybe there is some issue with
|
119
|
+
# Rake::Task#execute .. to investigate ..
|
120
|
+
@logger.should_receive(:info).at_least(2).with(/render/i)
|
121
|
+
@rake['render:doc'].execute({ })
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -5,57 +5,130 @@
|
|
5
5
|
# (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
6
|
#
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
|
9
|
+
|
10
|
+
require 'dokkit/hash'
|
11
|
+
|
12
|
+
module SpecHelper
|
13
|
+
module Path
|
14
|
+
TEST_DATA = 'test_data'
|
15
|
+
DATA_DEST_DIR = 'data'
|
16
|
+
CACHE_PATH = '.cache'
|
17
|
+
DOCUMENT_PATH = 'doc/pages'
|
18
|
+
DATA_PATH = 'doc/data'
|
19
|
+
CONFIG_PATH = 'doc/configs'
|
20
|
+
LAYOUT_PATH = 'doc/layouts'
|
21
|
+
TEMPLATE_PATH = 'templates'
|
22
|
+
OUTPUT_PATH = 'output'
|
23
|
+
def base_path(fn = '')
|
24
|
+
File.join('.', fn)
|
25
|
+
end
|
26
|
+
def cache_path(fn = '')
|
27
|
+
File.join(base_path, CACHE_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
|
28
|
+
end
|
29
|
+
def document_path(fn = '')
|
30
|
+
File.join(base_path, DOCUMENT_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
|
31
|
+
end
|
32
|
+
def config_path(fn = '')
|
33
|
+
File.join(base_path, CONFIG_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
|
34
|
+
end
|
35
|
+
def layout_path(fn = '')
|
36
|
+
File.join(base_path, LAYOUT_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
|
37
|
+
end
|
38
|
+
def data_path(fn = '')
|
39
|
+
File.join(base_path, DATA_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
|
40
|
+
end
|
41
|
+
def output_path(fn = '')
|
42
|
+
File.join(base_path, OUTPUT_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
|
43
|
+
end
|
23
44
|
end
|
24
|
-
|
25
|
-
|
45
|
+
module Logger
|
46
|
+
def logger
|
47
|
+
mock('logger',
|
48
|
+
:info => nil,
|
49
|
+
:error => nil,
|
50
|
+
:warn => nil,
|
51
|
+
:debug => nil)
|
52
|
+
end
|
26
53
|
end
|
27
|
-
|
28
|
-
|
54
|
+
module Resource
|
55
|
+
include Path
|
56
|
+
def document_1
|
57
|
+
mock('document_1',
|
58
|
+
:source_fn => 'doc/pages/document_1',
|
59
|
+
:targets => { :html => nil, :text => nil },
|
60
|
+
:target_for => 'output/document_1.html',
|
61
|
+
:deps_for => ['doc/pages/document_1'],
|
62
|
+
:render => nil
|
63
|
+
)
|
64
|
+
end
|
65
|
+
def document_2
|
66
|
+
mock('document_2',
|
67
|
+
:source_fn => 'doc/pages/document_2',
|
68
|
+
:targets => { :html => nil },
|
69
|
+
:target_for => 'output/document_1.html',
|
70
|
+
:deps_for => ['doc/pages/document_2'],
|
71
|
+
:render => nil
|
72
|
+
)
|
73
|
+
end
|
74
|
+
def data_1
|
75
|
+
mock('data_1',
|
76
|
+
:target_fn => 'output/data_1',
|
77
|
+
:source_fn => 'doc/data/data_1'
|
78
|
+
)
|
79
|
+
end
|
80
|
+
def resource_factory
|
81
|
+
mock('resource_factory')
|
82
|
+
end
|
83
|
+
def filter_factory
|
84
|
+
mock('filter_factory')
|
85
|
+
end
|
29
86
|
end
|
30
|
-
|
31
|
-
|
87
|
+
module Cache
|
88
|
+
def cache
|
89
|
+
mock('cache', :load => nil,
|
90
|
+
:deps => { },
|
91
|
+
:add_dependency => nil)
|
92
|
+
end
|
32
93
|
end
|
33
|
-
|
34
|
-
|
94
|
+
module Configuration
|
95
|
+
def configuration
|
96
|
+
{ :document_dir => 'doc/pages',
|
97
|
+
:data_dir => 'doc/data',
|
98
|
+
:layout_dir => 'doc/layouts',
|
99
|
+
:config_dir => 'doc/configs',
|
100
|
+
:cache_dir => '.cache',
|
101
|
+
:output_dir => 'output'
|
102
|
+
}
|
103
|
+
end
|
104
|
+
def merge_hashes(*hashes)
|
105
|
+
config = { }
|
106
|
+
hashes.each do |hash|
|
107
|
+
config.recursive_merge!(YAML::load(File.read(hash))) if File.exists?(hash.to_s)
|
108
|
+
config.recursive_merge!(hash) if hash.is_a?(Hash)
|
109
|
+
end
|
110
|
+
config.delete('config')
|
111
|
+
config
|
112
|
+
end
|
35
113
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
114
|
+
module CaptureOutput
|
115
|
+
def capture_stdout
|
116
|
+
s = StringIO.new
|
117
|
+
oldstdout = $stdout
|
118
|
+
$stdout = s
|
119
|
+
yield
|
120
|
+
s.string
|
121
|
+
ensure
|
122
|
+
$stdout = oldstdout
|
123
|
+
end
|
124
|
+
def capture_stderr
|
125
|
+
s = StringIO.new
|
126
|
+
oldstdout = $stderr
|
127
|
+
$stderr = s
|
128
|
+
yield
|
129
|
+
s.string
|
130
|
+
ensure
|
131
|
+
$stderr = oldstdout
|
132
|
+
end
|
50
133
|
end
|
51
|
-
def capture_stderr
|
52
|
-
s = StringIO.new
|
53
|
-
oldstdout = $stderr
|
54
|
-
$stderr = s
|
55
|
-
yield
|
56
|
-
s.string
|
57
|
-
ensure
|
58
|
-
$stderr = oldstdout
|
59
|
-
end
|
60
134
|
end
|
61
|
-
|