dokkit 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +125 -0
  3. data/README.txt +53 -0
  4. data/Rakefile +25 -167
  5. data/bin/dokkit +4 -60
  6. data/lib/dokkit/app.rb +63 -192
  7. data/lib/dokkit/builtintask.rb +85 -0
  8. data/lib/dokkit/cachemanager.rb +61 -0
  9. data/lib/dokkit/cleantask.rb +51 -0
  10. data/lib/dokkit/consolelog.rb +42 -0
  11. data/lib/dokkit/defaults.rb +19 -0
  12. data/lib/dokkit/document.rb +221 -0
  13. data/lib/dokkit/dokkitlib.rb +68 -0
  14. data/lib/dokkit/extension/extension.rb +15 -0
  15. data/lib/dokkit/extension/filehelper.rb +25 -0
  16. data/lib/dokkit/fileselection.rb +44 -0
  17. data/lib/dokkit/filters/all.rb +18 -0
  18. data/lib/dokkit/filters/base.rb +18 -0
  19. data/lib/dokkit/filters/deplate.rb +21 -25
  20. data/lib/dokkit/filters/maruku.rb +23 -0
  21. data/lib/dokkit/filters/nil.rb +23 -0
  22. data/lib/dokkit/filters.rb +29 -21
  23. data/lib/dokkit/logger.rb +73 -0
  24. data/lib/dokkit/model.rb +34 -0
  25. data/lib/dokkit/models/{Rakefile.tpl → simpledocument/model/Rakefile} +15 -2
  26. data/lib/dokkit/models/simpledocument/model/doc/configs/simpledocument.yaml +3 -0
  27. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.html +9 -0
  28. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.latex +8 -0
  29. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.text +1 -0
  30. data/lib/dokkit/models/simpledocument/model/doc/pages/simpledocument.deplate +102 -0
  31. data/lib/dokkit/models/simpledocument/model/tasks/all.rb +3 -0
  32. data/lib/dokkit/models/simpledocument/model/tasks/clean.rake +3 -0
  33. data/lib/dokkit/models/simpledocument/model/tasks/render.rake +8 -0
  34. data/lib/dokkit/models/simpledocument/model/tasks/setup.rb +9 -0
  35. data/lib/dokkit/modeltask.rb +83 -0
  36. data/lib/dokkit/pathhelper.rb +46 -0
  37. data/lib/dokkit/recursivemerge.rb +59 -0
  38. data/lib/dokkit/rendertask.rb +101 -0
  39. data/lib/dokkit/resourcemanager.rb +177 -0
  40. data/lib/dokkit/taskconfig.rb +39 -0
  41. data/lib/dokkit/templatetask.rb +37 -0
  42. data/lib/dokkit.rb +2 -8
  43. data/spec/app_spec.rb +55 -0
  44. data/spec/builtintask_spec.rb +114 -0
  45. data/spec/cachemanager_spec.rb +107 -0
  46. data/spec/cleantask_spec.rb +72 -0
  47. data/spec/consolelog_spec.rb +69 -0
  48. data/{tests/data/projects/simple-document → spec/data/test_build}/Rakefile +8 -8
  49. data/spec/data/test_build/doc/configs/document_1.yaml +3 -0
  50. data/spec/data/test_build/doc/configs/required.yaml +3 -0
  51. data/spec/data/test_build/doc/configs/subdir/document_4.yaml +3 -0
  52. data/spec/data/test_build/doc/layouts/document_1.html +9 -0
  53. data/spec/data/test_build/doc/layouts/document_1.latex +8 -0
  54. data/spec/data/test_build/doc/layouts/document_with_partials.html +9 -0
  55. data/spec/data/test_build/doc/layouts/layout +0 -0
  56. data/spec/data/test_build/doc/layouts/layout.html +8 -0
  57. data/spec/data/test_build/doc/layouts/layout.html.backup +8 -0
  58. data/spec/data/test_build/doc/layouts/nested.html +3 -0
  59. data/spec/data/test_build/doc/layouts/partials/partial.html +4 -0
  60. data/spec/data/test_build/doc/pages/COMMON.yaml +6 -0
  61. data/spec/data/test_build/doc/pages/document_1 +20 -0
  62. data/spec/data/test_build/doc/pages/document_1.dep +4 -0
  63. data/spec/data/test_build/doc/pages/document_1.yaml +11 -0
  64. data/spec/data/test_build/doc/pages/document_2 +9 -0
  65. data/spec/data/test_build/doc/pages/document_2.dep +0 -0
  66. data/spec/data/test_build/doc/pages/document_2.yaml +6 -0
  67. data/spec/data/test_build/doc/pages/document_3 +13 -0
  68. data/spec/data/test_build/doc/pages/document_5.exclude +0 -0
  69. data/spec/data/test_build/doc/pages/document_7 +4 -0
  70. data/spec/data/test_build/doc/pages/document_7.yaml +5 -0
  71. data/spec/data/test_build/doc/pages/document_extended +1 -0
  72. data/spec/data/test_build/doc/pages/document_nested +6 -0
  73. data/spec/data/test_build/doc/pages/document_nested.yaml +5 -0
  74. data/spec/data/test_build/doc/pages/document_nolayout.ext +3 -0
  75. data/spec/data/test_build/doc/pages/document_nolayout.yaml +2 -0
  76. data/spec/data/test_build/doc/pages/document_with_partials +3 -0
  77. data/spec/data/test_build/doc/pages/document_with_partials.yaml +2 -0
  78. data/spec/data/test_build/doc/pages/partials/COMMON.yaml +5 -0
  79. data/spec/data/test_build/doc/pages/partials/circular_partial +2 -0
  80. data/spec/data/test_build/doc/pages/partials/circular_partial.yaml +3 -0
  81. data/spec/data/test_build/doc/pages/partials/partial +2 -0
  82. data/spec/data/test_build/doc/pages/subdir/COMMON.yaml +2 -0
  83. data/spec/data/test_build/doc/pages/subdir/document_4 +11 -0
  84. data/spec/data/test_build/doc/pages/subdir/subdir/COMMON.yaml +2 -0
  85. data/spec/data/test_build/doc/pages/subdir/subdir/document_6 +3 -0
  86. data/spec/data/test_build/tasks/all.rb +3 -0
  87. data/spec/data/test_build/tasks/clean.rake +3 -0
  88. data/spec/data/test_build/tasks/render.rake +8 -0
  89. data/spec/data/test_build/tasks/setup.rb +9 -0
  90. data/spec/data/test_build/tasks/template.rake +3 -0
  91. data/spec/data/test_build/templates/layouts/layout +0 -0
  92. data/spec/data/test_build/templates/pages/template +0 -0
  93. data/spec/document_spec.rb +321 -0
  94. data/spec/dokkitlib_spec.rb +63 -0
  95. data/spec/filehelper_spec.rb +34 -0
  96. data/spec/fileselection_spec.rb +101 -0
  97. data/spec/filter_base_spec.rb +29 -0
  98. data/spec/filter_deplate_spec.rb +48 -0
  99. data/spec/filter_maruku_spec.rb +29 -0
  100. data/spec/filter_nil_spec.rb +30 -0
  101. data/spec/filters_spec.rb +37 -0
  102. data/spec/logger_spec.rb +150 -0
  103. data/spec/model_spec.rb +45 -0
  104. data/spec/pathhelper_spec.rb +62 -0
  105. data/spec/recursivemerge_spec.rb +91 -0
  106. data/spec/rendertask_spec.rb +374 -0
  107. data/spec/spec_helper.rb +61 -0
  108. data/spec/taskconfig_spec.rb +45 -0
  109. data/spec/templatetask_spec.rb +72 -0
  110. data/tasks/annotations.rake +30 -0
  111. data/tasks/doc.rake +49 -0
  112. data/tasks/gem.rake +89 -0
  113. data/tasks/manifest.rake +41 -0
  114. data/tasks/rubyforge.rake +57 -0
  115. data/tasks/setup.rb +151 -0
  116. data/tasks/spec.rake +40 -0
  117. data/tasks/svn.rake +44 -0
  118. data/tasks/test.rake +40 -0
  119. metadata +188 -161
  120. data/CHANGES +0 -26
  121. data/LICENSE +0 -674
  122. data/README +0 -32
  123. data/lib/dokkit/#render_task_factory.rb# +0 -94
  124. data/lib/dokkit/dokkittasks.rb +0 -99
  125. data/lib/dokkit/hash.rb +0 -41
  126. data/lib/dokkit/models/share/builtin.rf +0 -28
  127. data/lib/dokkit/page.rb +0 -195
  128. data/lib/dokkit/render_task_factory.rb +0 -91
  129. data/tests/data/output/simple_document/README +0 -57
  130. data/tests/data/output/simple_document/Rakefile +0 -7
  131. data/tests/data/output/simple_document/doc/config/simple_document.yaml +0 -5
  132. data/tests/data/output/simple_document/doc/pages/simple_document.dpl +0 -12
  133. data/tests/data/output/website_project/README +0 -49
  134. data/tests/data/output/website_project/Rakefile +0 -82
  135. data/tests/data/output/website_project/doc/layouts/normal.thtml +0 -38
  136. data/tests/data/output/website_project/doc/pages/COMMON.rb +0 -9
  137. data/tests/data/output/website_project/doc/pages/deplate.dplhtml +0 -9
  138. data/tests/data/output/website_project/doc/pages/index.rb +0 -10
  139. data/tests/data/output/website_project/doc/pages/index.thtml +0 -12
  140. data/tests/data/output/website_project/doc/res/images/rote-tiny.png +0 -0
  141. data/tests/data/projects/simple-document/README +0 -57
  142. data/tests/data/projects/simple-document/doc/config/author.yaml +0 -4
  143. data/tests/data/projects/simple-document/doc/config/model.yaml +0 -18
  144. data/tests/data/projects/simple-document/doc/config/simple_document.yaml +0 -6
  145. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +0 -8
  146. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +0 -10
  147. data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +0 -8
  148. data/tests/data/projects/simple-document/doc/layouts/semantic.cache +0 -23
  149. data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +0 -23
  150. data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +0 -12
  151. data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +0 -12
  152. data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +0 -12
  153. data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +0 -4
  154. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +0 -12
  155. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +0 -3
  156. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +0 -2
  157. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +0 -12
  158. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +0 -12
  159. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +0 -8
  160. data/tests/gem_tests.rb +0 -4
  161. data/tests/spec_page.rb +0 -25
  162. data/tests/test.rb +0 -2
  163. data/tests/test_application.rb +0 -40
  164. data/tests/test_builtin_tasks.rb +0 -37
  165. data/tests/test_config.rb +0 -108
  166. data/tests/test_core.rb +0 -12
  167. data/tests/test_dokkit_commandline.rb +0 -18
  168. data/tests/test_exception.rb +0 -7
  169. data/tests/test_filters.rb +0 -46
  170. data/tests/test_layout.rb +0 -64
  171. data/tests/test_options.rb +0 -33
  172. data/tests/test_project_tasks.rb +0 -48
  173. data/tests/test_recursive_merge.rb +0 -42
  174. data/tests/test_task_factory.rb +0 -38
  175. /data/{CONTRIBUTORS → lib/dokkit/models/simpledocument/model/doc/data/css/style.css} +0 -0
  176. /data/{DONE → spec/data/test_build/doc/data/resource} +0 -0
  177. /data/{TODO → spec/data/test_build/doc/data/resource.exclude} +0 -0
  178. /data/{tests/pages/test.dpltex → spec/data/test_build/doc/data/subdir/resource.insubdir} +0 -0
