dokkit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,39 @@
1
+ #
2
+ # File 'taskconfig.rb' created on 29 feb 2008 at 07:50:50.
3
+ #
4
+ # See 'dokkit.rb' or +LICENSE+ for licence information.
5
+ #
6
+ # (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
7
+ #
8
+
9
+ require 'ostruct'
10
+
11
+ module Dokkit
12
+ class TaskConfig < OpenStruct
13
+ STRIP_SLASHES = /^\/?(.*?)\/*$/
14
+ attr_reader :config, :directories
15
+ def initialize(hash = nil)
16
+ super(hash)
17
+ @directories = { }
18
+
19
+ yield self if block_given?
20
+
21
+ strip_slashes_from_dir
22
+ end
23
+ def directories
24
+ methods.each do |meth|
25
+ @directories[meth.to_sym] = send(meth.to_sym) if (meth =~ /\_dir$/)
26
+ end
27
+ @directories
28
+ end
29
+
30
+ private
31
+
32
+ def strip_slashes_from_dir
33
+ directories.each do |meth, dir|
34
+ stripped_dir = send(meth)[STRIP_SLASHES, 1]
35
+ send((meth.to_s + '=').to_sym, stripped_dir)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ # File 'templatetask.rb' created on 03 mar 2008 at 13:16:03.
3
+ #
4
+ # See 'dokkit.rb' or +LICENSE+ for licence information.
5
+ #
6
+ # (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
7
+ #
8
+
9
+ require 'dokkit/dokkitlib'
10
+
11
+ module Dokkit
12
+ class TemplateTask < DokkitLib
13
+ def initialize(model, namespace = 'template')
14
+ super(model, namespace, { :check_dir => true })
15
+ end
16
+
17
+ private
18
+
19
+ def pre_block_configuration
20
+ @config.template_dir ||= Dokkit::DEFAULT_TEMPLATE_DIR
21
+ end
22
+ def define_dokkit_create_template
23
+ desc "Copy the template to the given directory."
24
+ dokkit_task 'create', :template do |t, args|
25
+ template_fn = File.join(@config.template_dir, args.template)
26
+ @logger.error("Template '#{args.template}' doesn't exist") unless File.exists?(template_fn)
27
+ if ARGV.size == 2
28
+ dest_fn = t.application.top_level_tasks.pop
29
+ else
30
+ dest_fn = File.join('doc', args.template)
31
+ end
32
+ @logger.info("Copy template '#{File.basename(template_fn)}' to '#{dest_fn}'")
33
+ cp(template_fn, dest_fn, :preserve => true, :verbose => false)
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/dokkit.rb CHANGED
@@ -40,11 +40,6 @@
40
40
  # If Dokkit has been loaded through Gems, this will automatically
41
41
  # come from the right lib directory...
42
42
 
43
- require 'rote/rotetasks'
44
- require 'dokkit/dokkittasks'
45
- require 'rote/page'
46
- require 'dokkit/page'
47
-
48
43
  # Everything else should come first from Gems, if installed.
49
44
  begin
50
45
  require 'rubygems'
@@ -53,9 +48,8 @@ rescue LoadError
53
48
  end
54
49
 
55
50
  require 'rake'
56
-
57
- # Master Dokkit version. Manage this from the Rake release support.
58
- DOKKITVERSION = '0.2.0'
51
+ require 'dokkit/app'
52
+ require 'dokkit/defaults'
59
53
 
60
54
  module Dokkit
61
55
 
data/spec/app_spec.rb ADDED
@@ -0,0 +1,55 @@
1
+ #
2
+ # File 'app_spec.rb' created on 20 feb 2008 at 20:15:42.
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/app_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/app'
19
+ require File.dirname(__FILE__) + '/spec_helper.rb'
20
+
21
+ describe Dokkit::Application, ' when initialized' do
22
+ before do
23
+ @app = Dokkit.application
24
+ end
25
+ after(:all) do
26
+ Dokkit.release
27
+ end
28
+ it 'should instantiate a ModelTask object to manage built-in tasks' do
29
+ @app.builtintask.should_not be_nil
30
+ end
31
+ end
32
+
33
+ describe Dokkit::Application, ' running' do
34
+ include CaptureStdout, SpecPathHelper
35
+ before(:all) do
36
+ @initial_dir = Dir.pwd
37
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_DEST_DIR))
38
+ end
39
+ before do
40
+ @app = Dokkit.application
41
+ end
42
+ after do
43
+ Dokkit.release
44
+ rm_rf 'spec/data/simpledocument'
45
+ end
46
+ after(:all) do
47
+ Dir.chdir(@initial_dir)
48
+ end
49
+ it 'should output the list of built-in tasks' do
50
+ capture_stdout do
51
+ @app.do_option('--tasks', nil)
52
+ @app.run
53
+ end.should match(/new documentation/)
54
+ end
55
+ end
@@ -0,0 +1,114 @@
1
+ #
2
+ # File 'modeltask_spec.rb' created on 23 feb 2008 at 20:33:52.
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/modeltask_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'
17
+ require 'dokkit/builtintask'
18
+ require File.dirname(__FILE__) + '/spec_helper.rb'
19
+
20
+ describe Dokkit::BuiltinTask, ' when initialized' do
21
+ before do
22
+ Rake.application = nil
23
+ application = mock('application')
24
+ application.stub!(:logger)
25
+ @builtintask = Dokkit::BuiltinTask.new(application)
26
+ end
27
+ it 'should know the full path of dokkit installation directory' do
28
+ File.exists?(@builtintask.dokkit_dir).should be_true
29
+ end
30
+ it 'should know the full path of the built-in models dir' do
31
+ File.exists?(@builtintask.builtin_model_dir).should be_true
32
+ end
33
+ it 'should set a default project model' do
34
+ Dokkit::DEFAULT_MODEL.should == 'simpledocument'
35
+ end
36
+ it 'should store the list of the installed models' do
37
+ File.exists?(File.join(@builtintask.models['simpledocument'], 'model')).should be_true
38
+ end
39
+ end
40
+
41
+ describe Dokkit::BuiltinTask, ' when list task is invoked' do
42
+ include CaptureStdout
43
+ before do
44
+ Rake.application = nil
45
+ application = mock('application')
46
+ application.stub!(:logger).and_return(Dokkit::Log::ConsoleLog.consolelog)
47
+ @builtintask = Dokkit::BuiltinTask.new(application)
48
+ end
49
+ it 'should list the models installed on the system' do
50
+ capture_stdout do
51
+ task('list').invoke
52
+ end.should match(/Found model 'simpledocument'/)
53
+ end
54
+ end
55
+
56
+ describe Dokkit::BuiltinTask, ' when create task is invoked' do
57
+ include CaptureStdout
58
+ before do
59
+ Rake.application = nil
60
+ ARGV.clear
61
+ application = mock('application')
62
+ application.stub!(:logger).and_return(Dokkit::Log::ConsoleLog.consolelog)
63
+ @builtintask = Dokkit::BuiltinTask.new(application)
64
+ end
65
+ after do
66
+ rm_rf 'spec/data/simpledocument'
67
+ end
68
+ it 'should create a new documentation directory using the given model' do
69
+ ARGV.push('model:create[simpledocument]')
70
+ ARGV.push('spec/data/simpledocument')
71
+ Rake.application.collect_tasks
72
+ task('create').invoke('simpledocument')
73
+ File.exists?('spec/data/simpledocument').should be_true
74
+ end
75
+ it 'should create a new documentation directory using simpledocument as default model' do
76
+ ARGV.push('create')
77
+ ARGV.push('spec/data/simpledocument')
78
+ Rake.application.collect_tasks
79
+ task('create').invoke
80
+ File.exists?('spec/data/simpledocument').should be_true
81
+ end
82
+ it 'should inform that a new documentation directory has been created' do
83
+ ARGV.push('create')
84
+ ARGV.push('spec/data/simpledocument')
85
+ Rake.application.collect_tasks
86
+ capture_stdout do
87
+ task('create').invoke
88
+ end.should match(/Create '.*' based on '.*' model/)
89
+ end
90
+ it 'should raise an error if model not found' do
91
+ ARGV.push('create[notexists]')
92
+ ARGV.push('spec/data/simpledocument')
93
+ Rake.application.collect_tasks
94
+ lambda {
95
+ task('create').invoke('spec/data/simpledocument')
96
+ }.should raise_error(RuntimeError, /Model '.*' not found/)
97
+ end
98
+ it 'should raise an error if target directory exists' do
99
+ ARGV.push('create')
100
+ ARGV.push('spec/data/test_build')
101
+ Rake.application.collect_tasks
102
+ lambda {
103
+ task('create').invoke
104
+ }.should raise_error(RuntimeError, /Directory '.*' exists./)
105
+ end
106
+ it 'should copy model.yaml in the target directory' do
107
+ ARGV.push('create')
108
+ ARGV.push('spec/data/simpledocument')
109
+ Rake.application.collect_tasks
110
+ task('create').invoke
111
+ File.exists?('spec/data/simpledocument/doc/configs/model.yaml').should be_true
112
+ end
113
+ end
114
+
@@ -0,0 +1,107 @@
1
+ #
2
+ # File 'cachemanager_spec.rb' created on 28 gen 2008 at 18:31:31.
3
+ # See 'dokkit.rb' or +LICENSE+ for licence information.
4
+ #
5
+ # (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
6
+ #
7
+ # To execute this spec run:
8
+ #
9
+ # spec spec/cachemanager_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/cachemanager'
19
+ require File.dirname(__FILE__) + '/spec_helper.rb'
20
+
21
+ describe Dokkit::CacheManager do
22
+ include SpecPathHelper
23
+
24
+ describe '#init' do
25
+ before do
26
+ mkdir base_path('.cache_test') unless File.exists?(base_path('.cache_test'))
27
+ File.open(base_path('.cache_test/deps.rake'), 'w') do |file|
28
+ file.write YAML::dump({ output_path('document_1.out') => [document_path('document_1.dep')] })
29
+ end
30
+ @cache = Dokkit::CacheManager.instance
31
+ @cache.init('deps.rake', base_path('.cache_test'))
32
+ end
33
+ it 'should import the cache file (if exists)' do
34
+ task(output_path('document_1.out')).prerequisites.should include(document_path('document_1.dep'))
35
+ end
36
+ it 'should update @deps to reflect imported tasks and dependencies' do
37
+ @cache.deps[output_path('document_1.out')].should == [document_path('document_1.dep')]
38
+ end
39
+ after do
40
+ @cache.instance_eval { @deps.clear }
41
+ rm_rf base_path('.cache_test')
42
+ @cache = nil
43
+ end
44
+ end
45
+ describe '#add_dependency' do
46
+ before do
47
+ @cache = Dokkit::CacheManager.instance
48
+ @cache.init('deps.rake', base_path('.cache_test'))
49
+ end
50
+ it 'should add dependecies to the given task' do
51
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_1.dep')
52
+ @cache.deps.should == {output_path('document_1.out') => ['doc/pages/document_1.dep']}
53
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_2.dep')
54
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_3.dep')
55
+ @cache.deps.should == {output_path('document_1.out') => [
56
+ 'doc/pages/document_1.dep',
57
+ 'doc/pages/document_2.dep',
58
+ 'doc/pages/document_3.dep'
59
+ ]}
60
+ end
61
+ it 'should not add an existing dependency to the given task' do
62
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_1.dep')
63
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_1.dep')
64
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_2.dep')
65
+ @cache.deps.should == {output_path('document_1.out') => ['doc/pages/document_1.dep', 'doc/pages/document_2.dep']}
66
+ end
67
+ after do
68
+ @cache.instance_eval { @deps.clear }
69
+ rm_rf base_path('.cache_test')
70
+ @cache = nil
71
+ end
72
+ end
73
+ describe '#clean' do
74
+ before do
75
+ @cache = Dokkit::CacheManager.instance
76
+ @cache.init('deps.rake', base_path('.cache_test'))
77
+ @cache.add_dependency(output_path('document_1.out'), 'doc/pages/document_1.dep')
78
+ @cache.save
79
+ end
80
+ it 'should remove cache directory from base path' do
81
+ @cache.clean
82
+ @cache.instance_eval { @deps }.should be_empty
83
+ File.exists?(base_path('.cache_test')).should be_false
84
+ end
85
+ after do
86
+ @cache.clean
87
+ @cache = nil
88
+ end
89
+ end
90
+ describe '#save' do
91
+ before do
92
+ @cache = Dokkit::CacheManager.instance
93
+ @cache.init('deps.rake', base_path('.cache_test'))
94
+ @cache.add_dependency('output/document_1.out', 'doc/pages/document_1.dep')
95
+ @cache.add_dependency('output/document_1.out', 'doc/pages/document_2.dep')
96
+ @cache.add_dependency('output/document_1.out', 'doc/pages/document_3.dep')
97
+ end
98
+ it 'should save the dependencies to file' do
99
+ @cache.save
100
+ File.exists?(base_path('.cache_test/deps.rake')).should be_true
101
+ end
102
+ after do
103
+ @cache.clean
104
+ @cache = nil
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ # File 'clean_spec.rb' created on 19 feb 2008 at 19:30:45.
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
+
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/rendertask'
19
+ require 'dokkit/cleantask'
20
+ require File.dirname(__FILE__) + '/spec_helper.rb'
21
+
22
+ describe Dokkit::CleanTask do
23
+ include SpecPathHelper
24
+ before(:all) do
25
+ @initial_dir = Dir.pwd
26
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecPathHelper::DATA_TEST_DIR))
27
+ end
28
+ before do
29
+ Rake.application.clear
30
+ model = mock('model')
31
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
32
+ @cleantask = Dokkit::CleanTask.new(model, 'clean') do |task|
33
+ task.config.output_dir = output_path
34
+ end
35
+ mkdir_p output_path
36
+ mkdir_p cache_path
37
+ end
38
+ after do
39
+ rmdir output_path if File.exists?(output_path)
40
+ rmdir cache_path if File.exists?(cache_path)
41
+ end
42
+ after(:all) do
43
+ Dir.chdir(@initial_dir)
44
+ end
45
+ it 'should be initialized with the output directory' do
46
+ @cleantask.config.output_dir.should == output_path
47
+ end
48
+ describe ' when clean:output is invoked' do
49
+ it 'should remove output directory' do
50
+ task('clean:output').invoke
51
+ File.exists?(@cleantask.config.output_dir).should be_false
52
+ end
53
+ end
54
+ describe ' when clean:cache is invoked' do
55
+ before do
56
+ Rake.application.clear
57
+ model = mock('model')
58
+ cache = mock('cache')
59
+ cache.should_receive(:cache_dir).and_return(cache_path)
60
+ cache.should_receive(:clean)
61
+ model.should_receive(:config).and_return(Dokkit::TaskConfig.new)
62
+ model.should_receive(:cache).twice.and_return(cache)
63
+ @cleantask = Dokkit::CleanTask.new(model, 'clean') do |task|
64
+ task.config.output_dir = output_path
65
+ end
66
+ end
67
+ it 'should call CacheManager#clean method to remove cache' do
68
+ task('clean:cache').invoke
69
+ end
70
+ end
71
+ end
72
+
@@ -0,0 +1,69 @@
1
+ #
2
+ # File 'consolelog_spec.rb' created on 23 feb 2008 at 16:40:31.
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/consolelog_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 File.dirname(__FILE__) + '/spec_helper.rb'
19
+
20
+ require 'dokkit/consolelog'
21
+
22
+ describe Dokkit::Log::ConsoleLog, ' when initialized' do
23
+ it 'should reference to a logger instance and attach to it' do
24
+ @logger = mock('logger')
25
+ @logger.should_receive(:attach)
26
+ @consolelog = Dokkit::Log::ConsoleLog.new(@logger)
27
+ @consolelog.logger.should_not be_nil
28
+ end
29
+ end
30
+
31
+ describe Dokkit::Log::ConsoleLog, ' when logger notifies' do
32
+ include CaptureStdout
33
+ before do
34
+ @logger = mock('logger')
35
+ @logger.should_receive(:attach)
36
+ @consolelog = Dokkit::Log::ConsoleLog.new(@logger)
37
+ end
38
+ describe ' an error message' do
39
+ it 'should send the error message to the console' do
40
+ @logger.should_receive(:last_message).and_return({ :text => 'error message', :level => Dokkit::Log::ERROR })
41
+ lambda { @consolelog.update }.should raise_error(RuntimeError, /\[ERROR\] error message/)
42
+ end
43
+ end
44
+ describe ' a warning message' do
45
+ it 'should send the warning message to the console' do
46
+ @logger.should_receive(:last_message).and_return({ :text => 'warning message', :level => Dokkit::Log::WARNING })
47
+ capture_stderr do
48
+ @consolelog.update
49
+ end.should match(/\[WARNING\] warning message/)
50
+ end
51
+ end
52
+ describe ' an info message' do
53
+ it 'should send the info message to the console' do
54
+ @logger.should_receive(:last_message).and_return({ :text => 'info message', :level => Dokkit::Log::INFO })
55
+ capture_stdout do
56
+ @consolelog.update
57
+ end.should match(/\[INFO\] info message/)
58
+ end
59
+ end
60
+ describe ' a debug message' do
61
+ it 'should send the debug message the console' do
62
+ @logger.should_receive(:last_message).and_return({ :text => 'debug message', :level => Dokkit::Log::DEBUG })
63
+ capture_stdout do
64
+ @consolelog.update
65
+ end.should match(/\[DEBUG\] debug message/)
66
+ end
67
+ end
68
+ end
69
+
@@ -5,18 +5,18 @@
5
5
  #
6
6
  # (C) 2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
7
7
  #
8
- # Rakefile for simpledocument project model
8
+ # Rakefile for website project model
9
+
10
+ require 'tasks/all'
11
+
12
+ task :clobber => 'clean:all'
13
+ task :default => 'render:all'
14
+
15
+
9
16
 
10
- require 'dokkit'
11
- require 'dokkit/app'
12
- require 'dokkit/render_task_factory'
13
17
 
14
18
 
15
- factory = Dokkit::RenderTaskFactory.instance
16
19
 
17
- factory.create_render_html
18
- factory.create_render_tex
19
20
 
20
- task :default => [:render_html]
21
21
 
22
22
 
@@ -0,0 +1,3 @@
1
+ ---
2
+ test_config_merge: This is to test the correct merge of document configuration keys.
3
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ required_key: required value for document_1
3
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ document:
3
+ test_config: This is to test configuration rendering.
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>A changed title</title>
4
+ </head>
5
+ <body>
6
+ <%= render_partial('partials/partial') %>
7
+ <%= @content_for_layout %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,8 @@
1
+ \documentclass[a4paper,12pt]{article}
2
+ \usepackage[utf8]{inputenc}
3
+
4
+ \begin{document}
5
+
6
+ <%= @content_for_layout %>
7
+
8
+ \end{document}
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>A changed title</title>
4
+ </head>
5
+ <body>
6
+ <%= render_partial('partials/circular_partial') %>
7
+ <%= @content_for_layout %>
8
+ </body>
9
+ </html>
File without changes
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>A title</title>
4
+ </head>
5
+ <body>
6
+ <%= @content_for_layout %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>A title</title>
4
+ </head>
5
+ <body>
6
+ <%= @content_for_layout %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,3 @@
1
+ <div class="nested">
2
+ <%= @content_for_layout %>
3
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="partial">
2
+ <%= @content_for_layout %>
3
+ </div>
4
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: document_1
3
+ test_common_key: common value for all the documents in the current directory
4
+
5
+
6
+
@@ -0,0 +1,20 @@
1
+ * Title for document_1
2
+ Body of document_1
3
+
4
+ * item 1
5
+ * item 2
6
+ * item 3
7
+
8
+ <%= configuration['test_config'] %>
9
+
10
+ <%= configuration['notexists'] %>
11
+
12
+ <%= configuration['test_config_merge'] %>
13
+
14
+ <%= "Current rendering format is: #{@format}" %>
15
+
16
+ * Section
17
+
18
+ <%= "This is to test embedded " + "e"+"r"+"b" + " in document_1 source file." %>
19
+
20
+
@@ -0,0 +1,4 @@
1
+ CHANGED!!!
2
+
3
+
4
+
@@ -0,0 +1,11 @@
1
+ ---
2
+ test_config: This is to test configuration rendering.
3
+ config:
4
+ - required
5
+ render_in:
6
+ - html
7
+ - tex:
8
+ filters:
9
+ - deplate-latex
10
+ ext: .latex
11
+ output: latex