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,485 @@
|
|
1
|
+
#
|
2
|
+
# File 'document_spec.rb' created on 17 apr 2008 at 18:01:58.
|
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/document_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/resource/document'
|
18
|
+
require 'spec/spec_helper.rb'
|
19
|
+
|
20
|
+
describe Dokkit::Resource::Document, '#include' do
|
21
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
22
|
+
before(:all) do
|
23
|
+
@initial_dir = Dir.pwd
|
24
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
25
|
+
end
|
26
|
+
before do
|
27
|
+
@logger = logger
|
28
|
+
@filter_factory = filter_factory
|
29
|
+
@cache = cache
|
30
|
+
@document = Dokkit::Resource::Document.new('doc/pages/subdir/document.ext',
|
31
|
+
configuration,
|
32
|
+
@logger,
|
33
|
+
@cache,
|
34
|
+
@resource_factory,
|
35
|
+
@filter_factory)
|
36
|
+
File.stub!(:read).and_return('<%= "erb" %>')
|
37
|
+
end
|
38
|
+
after(:all) do
|
39
|
+
Dir.chdir(@initial_dir)
|
40
|
+
end
|
41
|
+
it 'should read the given file processing it with erb' do
|
42
|
+
File.should_receive(:read).with('included.html').and_return('<%= "erb" %>')
|
43
|
+
@document.include('included.html')
|
44
|
+
end
|
45
|
+
it 'should process the given file with erb' do
|
46
|
+
@erb = ERB.new('<%= "erb" %>')
|
47
|
+
ERB.should_receive(:new).with('<%= "erb" %>').and_return(@erb)
|
48
|
+
@document.include('included.html').should == "erb"
|
49
|
+
end
|
50
|
+
it 'should add the given file as dependency' do
|
51
|
+
@cache.should_receive(:add_dependency).with('doc/pages/subdir/document.ext', 'html', 'included.html')
|
52
|
+
@document.include('included.html')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe Dokkit::Resource::Document, ' when inizialized with a code block' do
|
57
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
58
|
+
before(:all) do
|
59
|
+
@initial_dir = Dir.pwd
|
60
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
61
|
+
end
|
62
|
+
before do
|
63
|
+
module Extension; def foo; end; end
|
64
|
+
end
|
65
|
+
before do
|
66
|
+
@document = Dokkit::Resource::Document.new('doc/pages/subdir/document.ext',
|
67
|
+
configuration,
|
68
|
+
logger,
|
69
|
+
cache,
|
70
|
+
resource_factory,
|
71
|
+
filter_factory) { |document| document.extend Extension }
|
72
|
+
end
|
73
|
+
after(:all) do
|
74
|
+
Dir.chdir(@initial_dir)
|
75
|
+
end
|
76
|
+
it 'should be extended with Extension module' do
|
77
|
+
@document.respond_to?(:foo).should be_true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe Dokkit::Resource::Document, ' when inizialized with document.ext' do
|
82
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
83
|
+
before(:all) do
|
84
|
+
@initial_dir = Dir.pwd
|
85
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
86
|
+
end
|
87
|
+
before do
|
88
|
+
@logger = logger
|
89
|
+
@filter_factory = filter_factory
|
90
|
+
@document = Dokkit::Resource::Document.new('doc/pages/subdir/document.ext',
|
91
|
+
configuration,
|
92
|
+
@logger,
|
93
|
+
cache,
|
94
|
+
@resource_factory,
|
95
|
+
@filter_factory)
|
96
|
+
end
|
97
|
+
after(:all) do
|
98
|
+
Dir.chdir(@initial_dir)
|
99
|
+
end
|
100
|
+
it 'should set a default output' do
|
101
|
+
@document.default_format.should == 'html'
|
102
|
+
end
|
103
|
+
it 'should have targets hash' do
|
104
|
+
@document.targets.should
|
105
|
+
end
|
106
|
+
it 'should set a default target filename for a given output format' do
|
107
|
+
@document.target_for(@document.default_format).should == 'output/subdir/document.html'
|
108
|
+
end
|
109
|
+
it 'should have a default filter chain for the default output format' do
|
110
|
+
@document.filters_for(@document.default_format).should == ['deplate-html']
|
111
|
+
end
|
112
|
+
it 'should have a default filter chain for latex output' do
|
113
|
+
@document.filters_for('latex').should == ['deplate-latex']
|
114
|
+
end
|
115
|
+
it 'should have a default filter chain for text output' do
|
116
|
+
@document.filters_for('text').should == ['deplate-text']
|
117
|
+
end
|
118
|
+
it 'should fail if a filter chain for a given output format was not found' do
|
119
|
+
@logger.should_receive(:error).with(/defined filter/)
|
120
|
+
@document.filters_for(:'notexists')
|
121
|
+
end
|
122
|
+
it 'should return the target filename for the given format' do
|
123
|
+
@document.target_for('html').should == 'output/subdir/document.html'
|
124
|
+
end
|
125
|
+
it 'should set the source file basename' do
|
126
|
+
@document.basename.should == 'document'
|
127
|
+
end
|
128
|
+
it 'should set the dirname' do
|
129
|
+
@document.dirname.should == 'doc/pages/subdir'
|
130
|
+
end
|
131
|
+
it 'should set the filename with path but without extension' do
|
132
|
+
@document.name_noext == 'doc/pages/subdir/document'
|
133
|
+
end
|
134
|
+
it 'should set name relative to document directory' do
|
135
|
+
@document.relativename == 'subdir/document'
|
136
|
+
end
|
137
|
+
it 'should read the content of the source file' do
|
138
|
+
@document.source.should match(/\* Title for document/)
|
139
|
+
end
|
140
|
+
it 'should not store header information in the source text' do
|
141
|
+
@document.source.should_not match(/^-{3}$(.*?)-{3}$/m)
|
142
|
+
end
|
143
|
+
it 'should configure itself through configuration files' do
|
144
|
+
@document.configuration.should == merge_hashes(configuration,
|
145
|
+
'doc/configs/required.yaml',
|
146
|
+
'doc/pages/subdir/document.yaml',
|
147
|
+
'doc/pages/subdir/COMMON.yaml',
|
148
|
+
'doc/pages/COMMON.yaml',
|
149
|
+
'doc/configs/subdir/document.yaml',
|
150
|
+
{ 'key_in_header' => 'value in header'}
|
151
|
+
)
|
152
|
+
end
|
153
|
+
it 'should collect config filenames' do
|
154
|
+
@document.config_fns.should == ['doc/configs/subdir/document.yaml',
|
155
|
+
File.expand_path('doc/pages/COMMON.yaml'),
|
156
|
+
File.expand_path('doc/pages/subdir/COMMON.yaml'),
|
157
|
+
'doc/pages/subdir/document.yaml',
|
158
|
+
'doc/configs/required.yaml',
|
159
|
+
'doc/pages/subdir/document.ext']
|
160
|
+
end
|
161
|
+
it 'should collect layout filenames grouped by format' do
|
162
|
+
@document.layouts['html'].should == ['doc/layouts/subdir/document.html']
|
163
|
+
end
|
164
|
+
it 'should collect target filename' do
|
165
|
+
@document.target_for('html').should == 'output/subdir/document.html'
|
166
|
+
end
|
167
|
+
it 'should store the names of its dependencies grouped by format' do
|
168
|
+
@document.deps_for('html').should == ['doc/pages/subdir/document.ext',
|
169
|
+
'doc/configs/subdir/document.yaml',
|
170
|
+
File.expand_path('doc/pages/COMMON.yaml'),
|
171
|
+
File.expand_path('doc/pages/subdir/COMMON.yaml'),
|
172
|
+
'doc/pages/subdir/document.yaml',
|
173
|
+
'doc/configs/required.yaml',
|
174
|
+
'doc/layouts/subdir/document.html']
|
175
|
+
end
|
176
|
+
it 'should fail if config file doesn''t exist' do
|
177
|
+
@logger.should_receive(:error).with("Configuration file 'notexists' not found for '#{@document.source_fn}'!")
|
178
|
+
@document.add_config('notexists')
|
179
|
+
end
|
180
|
+
it 'should warn if a configuration key doesn''t exist' do
|
181
|
+
@logger.should_receive(:warn)
|
182
|
+
@document.configuration['notexists']
|
183
|
+
end
|
184
|
+
it 'should associate a default value for a not defined configuration key' do
|
185
|
+
@logger.should_receive(:warn)
|
186
|
+
@document.configuration['notexists'].should == @document.default_configuration_value
|
187
|
+
end
|
188
|
+
describe ' and rendered in html' do
|
189
|
+
it 'should produce html output' do
|
190
|
+
filter = mock('filter', :filter => '<h1>Title</h1>')
|
191
|
+
@filter_factory.should_receive(:get).with('deplate-html').and_return(filter)
|
192
|
+
@document.render.should match(/\<h1\>Title\<\/h1\>/)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
describe ' and rendered in a unknown format' do
|
196
|
+
it 'should fail if output format doesn''t exist' do
|
197
|
+
@logger.should_receive(:error).with(/format.*is unknown/)
|
198
|
+
@document.render(:format => 'notexists')
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe Dokkit::Resource::Document, ' when inizialized with document_with_many_targets.ext' do
|
204
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
205
|
+
before(:all) do
|
206
|
+
@initial_dir = Dir.pwd
|
207
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
208
|
+
end
|
209
|
+
before do
|
210
|
+
@logger = logger
|
211
|
+
@logger.stub!(:warn)
|
212
|
+
@filter_factory = filter_factory
|
213
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_targets.ext',
|
214
|
+
configuration,
|
215
|
+
@logger,
|
216
|
+
cache,
|
217
|
+
@resource_factory,
|
218
|
+
@filter_factory
|
219
|
+
)
|
220
|
+
end
|
221
|
+
after(:all) do
|
222
|
+
Dir.chdir(@initial_dir)
|
223
|
+
end
|
224
|
+
it 'should collect all the targets grouped by format' do
|
225
|
+
@document.targets.should == {
|
226
|
+
# 'html' => { :target_fn => 'output/document_with_many_targets.html' },
|
227
|
+
'latex' => { :target_fn => 'output/document_with_many_targets.latex' },
|
228
|
+
'text' => { :target_fn => 'output/document_with_many_targets.text' },
|
229
|
+
'custom' => {
|
230
|
+
:target_fn => 'output/document_with_many_targets.html',
|
231
|
+
'filter' => ['maruku-html']
|
232
|
+
}
|
233
|
+
}
|
234
|
+
end
|
235
|
+
it 'should return filter_chain for custom format' do
|
236
|
+
@document.filters_for('custom').should == ['maruku-html']
|
237
|
+
end
|
238
|
+
# describe ' and rendered in html format' do
|
239
|
+
# it 'should produce html output' do
|
240
|
+
# result = "<h1>Title</h1>"
|
241
|
+
# filter = mock('filter', :filter => result)
|
242
|
+
# @filter_factory.should_receive(:get).with('deplate-html').and_return(filter)
|
243
|
+
# @document.render(:format => 'html').should match(/#{result}/)
|
244
|
+
# end
|
245
|
+
# end
|
246
|
+
describe ' and rendered in latex format' do
|
247
|
+
it 'should produce latex output' do
|
248
|
+
result = "\section"
|
249
|
+
filter = mock('filter', :filter => result)
|
250
|
+
@filter_factory.should_receive(:get).with('deplate-latex').and_return(filter)
|
251
|
+
@document.render(:format => 'latex').should match(/#{result}/)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
describe ' and rendered in text format' do
|
255
|
+
it 'should produce text output' do
|
256
|
+
result = "=====\nTitle\n====="
|
257
|
+
filter = mock('filter', :filter => result)
|
258
|
+
@filter_factory.should_receive(:get).with('deplate-text').and_return(filter)
|
259
|
+
@document.render(:format => 'text').should match(/#{result}/)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
describe ' and rendered in custom format' do
|
263
|
+
it 'should produce html output using maruku' do
|
264
|
+
result = "<h1>Title</h1>"
|
265
|
+
filter = mock('filter', :filter => result)
|
266
|
+
@filter_factory.should_receive(:get).with('maruku-html').and_return(filter)
|
267
|
+
@document.render(:format => 'custom').should match(/#{result}/)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe Dokkit::Resource::Document, ' when inizialized with document_with_nested_layout.ext' do
|
273
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
274
|
+
before(:all) do
|
275
|
+
@initial_dir = Dir.pwd
|
276
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
277
|
+
end
|
278
|
+
before do
|
279
|
+
@logger = logger
|
280
|
+
@filter_factory = filter_factory
|
281
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_nested_layout.ext',
|
282
|
+
configuration,
|
283
|
+
@logger,
|
284
|
+
cache,
|
285
|
+
@resource_factory,
|
286
|
+
@filter_factory
|
287
|
+
)
|
288
|
+
end
|
289
|
+
after(:all) do
|
290
|
+
Dir.chdir(@initial_dir)
|
291
|
+
end
|
292
|
+
it 'should collect layouts' do
|
293
|
+
@document.layouts['html'].should == ['doc/layouts/nested/nested.html', 'doc/layouts/container.html']
|
294
|
+
end
|
295
|
+
describe ' and rendered in html format' do
|
296
|
+
it 'should produce html output using layout chain' do
|
297
|
+
result = "<p>Some content</p>"
|
298
|
+
filter = mock('filter', :filter => result)
|
299
|
+
@filter_factory.should_receive(:get).with('deplate-html').and_return(filter)
|
300
|
+
render_result = @document.render
|
301
|
+
render_result.should match(/\A\<html\>/)
|
302
|
+
render_result.should match(/<div id=\"nested\"\>/)
|
303
|
+
render_result.should match(/Some content/)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe Dokkit::Resource::Document, ' when inizialized with document_with_many_config.ext' do
|
309
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
310
|
+
before(:all) do
|
311
|
+
@initial_dir = Dir.pwd
|
312
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
313
|
+
end
|
314
|
+
before do
|
315
|
+
@logger = logger
|
316
|
+
@filter_factory = filter_factory
|
317
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_config.ext',
|
318
|
+
configuration,
|
319
|
+
@logger,
|
320
|
+
cache,
|
321
|
+
@resource_factory,
|
322
|
+
@filter_factory
|
323
|
+
)
|
324
|
+
end
|
325
|
+
after(:all) do
|
326
|
+
Dir.chdir(@initial_dir)
|
327
|
+
end
|
328
|
+
it 'should collect config files' do
|
329
|
+
@document.config_fns.should include(config_path('config_1.yaml'), config_path('config_2.yaml'))
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
describe Dokkit::Resource::Document, ' when inizialized with document_with_many_errors.ext' do
|
334
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
335
|
+
before(:all) do
|
336
|
+
@initial_dir = Dir.pwd
|
337
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
338
|
+
end
|
339
|
+
before do
|
340
|
+
@logger = logger
|
341
|
+
@filter_factory = filter_factory
|
342
|
+
end
|
343
|
+
after(:all) do
|
344
|
+
Dir.chdir(@initial_dir)
|
345
|
+
end
|
346
|
+
it 'should warn that layouts not exist for html and custom output format' do
|
347
|
+
@logger.should_receive(:warn).with(/Layout.* not exists/)
|
348
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_errors.ext',
|
349
|
+
configuration,
|
350
|
+
@logger,
|
351
|
+
cache,
|
352
|
+
@resource_factory,
|
353
|
+
@filter_factory)
|
354
|
+
end
|
355
|
+
it 'should not add not existent layout to deps array' do
|
356
|
+
@logger.stub!(:warn)
|
357
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_errors.ext',
|
358
|
+
configuration,
|
359
|
+
@logger,
|
360
|
+
cache,
|
361
|
+
resource_factory,
|
362
|
+
@filter_factory)
|
363
|
+
@document.deps['html'].should_not include(nil)
|
364
|
+
end
|
365
|
+
describe ' and rendered' do
|
366
|
+
before do
|
367
|
+
@logger.stub!(:warn)
|
368
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_many_errors.ext',
|
369
|
+
configuration,
|
370
|
+
@logger,
|
371
|
+
cache,
|
372
|
+
@resource_factory,
|
373
|
+
@filter_factory)
|
374
|
+
end
|
375
|
+
it 'should fail if rendered in :notexists format' do
|
376
|
+
@logger.should_receive(:error)
|
377
|
+
@document.render(:format => 'notexists')
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
describe Dokkit::Resource::Document, ' when inizialized with document_with_one_target' do
|
383
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
384
|
+
before(:all) do
|
385
|
+
@initial_dir = Dir.pwd
|
386
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
387
|
+
end
|
388
|
+
before do
|
389
|
+
@logger = logger
|
390
|
+
@logger.stub!(:warn)
|
391
|
+
@filter_factory = filter_factory
|
392
|
+
end
|
393
|
+
before do
|
394
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_one_target.ext',
|
395
|
+
configuration,
|
396
|
+
@logger,
|
397
|
+
cache,
|
398
|
+
@resource_factory,
|
399
|
+
@filter_factory)
|
400
|
+
end
|
401
|
+
after(:all) do
|
402
|
+
Dir.chdir(@initial_dir)
|
403
|
+
end
|
404
|
+
it 'should correctly setup targets' do
|
405
|
+
@document.targets['text'].should == { :target_fn => output_path('document_with_one_target.text') }
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
# describe Dokkit::Resource::Document, ' when inizialized with document_with_nil_target' do
|
410
|
+
# include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
411
|
+
# before(:all) do
|
412
|
+
# @initial_dir = Dir.pwd
|
413
|
+
# Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
414
|
+
# end
|
415
|
+
# before do
|
416
|
+
# @logger = logger
|
417
|
+
# @logger.stub!(:warn)
|
418
|
+
# @filter_factory = filter_factory
|
419
|
+
# end
|
420
|
+
# after(:all) do
|
421
|
+
# Dir.chdir(@initial_dir)
|
422
|
+
# end
|
423
|
+
# it 'should fail because target format doesn''t exist' do
|
424
|
+
# @logger.should_receive(:error).with(/invalid target/i)
|
425
|
+
# @document = Dokkit::Resource::Document.new('doc/pages/document_with_nil_target.ext',
|
426
|
+
# configuration,
|
427
|
+
# @logger,
|
428
|
+
# cache,
|
429
|
+
# @resource_factory,
|
430
|
+
# @filter_factory)
|
431
|
+
# end
|
432
|
+
# end
|
433
|
+
|
434
|
+
describe Dokkit::Resource::Document, ' when inizialized with document_with_not_defined_target' do
|
435
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
436
|
+
before(:all) do
|
437
|
+
@initial_dir = Dir.pwd
|
438
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
439
|
+
end
|
440
|
+
before do
|
441
|
+
@logger = logger
|
442
|
+
@logger.stub!(:warn)
|
443
|
+
@filter_factory = filter_factory
|
444
|
+
end
|
445
|
+
after(:all) do
|
446
|
+
Dir.chdir(@initial_dir)
|
447
|
+
end
|
448
|
+
it 'should fail because target format was not defined' do
|
449
|
+
@logger.should_receive(:error).with(/must define format/i)
|
450
|
+
@document = Dokkit::Resource::Document.new('doc/pages/document_with_not_defined_target.ext',
|
451
|
+
configuration,
|
452
|
+
@logger,
|
453
|
+
cache,
|
454
|
+
@resource_factory,
|
455
|
+
@filter_factory)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
describe Dokkit::Resource::Document, ' when render partial' do
|
460
|
+
include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
|
461
|
+
before(:all) do
|
462
|
+
@initial_dir = Dir.pwd
|
463
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
464
|
+
end
|
465
|
+
before do
|
466
|
+
@partial = mock('partial')
|
467
|
+
@partial.stub!(:render)
|
468
|
+
@cache = mock('cache')
|
469
|
+
@cache.stub!(:add_dependency)
|
470
|
+
@resource_factory = resource_factory
|
471
|
+
end
|
472
|
+
before do
|
473
|
+
# @document = Dokkit::Resource::Document.new('doc/pages/document_with_partial.ext',
|
474
|
+
# configuration,
|
475
|
+
# @logger,
|
476
|
+
# cache,
|
477
|
+
# @resource_factory,
|
478
|
+
# @filter_factory)
|
479
|
+
end
|
480
|
+
after(:all) do
|
481
|
+
Dir.chdir(@initial_dir)
|
482
|
+
end
|
483
|
+
it 'should instantiate a document object'
|
484
|
+
it 'should cache document'
|
485
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# File 'html_spec.rb' created on 21 giu 2008 at 19:57:13.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'spec'
|
10
|
+
require 'dokkit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../../../lib')))
|
13
|
+
require 'dokkit/resource/extensions/html'
|
14
|
+
|
15
|
+
|
16
|
+
module Dokkit
|
17
|
+
module Resource
|
18
|
+
module Extension
|
19
|
+
|
20
|
+
describe HTML, '#link_to' do
|
21
|
+
before do
|
22
|
+
@document = mock('document',
|
23
|
+
:configuration => { :document_dir => 'doc/pages' },
|
24
|
+
:source_fn => 'doc/pages/subdir/document.ext'
|
25
|
+
)
|
26
|
+
@document.extend Dokkit::Resource::Extension::HTML
|
27
|
+
end
|
28
|
+
it 'should produce a link with the given href, name and class' do
|
29
|
+
@document.link_to("Link to page", :href => '/page.html', :class => 'class').should == "<a href=\"../page.html\" class=\"class\">Link to page</a>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# File 'url_spec.rb' created on 09 mag 2008 at 19:17:03.
|
3
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
|
+
#
|
5
|
+
# (c)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
|
+
#
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../../../lib')))
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'spec'
|
12
|
+
require 'dokkit'
|
13
|
+
require 'dokkit/resource/extensions/url'
|
14
|
+
require 'spec/spec_helper.rb'
|
15
|
+
|
16
|
+
describe Dokkit::Resource::Extension::Url do
|
17
|
+
before do
|
18
|
+
@document = mock('document',
|
19
|
+
:configuration => { :document_dir => 'doc/pages' },
|
20
|
+
:source_fn => 'doc/pages/subdir/document.ext'
|
21
|
+
)
|
22
|
+
@document.extend Dokkit::Resource::Extension::Url
|
23
|
+
end
|
24
|
+
it 'should resolve the absolute path name' do
|
25
|
+
@document.relative('/images/image.img').should == '../images/image.img'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# File 'filehelper_spec.rb' created on 28 feb 2008 at 16:44:07.
|
3
3
|
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
4
4
|
#
|
5
|
-
# (c)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
5
|
+
# (c) 2006, 2007, 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
6
6
|
#
|
7
7
|
# To execute this spec run:
|
8
8
|
#
|
@@ -10,25 +10,24 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
|
13
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'
|
13
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../lib')))
|
14
14
|
|
15
15
|
require 'rubygems'
|
16
16
|
require 'spec'
|
17
17
|
require 'dokkit'
|
18
|
-
require 'dokkit/
|
19
|
-
require
|
18
|
+
require 'dokkit/resource/filenamehelper'
|
19
|
+
require 'spec/spec_helper.rb'
|
20
20
|
|
21
|
-
describe Dokkit::
|
21
|
+
describe Dokkit::Resource::FilenameHelper do
|
22
22
|
before do
|
23
|
-
@
|
24
|
-
@
|
23
|
+
@resource = mock('resource')
|
24
|
+
@resource.extend Dokkit::Resource::FilenameHelper
|
25
25
|
end
|
26
|
-
it 'should
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
@
|
31
|
-
@document.relative('/images/image.img').should == '../images/image.img'
|
26
|
+
it 'should replace source path with the new path' do
|
27
|
+
@resource.filename_helper('doc/pages/resource', 'doc/pages', 'output').should == 'output/resource'
|
28
|
+
end
|
29
|
+
it 'should add new extension to the source extension' do
|
30
|
+
@resource.filename_helper('doc/pages/resource.ext', 'doc/pages', 'output', '.html').should == 'output/resource.ext.html'
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|