@@ -0,0 +1,374 @@
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)2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
6
+ #
7
+ # To execute this spec run:
8
+ #
9
+ # spec spec/rendertask_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/cachemanager'
18
+ require 'dokkit/rendertask'
19
+ require File.dirname(__FILE__) + '/spec_helper.rb'
20
+
21
+ describe 'a non configured RenderTask instance', :shared => true 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 = mock('model')
29
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
30
+ @rendertask = Dokkit::RenderTask.new(model)
31
+ end
32
+ after do
33
+ rm_rf output_path
34
+ rm_rf cache_path
35
+ Rake.application = nil
36
+ end
37
+ after(:all) do
38
+ Dir.chdir(@initial_dir)
39
+ end
40
+ end
41
+
42
+ describe 'a configured RenderTask instance', :shared => true do
43
+ include SpecPathHelper
44
+ before(:all) do
45
+ @initial_dir = Dir.pwd
46
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
47
+ end
48
+ before do
49
+ model = mock('model')
50
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
51
+ @cache = Dokkit::CacheManager.instance
52
+ @cache.init('deps.yaml', cache_path)
53
+ @rendertask = Dokkit::RenderTask.new(model, 'render') do |task|
54
+ task.config.output_dir = output_path
55
+ task.config.config_dir = config_path
56
+ task.config.layout_dir = layout_path
57
+ task.documents.dir = document_path
58
+ task.documents.include('**/*')
59
+ task.documents.exclude('*_extended', '**/*.exclude', '**/*.yaml', '**/*.dep', '**/*partial*')
60
+ task.data.dir = data_path
61
+ task.data.include('**/*')
62
+ task.data.exclude('**/*.exclude')
63
+ end
64
+ end
65
+ after do
66
+ rm_rf output_path
67
+ @cache.clean
68
+ Rake.application = nil
69
+ end
70
+ after(:all) do
71
+ Dir.chdir(@initial_dir)
72
+ end
73
+ end
74
+
75
+ describe 'a RenderTask instance initialized with a configuration hash and a block', :shared => true do
76
+ include SpecPathHelper
77
+ before(:all) do
78
+ @initial_dir = Dir.pwd
79
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
80
+ end
81
+ before do
82
+ @config = mock('config')
83
+ @config.should_receive(:document_dir).at_least(1).and_return(document_path + '/subdir')
84
+ @config.should_receive(:config_dir).at_least(1).and_return(config_path)
85
+ @config.should_receive(:layout_dir).at_least(1).and_return(layout_path)
86
+ @config.should_receive(:data_dir).at_least(1).and_return(data_path + '/subdir')
87
+ @config.should_receive(:output_dir).at_least(1).and_return(output_path)
88
+ @config.should_receive(:cache_dir).at_least(1).and_return(cache_path)
89
+ @config.should_receive(:directories).twice.and_return({
90
+ :document_dir => @config.document_dir,
91
+ :config_dir => @config.config_dir,
92
+ :layout_dir => @config.layout_dir,
93
+ :data_dir => @config.data_dir,
94
+ :output_dir => @config.output_dir,
95
+ :cache_dir => @config.cache_dir
96
+ })
97
+ model = mock('model')
98
+ model.should_receive(:config).and_return(@config)
99
+ @rendertask = Dokkit::RenderTask.new(model, 'render') do |task|
100
+ task.documents.include('*')
101
+ task.data.include('*')
102
+ end
103
+ end
104
+ after do
105
+ rm_rf output_path
106
+ rm_rf cache_path
107
+ Rake.application = nil
108
+ end
109
+ after(:all) do
110
+ Dir.chdir(@initial_dir)
111
+ end
112
+ end
113
+
114
+ describe 'a configured RenderTask instance with an extension block', :shared => true do
115
+ include SpecPathHelper
116
+ before(:all) do
117
+ @initial_dir = Dir.pwd
118
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
119
+ end
120
+ before do
121
+ module Extension
122
+ def extension
123
+ "Extension"
124
+ end
125
+ end
126
+ model = mock('model')
127
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
128
+ @rendertask = Dokkit::RenderTask.new(model, 'render') do |task|
129
+ task.config.output_dir = output_path
130
+ task.config.config_dir = config_path
131
+ task.config.layout_dir = layout_path
132
+ task.config.document_dir = document_path
133
+ task.config.data_dir = data_path
134
+ task.documents.include('**/*')
135
+ task.documents.exclude('**/*.exclude', '**/*.yaml', '**/*.dep')
136
+ task.data.include('**/*')
137
+ task.data.exclude('**/*.exclude')
138
+ task.documents.extend(/document_extended$/) { |document| document.extend Extension }
139
+ end
140
+ end
141
+ after do
142
+ rm_rf output_path
143
+ rm_rf cache_path
144
+ Rake.application = nil
145
+ end
146
+ after(:all) do
147
+ Dir.chdir(@initial_dir)
148
+ end
149
+ end
150
+
151
+ describe Dokkit::RenderTask, ' when initialized with an empty document dir' do
152
+ it_should_behave_like 'a non configured RenderTask instance'
153
+ before do
154
+ Rake.application.clear
155
+ end
156
+ it 'should raise an empty dir error' do
157
+ lambda {
158
+ model = mock('model')
159
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
160
+ @empty = Dokkit::RenderTask.new(model, 'render') do |task|
161
+ task.documents.exclude('**/*')
162
+ end
163
+ puts @empty.documents.files
164
+ }.should raise_error(RuntimeError, /No documents found in \'.*\'/)
165
+ end
166
+ end
167
+
168
+ describe Dokkit::RenderTask, ' when initialized without a block' do
169
+ it_should_behave_like 'a non configured RenderTask instance'
170
+
171
+ it 'should be initialized with a default document_dir' do
172
+ @rendertask.config.document_dir.should == document_path
173
+ @rendertask.documents.dir == document_path
174
+ end
175
+ it 'should be initialized with a default layout_dir' do
176
+ @rendertask.config.layout_dir.should == layout_path
177
+ end
178
+ it 'should be initialized with a default config_dir' do
179
+ @rendertask.config.config_dir.should == config_path
180
+ end
181
+ it 'should be initialized with a default data_dir' do
182
+ @rendertask.config.data_dir.should == data_path
183
+ @rendertask.data.dir.should == data_path
184
+ end
185
+ end
186
+
187
+ describe Dokkit::RenderTask, ' when initialized with a configuration hash and a block' do
188
+ it_should_behave_like 'a RenderTask instance initialized with a configuration hash and a block'
189
+
190
+ it 'should be initialized with a default document_dir' do
191
+ @rendertask.config.document_dir.should == File.join(document_path, 'subdir')
192
+ @rendertask.documents.dir.should == File.join(document_path, 'subdir')
193
+ end
194
+ it 'should be initialized with the list of documents to render' do
195
+ @rendertask.documents.files.should have(1).items
196
+ @rendertask.documents.files.should == [document_path('subdir/document_4')]
197
+ end
198
+ it 'should be initialized with a default layout_dir' do
199
+ @rendertask.config.layout_dir.should == layout_path
200
+ end
201
+ it 'should be initialized with a default config_dir' do
202
+ @rendertask.config.config_dir.should == config_path
203
+ end
204
+ it 'should be initialized with a default data_dir' do
205
+ @rendertask.config.data_dir.should == File.join(data_path, 'subdir')
206
+ @rendertask.data.dir.should == File.join(data_path, 'subdir')
207
+ end
208
+ end
209
+
210
+ describe Dokkit::RenderTask, ' when initialized with a configuration block' do
211
+ it_should_behave_like 'a configured RenderTask instance'
212
+
213
+ it 'should be initialized with the config dir' do
214
+ @rendertask.config.config_dir.should == config_path
215
+ end
216
+ it 'should be initialized with the layout dir' do
217
+ @rendertask.config.layout_dir.should == layout_path
218
+ end
219
+ it 'should be initialized with the data dir' do
220
+ @rendertask.config.data_dir == data_path
221
+ end
222
+ it 'should be initialized with the output dir' do
223
+ @rendertask.config.output_dir == output_path
224
+ end
225
+ it 'should be initialized with the list of documents to render' do
226
+ @rendertask.documents.files.should have(8).items
227
+ @rendertask.documents.files.should include(
228
+ document_path('document_1'),
229
+ document_path('document_2'),
230
+ document_path('document_3'),
231
+ document_path('subdir/document_4'),
232
+ document_path('subdir/subdir/document_6')
233
+ )
234
+ end
235
+ it 'should be initialized with the list of data to copy' do
236
+ @rendertask.data.files.should have(2).items
237
+ @rendertask.data.files.should include(
238
+ data_path('resource'),
239
+ data_path('subdir/resource.insubdir')
240
+ )
241
+ end
242
+ it 'should define single document task and prerequisites' do
243
+ task(output_path('document_1.html')).prerequisites.should have(6).items
244
+ task(output_path('document_1.html')).prerequisites.should include(
245
+ document_path('document_1'),
246
+ config_path('document_1.yaml'),
247
+ document_path('COMMON.yaml'),
248
+ document_path('document_1.yaml'),
249
+ config_path('required.yaml'),
250
+ layout_path('document_1.html')
251
+ )
252
+ task(output_path('latex/document_1.latex')).prerequisites.should have(6).items
253
+ task(output_path('latex/document_1.latex')).prerequisites.should include(
254
+ document_path('document_1'),
255
+ config_path('document_1.yaml'),
256
+ document_path('COMMON.yaml'),
257
+ document_path('document_1.yaml'),
258
+ config_path('required.yaml'),
259
+ layout_path('document_1.latex')
260
+ )
261
+ end
262
+ it 'should define a render all documents task and prerequisites' do
263
+ task('render:doc').prerequisites.should have(9).items
264
+ task('render:doc').prerequisites.should include(
265
+ output_path('document_7.html'),
266
+ output_path('document_1.html'),
267
+ output_path('latex/document_1.latex'),
268
+ output_path('document_nolayout.html'),
269
+ output_path('document_2.html'),
270
+ output_path('document_3.html'),
271
+ output_path('subdir/subdir/document_6.html'),
272
+ output_path('subdir/document_4.html')
273
+ )
274
+ end
275
+ it 'should define a data task to copy single data file from data_dir to output_dir' do
276
+ task(output_path('resource')).prerequisites.should == [data_path('resource')]
277
+ task(output_path('subdir/resource.insubdir')).prerequisites.should == [data_path('subdir/resource.insubdir')]
278
+ end
279
+ it 'should define a copy_all_data task to copy all data from data_dir to output_dir' do
280
+ task('render:data').prerequisites.should == [
281
+ output_path('resource'),
282
+ output_path('subdir/resource.insubdir')
283
+ ]
284
+ end
285
+ it 'should define a render task to render the documents and copy the data' do
286
+ task('render:all').prerequisites.should == ['render:doc', 'render:data']
287
+ end
288
+ end
289
+
290
+ describe Dokkit::RenderTask, ' when configured with not existent directories' do
291
+ include SpecPathHelper
292
+ before(:all) do
293
+ @initial_dir = Dir.pwd
294
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
295
+ end
296
+ it 'should raise an error if document_dir does not exist' do
297
+ lambda {
298
+ model = mock('model')
299
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
300
+ @rendertask = Dokkit::RenderTask.new(model, 'render') do |task|
301
+ task.config.output_dir = output_path
302
+ task.config.config_dir = 'notexist'
303
+ task.config.layout_dir = 'notexist'
304
+ task.config.document_dir = 'notexist'
305
+ task.config.data_dir = 'notexist'
306
+ task.documents.include('**/*')
307
+ task.documents.exclude('**/*.exclude', '**/*.yaml', '**/*.dep')
308
+ task.data.include('**/*')
309
+ task.data.exclude('**/*.exclude')
310
+ end
311
+ }.should raise_error(RuntimeError, /Directory '.*' does not exist/)
312
+ end
313
+ after do
314
+ rm_rf output_path
315
+ rm_rf cache_path
316
+ Rake.application = nil
317
+ end
318
+ after(:all) do
319
+ Dir.chdir(@initial_dir)
320
+ end
321
+ end
322
+
323
+ describe Dokkit::RenderTask, ' when data task is invoked' do
324
+ it_should_behave_like 'a configured RenderTask instance'
325
+
326
+ it 'should copy resources from data_dir to output_dir' do
327
+ task('render:data').invoke
328
+ File.exists?(File.join(output_path('resource'))).should be_true
329
+ end
330
+ it 'should copy resources from data_dir/subdir to output_dir/subdir' do
331
+ task('render:data').invoke
332
+ File.exists?(File.join(data_path, 'subdir', 'resource.insubdir')).should be_true
333
+ end
334
+ it 'should not copy resources that were explicity excluded' do
335
+ task('render:data').invoke
336
+ File.exists?(File.join(output_path('resource.exclude'))).should be_false
337
+ end
338
+ end
339
+
340
+ describe Dokkit::RenderTask, ' when a single file task is invoked' do
341
+ it_should_behave_like 'a configured RenderTask instance'
342
+
343
+ it 'should render document_1.html' do
344
+ task(output_path('document_1.html')).invoke
345
+ File.exists?(output_path('document_1.html')).should be_true
346
+ end
347
+ it 'should render document_1.latex' do
348
+ task(output_path('latex/document_1.latex')).invoke
349
+ File.exists?(output_path('latex/document_1.latex')).should be_true
350
+ end
351
+ end
352
+
353
+ describe Dokkit::RenderTask, ' when the render task is invoked' do
354
+ it_should_behave_like 'a configured RenderTask instance'
355
+
356
+ it 'should create document_1.html, document_2.html, latex/document_1.latex, document_3.html, subdir/document_4, subdir/subdir/document_6' do
357
+ task('render:all').invoke
358
+ File.exists?(output_path('document_1.html')).should be_true
359
+ File.exists?(output_path('latex/document_1.latex')).should be_true
360
+ File.exists?(output_path('document_2.html')).should be_true
361
+ File.exists?(output_path('document_3.html')).should be_true
362
+ File.exists?(output_path('subdir/document_4.html')).should be_true
363
+ File.exists?(output_path('subdir/subdir/document_6.html')).should be_true
364
+ end
365
+ end
366
+
367
+ describe Dokkit::RenderTask, ' when the render task is invoked for document_extended' do
368
+ it_should_behave_like 'a configured RenderTask instance with an extension block'
369
+
370
+ it 'should render extended variable' do
371
+ task(output_path('document_extended.html')).invoke
372
+ File.read(output_path('document_extended.html')).should match(/Extension/)
373
+ end
374
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # File 'spec_helper.rb' created on 12 gen 2008 at 20:25:09.
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
+
8
+ module SpecPathHelper
9
+ DATA_TEST_DIR = 'data/test_build'
10
+ DATA_DEST_DIR = 'data'
11
+ CACHE_PATH = '.cache'
12
+ DOCUMENT_PATH = 'doc/pages'
13
+ DATA_PATH = 'doc/data'
14
+ CONFIG_PATH = 'doc/configs'
15
+ LAYOUT_PATH = 'doc/layouts'
16
+ TEMPLATE_PATH = 'templates'
17
+ OUTPUT_PATH = 'output'
18
+ def base_path(fn = '')
19
+ File.join('.', fn)
20
+ end
21
+ def cache_path(fn = '')
22
+ File.join(base_path, CACHE_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
23
+ end
24
+ def document_path(fn = '')
25
+ File.join(base_path, DOCUMENT_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
26
+ end
27
+ def config_path(fn = '')
28
+ File.join(base_path, CONFIG_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
29
+ end
30
+ def layout_path(fn = '')
31
+ File.join(base_path, LAYOUT_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
32
+ end
33
+ def data_path(fn = '')
34
+ File.join(base_path, DATA_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
35
+ end
36
+ def output_path(fn = '')
37
+ File.join(base_path, OUTPUT_PATH, fn).sub(/^\.\//, '').sub(/\/$/, '')
38
+ end
39
+ end
40
+
41
+ module CaptureStdout
42
+ def capture_stdout
43
+ s = StringIO.new
44
+ oldstdout = $stdout
45
+ $stdout = s
46
+ yield
47
+ s.string
48
+ ensure
49
+ $stdout = oldstdout
50
+ 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
+ end
61
+
@@ -0,0 +1,45 @@
1
+ #
2
+ # File 'taskconfig_spec.rb' created on 29 feb 2008 at 07:45:54.
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/taskconfig_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/taskconfig'
19
+ require File.dirname(__FILE__) + '/spec_helper.rb'
20
+
21
+ describe Dokkit::TaskConfig, ' when initialized' do
22
+ before do
23
+ @taskconfig = Dokkit::TaskConfig.new do |config|
24
+ config.a_dir = 'a_dir/'
25
+ config.a_sub_dir = 'a_dir/subdir/'
26
+ config.another_dir = 'another_dir///'
27
+ config.right_dir = 'right_dir'
28
+ end
29
+ end
30
+ it 'should strip extra slashes from keys with _dir suffix' do
31
+ @taskconfig.a_dir.should == 'a_dir'
32
+ @taskconfig.a_sub_dir.should == 'a_dir/subdir'
33
+ @taskconfig.another_dir.should == 'another_dir'
34
+ @taskconfig.right_dir.should == 'right_dir'
35
+ end
36
+ it 'should return directory hash' do
37
+ @taskconfig.directories.should == {
38
+ :a_dir => 'a_dir',
39
+ :a_sub_dir => 'a_dir/subdir',
40
+ :another_dir => 'another_dir',
41
+ :right_dir => 'right_dir'
42
+ }
43
+ end
44
+ end
45
+
@@ -0,0 +1,72 @@
1
+ #
2
+ # File 'templatetask_spec.rb' created on 03 mar 2008 at 13:11: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/templatetask_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/templatetask'
19
+ require File.dirname(__FILE__) + '/spec_helper.rb'
20
+
21
+ describe Dokkit::TemplateTask do
22
+ include SpecPathHelper, CaptureStdout
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
+ ARGV.clear
29
+ Rake.application.clear
30
+ model = mock('model')
31
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
32
+ @templatetask = Dokkit::TemplateTask.new(model)
33
+ end
34
+ after do
35
+ rm document_path('template') if File.exists?(document_path('template'))
36
+ rm layout_path('newlayout') if File.exists?(layout_path('newlayout'))
37
+ end
38
+ after(:all) do
39
+ Dir.chdir(@initial_dir)
40
+ end
41
+ it 'should be initialized with the template dir' do
42
+ @templatetask.config.template_dir.should == SpecPathHelper::TEMPLATE_PATH
43
+ end
44
+ describe ' when create task is invoked' do
45
+ it 'should copy the given template from template dir to document dir' do
46
+ task('template:create').invoke('pages/template')
47
+ File.exists?(document_path('template')).should be_true
48
+ end
49
+ it 'should copy the given template from template dir to the given dir' do
50
+ ARGV.push('template:create[layouts/layout]')
51
+ ARGV.push('doc/layouts/newlayout')
52
+ Rake.application.collect_tasks
53
+ task('template:create').invoke('layouts/layout')
54
+ File.exists?(layout_path('newlayout')).should be_true
55
+ end
56
+ it 'should raise an error if the template file does not exist' do
57
+ lambda {
58
+ task('template:create').invoke('pages/notexist')
59
+ }.should raise_error(RuntimeError, /Template \'.*\' doesn't exist/)
60
+ end
61
+ it 'should inform that the template was copied successfully' do
62
+ ARGV.push('template:create[layouts/layout]')
63
+ ARGV.push('doc/layouts/newlayout')
64
+ Rake.application.collect_tasks
65
+ capture_stdout {
66
+ task('template:create').invoke('layouts/layout')
67
+ }.should match(/Copy template \'.*\' to/)
68
+ end
69
+ end
70
+ end
71
+
72
+
@@ -0,0 +1,30 @@
1
+ # $Id$
2
+
3
+ if HAVE_BONES
4
+
5
+ desc "Enumerate all annotations"
6
+ task :notes do
7
+ Bones::AnnotationExtractor.enumerate(
8
+ PROJ, "OPTIMIZE|FIXME|TODO", :tag => true)
9
+ end
10
+
11
+ namespace :notes do
12
+ desc "Enumerate all OPTIMIZE annotations"
13
+ task :optimize do
14
+ Bones::AnnotationExtractor.enumerate(PROJ, "OPTIMIZE")
15
+ end
16
+
17
+ desc "Enumerate all FIXME annotations"
18
+ task :fixme do
19
+ Bones::AnnotationExtractor.enumerate(PROJ, "FIXME")
20
+ end
21
+
22
+ desc "Enumerate all TODO annotations"
23
+ task :todo do
24
+ Bones::AnnotationExtractor.enumerate(PROJ, "TODO")
25
+ end
26
+ end
27
+
28
+ end # if HAVE_BONES
29
+
30
+ # EOF
data/tasks/doc.rake ADDED
@@ -0,0 +1,49 @@
1
+ # $Id$
2
+
3
+ require 'rake/rdoctask'
4
+
5
+ namespace :doc do
6
+
7
+ desc 'Generate RDoc documentation'
8
+ Rake::RDocTask.new do |rd|
9
+ rd.main = PROJ.rdoc_main
10
+ rd.options << '-d' if !WIN32 and `which dot` =~ %r/\/dot/
11
+ rd.rdoc_dir = PROJ.rdoc_dir
12
+
13
+ incl = Regexp.new(PROJ.rdoc_include.join('|'))
14
+ excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
15
+ files = PROJ.files.find_all do |fn|
16
+ case fn
17
+ when excl; false
18
+ when incl; true
19
+ else false end
20
+ end
21
+ rd.rdoc_files.push(*files)
22
+
23
+ title = "#{PROJ.name}-#{PROJ.version} Documentation"
24
+ title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
25
+
26
+ rd.options << "-t #{title}"
27
+ end
28
+
29
+ desc 'Generate ri locally for testing'
30
+ task :ri => :clobber_ri do
31
+ sh "#{RDOC} --ri -o ri ."
32
+ end
33
+
34
+ desc 'Remove ri products'
35
+ task :clobber_ri do
36
+ rm_r 'ri' rescue nil
37
+ end
38
+
39
+ end # namespace :doc
40
+
41
+ desc 'Alias to doc:rdoc'
42
+ task :doc => 'doc:rdoc'
43
+
44
+ desc 'Remove all build products'
45
+ task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
46
+
47
+ remove_desc_for_task %w(doc:clobber_rdoc doc:clobber_ri)
48
+
49
+ # EOF