dokkit 0.3.0 → 0.4.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 (180) hide show
  1. data/History.txt +5 -0
  2. data/Manifest.txt +90 -105
  3. data/README.txt +27 -7
  4. data/Rakefile +2 -3
  5. data/bin/dokkit +3 -2
  6. data/lib/dokkit/application.rb +159 -0
  7. data/lib/dokkit/cache/cache.rb +53 -0
  8. data/lib/dokkit/{models/simpledocument/model/Rakefile → cache.rb} +3 -15
  9. data/lib/dokkit/environment/basic.rb +156 -0
  10. data/lib/dokkit/environment/helpers/extmap.rb +29 -0
  11. data/lib/dokkit/environment/helpers/fileselection.rb +53 -0
  12. data/lib/dokkit/environment/helpers.rb +20 -0
  13. data/{spec/data/test_build/Rakefile → lib/dokkit/environment.rb} +4 -15
  14. data/lib/dokkit/factory/factory.rb +56 -0
  15. data/lib/dokkit/factory.rb +9 -0
  16. data/lib/dokkit/filters/deplate.rb +25 -20
  17. data/lib/dokkit/filters/maruku.rb +6 -5
  18. data/lib/dokkit/filters/nil.rb +7 -6
  19. data/lib/dokkit/filters.rb +5 -27
  20. data/lib/dokkit/hash.rb +82 -0
  21. data/lib/dokkit/{logger.rb → logging/logger.rb} +30 -24
  22. data/lib/dokkit/logging/observers/console.rb +52 -0
  23. data/lib/dokkit/{extension/extension.rb → logging/observers.rb} +7 -5
  24. data/lib/dokkit/logging.rb +11 -0
  25. data/lib/dokkit/models/simple/Rakefile +6 -0
  26. data/lib/dokkit/models/simple/doc/data/html/css/style.css +3 -0
  27. data/lib/dokkit/models/simple/doc/data/latex/deplate.sty +46 -0
  28. data/lib/dokkit/models/simple/doc/layouts/simple.html +9 -0
  29. data/lib/dokkit/models/simple/doc/layouts/simple.latex +11 -0
  30. data/lib/dokkit/models/simple/doc/pages/simple.deplate +80 -0
  31. data/lib/dokkit/models/simple/setup/setup.rb +10 -0
  32. data/lib/dokkit/resource/data.rb +36 -0
  33. data/lib/dokkit/resource/document.rb +385 -0
  34. data/lib/dokkit/resource/extensions/builtin.rb +19 -0
  35. data/lib/dokkit/resource/extensions/html.rb +22 -0
  36. data/lib/dokkit/resource/extensions/url.rb +25 -0
  37. data/lib/dokkit/{filters/base.rb → resource/extensions.rb} +7 -8
  38. data/lib/dokkit/resource/filenamehelper.rb +28 -0
  39. data/lib/dokkit/resource.rb +11 -0
  40. data/lib/dokkit/tasklib/clean.rb +73 -0
  41. data/lib/dokkit/tasklib/render.rb +137 -0
  42. data/lib/dokkit/tasklib.rb +11 -0
  43. data/lib/dokkit.rb +26 -29
  44. data/spec/dokkit/application_spec.rb +141 -0
  45. data/spec/dokkit/cache/cache_spec.rb +87 -0
  46. data/spec/dokkit/dokkit_spec.rb +20 -0
  47. data/spec/dokkit/environment/basic_spec.rb +135 -0
  48. data/spec/dokkit/environment/helpers/extmap_spec.rb +52 -0
  49. data/spec/dokkit/environment/helpers/fileselection_spec.rb +80 -0
  50. data/spec/dokkit/environment/test_data/doc/pages/document_1.yaml +3 -0
  51. data/spec/dokkit/factory/factory_spec.rb +69 -0
  52. data/spec/{filter_deplate_spec.rb → dokkit/filters/deplate_spec.rb} +7 -8
  53. data/spec/{filter_maruku_spec.rb → dokkit/filters/maruku_spec.rb} +3 -4
  54. data/spec/{filter_nil_spec.rb → dokkit/filters/nil_spec.rb} +3 -4
  55. data/spec/{recursivemerge_spec.rb → dokkit/hash_spec.rb} +25 -27
  56. data/spec/{logger_spec.rb → dokkit/logging/logger_spec.rb} +35 -47
  57. data/spec/{consolelog_spec.rb → dokkit/logging/observers/console_spec.rb} +14 -15
  58. data/spec/dokkit/resource/data_spec.rb +32 -0
  59. data/spec/dokkit/resource/document_spec.rb +485 -0
  60. data/spec/dokkit/resource/extensions/html_spec.rb +35 -0
  61. data/spec/dokkit/resource/extensions/url_spec.rb +29 -0
  62. data/spec/{filehelper_spec.rb → dokkit/resource/filenamehelper_spec.rb} +12 -13
  63. data/spec/dokkit/resource/test_data/doc/configs/config_1.yaml +3 -0
  64. data/spec/dokkit/resource/test_data/doc/configs/config_2.yaml +3 -0
  65. data/spec/dokkit/resource/test_data/doc/configs/required.yaml +3 -0
  66. data/spec/dokkit/resource/test_data/doc/configs/subdir/document.yaml +3 -0
  67. data/spec/dokkit/resource/test_data/doc/layouts/container.html +6 -0
  68. data/spec/dokkit/resource/test_data/doc/layouts/layout.html +6 -0
  69. data/spec/{data/test_build/doc/layouts → dokkit/resource/test_data/doc/layouts/nested}/nested.html +2 -1
  70. data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.html +6 -0
  71. data/spec/dokkit/resource/test_data/doc/pages/COMMON.yaml +4 -0
  72. data/spec/dokkit/resource/test_data/doc/pages/document_with_many_config.ext +7 -0
  73. data/spec/dokkit/resource/test_data/doc/pages/document_with_many_errors.ext +12 -0
  74. data/spec/dokkit/resource/test_data/doc/pages/document_with_many_targets.ext +19 -0
  75. data/spec/dokkit/resource/test_data/doc/pages/document_with_nested_layout.ext +13 -0
  76. data/spec/dokkit/resource/test_data/doc/pages/document_with_nil_target.ext +5 -0
  77. data/spec/dokkit/resource/test_data/doc/pages/document_with_not_defined_target.ext +6 -0
  78. data/spec/dokkit/resource/test_data/doc/pages/document_with_one_target.ext +8 -0
  79. data/spec/dokkit/resource/test_data/doc/pages/subdir/COMMON.yaml +3 -0
  80. data/spec/dokkit/resource/test_data/doc/pages/subdir/document.ext +8 -0
  81. data/spec/dokkit/resource/test_data/doc/pages/subdir/document.yaml +5 -0
  82. data/spec/dokkit/tasklib/clean_spec.rb +75 -0
  83. data/spec/dokkit/tasklib/render_spec.rb +125 -0
  84. data/spec/dokkit/tasklib/test_data/doc/pages/document_2 +0 -0
  85. data/spec/dokkit/test_data/dokkit/models/model1/doc/pages/model1 +0 -0
  86. data/spec/dokkit/test_data/dokkit/models/model2/doc/pages/model2 +0 -0
  87. data/spec/spec.opts +4 -0
  88. data/spec/spec_helper.rb +120 -47
  89. metadata +94 -117
  90. data/lib/dokkit/app.rb +0 -131
  91. data/lib/dokkit/builtintask.rb +0 -85
  92. data/lib/dokkit/cachemanager.rb +0 -61
  93. data/lib/dokkit/cleantask.rb +0 -51
  94. data/lib/dokkit/consolelog.rb +0 -42
  95. data/lib/dokkit/defaults.rb +0 -19
  96. data/lib/dokkit/deplate/fmt/html-notemplate.rb +0 -21
  97. data/lib/dokkit/deplate/fmt/latex-notemplate.rb +0 -24
  98. data/lib/dokkit/document.rb +0 -221
  99. data/lib/dokkit/dokkitlib.rb +0 -68
  100. data/lib/dokkit/extension/filehelper.rb +0 -25
  101. data/lib/dokkit/fileselection.rb +0 -44
  102. data/lib/dokkit/filters/all.rb +0 -18
  103. data/lib/dokkit/model.rb +0 -34
  104. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.html +0 -9
  105. data/lib/dokkit/models/simpledocument/model/doc/pages/simpledocument.deplate +0 -102
  106. data/lib/dokkit/models/simpledocument/model/tasks/all.rb +0 -3
  107. data/lib/dokkit/models/simpledocument/model/tasks/clean.rake +0 -3
  108. data/lib/dokkit/models/simpledocument/model/tasks/render.rake +0 -8
  109. data/lib/dokkit/models/simpledocument/model/tasks/setup.rb +0 -9
  110. data/lib/dokkit/modeltask.rb +0 -83
  111. data/lib/dokkit/pathhelper.rb +0 -46
  112. data/lib/dokkit/recursivemerge.rb +0 -59
  113. data/lib/dokkit/rendertask.rb +0 -101
  114. data/lib/dokkit/resourcemanager.rb +0 -177
  115. data/lib/dokkit/taskconfig.rb +0 -39
  116. data/lib/dokkit/templatetask.rb +0 -37
  117. data/spec/app_spec.rb +0 -55
  118. data/spec/builtintask_spec.rb +0 -114
  119. data/spec/cachemanager_spec.rb +0 -107
  120. data/spec/cleantask_spec.rb +0 -72
  121. data/spec/data/test_build/doc/configs/document_1.yaml +0 -3
  122. data/spec/data/test_build/doc/configs/required.yaml +0 -3
  123. data/spec/data/test_build/doc/configs/subdir/document_4.yaml +0 -3
  124. data/spec/data/test_build/doc/layouts/document_1.html +0 -9
  125. data/spec/data/test_build/doc/layouts/document_with_partials.html +0 -9
  126. data/spec/data/test_build/doc/layouts/layout.html +0 -8
  127. data/spec/data/test_build/doc/layouts/layout.html.backup +0 -8
  128. data/spec/data/test_build/doc/layouts/partials/partial.html +0 -4
  129. data/spec/data/test_build/doc/pages/COMMON.yaml +0 -6
  130. data/spec/data/test_build/doc/pages/document_1 +0 -20
  131. data/spec/data/test_build/doc/pages/document_1.dep +0 -4
  132. data/spec/data/test_build/doc/pages/document_1.yaml +0 -11
  133. data/spec/data/test_build/doc/pages/document_2 +0 -9
  134. data/spec/data/test_build/doc/pages/document_2.yaml +0 -6
  135. data/spec/data/test_build/doc/pages/document_3 +0 -13
  136. data/spec/data/test_build/doc/pages/document_7 +0 -4
  137. data/spec/data/test_build/doc/pages/document_7.yaml +0 -5
  138. data/spec/data/test_build/doc/pages/document_extended +0 -1
  139. data/spec/data/test_build/doc/pages/document_nested +0 -6
  140. data/spec/data/test_build/doc/pages/document_nested.yaml +0 -5
  141. data/spec/data/test_build/doc/pages/document_nolayout.ext +0 -3
  142. data/spec/data/test_build/doc/pages/document_nolayout.yaml +0 -2
  143. data/spec/data/test_build/doc/pages/document_with_partials +0 -3
  144. data/spec/data/test_build/doc/pages/document_with_partials.yaml +0 -2
  145. data/spec/data/test_build/doc/pages/partials/COMMON.yaml +0 -5
  146. data/spec/data/test_build/doc/pages/partials/circular_partial +0 -2
  147. data/spec/data/test_build/doc/pages/partials/circular_partial.yaml +0 -3
  148. data/spec/data/test_build/doc/pages/partials/partial +0 -2
  149. data/spec/data/test_build/doc/pages/subdir/COMMON.yaml +0 -2
  150. data/spec/data/test_build/doc/pages/subdir/document_4 +0 -11
  151. data/spec/data/test_build/doc/pages/subdir/subdir/COMMON.yaml +0 -2
  152. data/spec/data/test_build/doc/pages/subdir/subdir/document_6 +0 -3
  153. data/spec/data/test_build/tasks/all.rb +0 -3
  154. data/spec/data/test_build/tasks/clean.rake +0 -3
  155. data/spec/data/test_build/tasks/render.rake +0 -8
  156. data/spec/data/test_build/tasks/setup.rb +0 -9
  157. data/spec/data/test_build/tasks/template.rake +0 -3
  158. data/spec/document_spec.rb +0 -321
  159. data/spec/dokkitlib_spec.rb +0 -63
  160. data/spec/fileselection_spec.rb +0 -101
  161. data/spec/filter_base_spec.rb +0 -29
  162. data/spec/filters_spec.rb +0 -37
  163. data/spec/model_spec.rb +0 -45
  164. data/spec/pathhelper_spec.rb +0 -62
  165. data/spec/rendertask_spec.rb +0 -374
  166. data/spec/taskconfig_spec.rb +0 -45
  167. data/spec/templatetask_spec.rb +0 -72
  168. /data/lib/dokkit/models/{simpledocument/model/doc/configs/simpledocument.yaml → simple/doc/configs/simple.yaml} +0 -0
  169. /data/lib/dokkit/models/{simpledocument/model/doc/layouts/simpledocument.text → simple/doc/layouts/simple.text} +0 -0
  170. /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
  171. /data/spec/{data/test_build/doc/data/resource → dokkit/environment/helpers/test_data/doc/pages/document_2} +0 -0
  172. /data/spec/{data/test_build/doc/data/resource.exclude → dokkit/environment/helpers/test_data/doc/pages/document_3.ext_3} +0 -0
  173. /data/spec/{data/test_build/doc/data/subdir/resource.insubdir → dokkit/environment/test_data/doc/data/data} +0 -0
  174. /data/spec/{data/test_build/doc/layouts/layout → dokkit/environment/test_data/doc/pages/document_1} +0 -0
  175. /data/spec/{data/test_build/doc/pages/document_2.dep → dokkit/environment/test_data/doc/pages/document_2} +0 -0
  176. /data/spec/{data/test_build/doc/pages/document_5.exclude → dokkit/environment/test_data/doc/pages/subdir/document_1} +0 -0
  177. /data/{lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.latex → spec/dokkit/resource/test_data/doc/layouts/layout.latex} +0 -0
  178. /data/spec/{data/test_build/doc/layouts/document_1.latex → dokkit/resource/test_data/doc/layouts/subdir/document.latex} +0 -0
  179. /data/spec/{data/test_build/templates/layouts/layout → dokkit/tasklib/test_data/doc/data/data_1} +0 -0
  180. /data/spec/{data/test_build/templates/pages/template → dokkit/tasklib/test_data/doc/pages/document_1} +0 -0
@@ -0,0 +1,20 @@
1
+ #
2
+ # File 'dokkit_spec.rb' created on 08 mag 2008 at 17:03:32.
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
+
14
+ describe Dokkit do
15
+ it 'should set version number' do
16
+ VERSION.should match(/\d.\d.\d/)
17
+ end
18
+ end
19
+
20
+
@@ -0,0 +1,135 @@
1
+ #
2
+ # File 'environment_spec.rb' created on 01 mag 2008 at 15:34:55.
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/environment_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/environment/basic'
17
+ require 'spec/spec_helper.rb'
18
+
19
+ include Dokkit::Environment::Basic
20
+
21
+ module Dokkit
22
+ describe 'A container that includes basic documentation environment' do
23
+ include SpecHelper::Path
24
+ before(:all) do
25
+ @initial_dir = Dir.pwd
26
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
27
+ end
28
+ after(:all) do
29
+ Dir.chdir(@initial_dir)
30
+ end
31
+ before do
32
+ @rake = Rake.application
33
+ end
34
+ before do
35
+ @container = Container.new { |c| c.logger.level = Logging::OFF }
36
+ end
37
+ after do
38
+ Rake.application.clear
39
+ end
40
+ it 'should add lib folder to $:' do
41
+ $:.should include('lib')
42
+ end
43
+ it 'should initialize a console logger' do
44
+ @container.logger.is_a?(Logging::Logger).should be_true
45
+ end
46
+ it 'should initialize only one instance of Logger' do
47
+ @container.logger.object_id.should == @container.logger.object_id
48
+ end
49
+ it 'should set default directories in configuration struct' do
50
+ @container.configuration.marshal_dump.should == {
51
+ :document_dir => 'doc/pages',
52
+ :config_dir => 'doc/configs',
53
+ :layout_dir => 'doc/layouts',
54
+ :data_dir => 'doc/data',
55
+ :output_dir => 'output',
56
+ :cache_dir => '.cache'
57
+ }
58
+ end
59
+ it 'should initialize configuration struct only once' do
60
+ @container.configuration.object_id.should == @container.configuration.object_id
61
+ end
62
+ it 'should allow client to change configuration struct' do
63
+ @container.configuration.document_dir = 'doc/documents'
64
+ @container.configuration.document_dir.should == 'doc/documents'
65
+ end
66
+ it 'should set default document filelist' do
67
+ @container.documents.files.sort.should == ['doc/pages/document_1', 'doc/pages/document_2', 'doc/pages/subdir/document_1']
68
+ end
69
+ it 'should set default data filelist' do
70
+ @container.data.files.sort.should == ['doc/data/data']
71
+ end
72
+ it 'should allow client to change document filelist' do
73
+ @container.documents.exclude('*')
74
+ @container.documents.files.should be_empty
75
+ end
76
+ it 'should allow client to change data filelist' do
77
+ @container.data.exclude('*')
78
+ @container.data.files.should be_empty
79
+ end
80
+ it 'should set a block that construct a document instance' do
81
+ @container.document_factory_block.call(document_path('document_1')).is_a?(Resource::Document).should be_true
82
+ end
83
+ it 'should set a block that construct a data instance' do
84
+ @container.data_factory_block.call(data_path('data')).is_a?(Resource::Data).should be_true
85
+ end
86
+ it 'should construct a filter factory' do
87
+ @container.filter_factory.is_a?(Factory).should be_true
88
+ end
89
+ it 'should initialize only one instance of filter factory' do
90
+ @container.filter_factory.object_id.should == @container.filter_factory.object_id
91
+ end
92
+ it 'should construct a resource factory' do
93
+ @container.resource_factory.is_a?(Factory).should be_true
94
+ end
95
+ it 'should initialize only one instance of resource factory' do
96
+ @container.resource_factory.object_id.should == @container.resource_factory.object_id
97
+ end
98
+ it 'should construct a DeplateHTML filter instance through filter factory' do
99
+ @container.filter_factory.get('deplate-html').is_a?(Filter::DeplateHTML).should be_true
100
+ end
101
+ it 'should construct a DeplateText filter instance through filter factory' do
102
+ @container.filter_factory.get('deplate-text').is_a?(Filter::DeplateText).should be_true
103
+ end
104
+ it 'should construct a DeplateLatex filter instance through filter factory' do
105
+ @container.filter_factory.get('deplate-latex').is_a?(Filter::DeplateLatex).should be_true
106
+ end
107
+ it 'should construct a MarukuHTML filter instance through filter factory' do
108
+ @container.filter_factory.get('maruku-html').is_a?(Filter::MarukuHTML).should be_true
109
+ end
110
+ it 'should define render tasklib' do
111
+ @rake.tasks.should include(task('render:all'))
112
+ @rake.tasks.should include(task('render:data'))
113
+ end
114
+ it 'should define clean tasklib' do
115
+ @rake.tasks.should include(task('clean:all'))
116
+ @rake.tasks.should include(task('clean:output'))
117
+ @rake.tasks.should include(task('clean:cache'))
118
+ end
119
+ describe ' when an extension block is provided' do
120
+ before do
121
+ module Extension; def foo; end; end
122
+ end
123
+ before do
124
+ @container = Container.new do |c|
125
+ c.logger.level = Logging::OFF
126
+ c.extmap.include('document_1*').map { |document| document.extend Extension }
127
+ end
128
+ end
129
+ it 'should map the extension to the corresponding document' do
130
+ @container.resource_factory.get(:document, 'doc/pages/document_1').respond_to?(:foo).should be_true
131
+ @container.resource_factory.get(:document, 'doc/pages/document_2').respond_to?(:foo).should be_false
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,52 @@
1
+ #
2
+ # File 'extmap_spec.rb' created on 14 mag 2008 at 10:51:19.
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/environment/helpers/extmap'
13
+ require 'spec/spec_helper.rb'
14
+
15
+
16
+ module Dokkit
17
+ module Resource
18
+ module Extension
19
+
20
+ end
21
+ end
22
+ module Environment
23
+ module Helper
24
+ describe ExtMap do
25
+ include SpecHelper::Path
26
+ before(:all) do
27
+ @initial_dir = Dir.pwd
28
+ Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
29
+ end
30
+ after(:all) do
31
+ Dir.chdir(@initial_dir)
32
+ end
33
+ before do
34
+ @extension_block = lambda { |document| document.extend Extension }
35
+ @extmap = ExtMap.new('doc/pages').include('*.ext*').map(&@extension_block)
36
+ end
37
+ it 'should return the correct filelist array' do
38
+ @extmap.files.sort.should == [document_path('document_1.ext_1'), document_path('document_3.ext_3')]
39
+ end
40
+ it 'should map the extension block to document_1.ext_1' do
41
+ @extmap['doc/pages/document_1.ext_1'].should == @extension_block
42
+ end
43
+ it 'should map the extension block to document_1.ext_1' do
44
+ @extmap['doc/pages/document_3.ext_3'].should == @extension_block
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+
52
+
@@ -0,0 +1,80 @@
1
+ #
2
+ # File 'fileselect_spec.rb' created on 07 feb 2008 at 15:46:04.
3
+ # See 'dokkit.rb' or +LICENSE+ for licence information.
4
+ #
5
+ # (c) 2006, 2007, 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
6
+ #
7
+ # To execute this spec run:
8
+ #
9
+ # spec spec/fileselect_spec.rb
10
+ #
11
+
12
+
13
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../../../lib')))
14
+
15
+ require 'rubygems'
16
+ require 'spec'
17
+ require 'dokkit/environment/helpers/fileselection'
18
+ require 'spec/spec_helper.rb'
19
+
20
+ module Dokkit
21
+ module Environment
22
+ module Helper
23
+ describe FileSelection, ' when initialized' do
24
+ include SpecHelper::Path
25
+ before(:all) do
26
+ @initial_dir = Dir.pwd
27
+ Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..', SpecHelper::Path::TEST_DATA)))
28
+ end
29
+ after(:all) do
30
+ Dir.chdir(@initial_dir)
31
+ end
32
+ it 'should set the current dir as default base path' do
33
+ fs = FileSelection.new
34
+ fs.base_dir.should == '.'
35
+ end
36
+ it 'should set the given directory as the base path for all operations' do
37
+ fs = FileSelection.new(document_path)
38
+ fs.base_dir.should == document_path
39
+ end
40
+ end
41
+ describe FileSelection, '#files' do
42
+ include SpecHelper::Path
43
+ before(:all) do
44
+ @initial_dir = Dir.pwd
45
+ Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..', SpecHelper::Path::TEST_DATA)))
46
+ end
47
+ after(:all) do
48
+ Dir.chdir(@initial_dir)
49
+ end
50
+ it 'should return an array with the list of the included files in the given directory' do
51
+ FileSelection.new(document_path) do |fs|
52
+ fs.include('*')
53
+ end.files.should have(3).items
54
+ end
55
+ it 'should not include files that was explicity excluded' do
56
+ FileSelection.new(document_path) do |fs|
57
+ fs.exclude('*.exclude')
58
+ end.files.should_not include(document_path('document_5.exclude'))
59
+ end
60
+ it 'should include only the files that was explicity included' do
61
+ FileSelection.new(document_path) do |fs|
62
+ fs.include('*_1')
63
+ end.files.should include(document_path('document_1'))
64
+ end
65
+ it 'should not include the same files' do
66
+ FileSelection.new(document_path) do |fs|
67
+ fs.include('*')
68
+ fs.include('*')
69
+ end.files.should have(3).items
70
+ end
71
+ it 'should not include directory' do
72
+ FileSelection.new(document_path) do |fs|
73
+ fs.include('**/*')
74
+ end.files.should_not include(document_path('subdir'))
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ key: value
3
+ ---
@@ -0,0 +1,69 @@
1
+ #
2
+ # File 'factory_spec.rb' created on 25 apr 2008 at 19:42:47.
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/factory_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/factory/factory'
18
+ require 'spec/spec_helper.rb'
19
+
20
+ describe Dokkit::Factory do
21
+ include SpecHelper::Logger, SpecHelper::Cache, SpecHelper::Configuration, SpecHelper::Resource
22
+ before do
23
+ class Foo
24
+ attr_reader :arg1, :arg2
25
+ def initialize(arg1, arg2)
26
+ @arg1, @arg2 = arg1, arg2
27
+ end
28
+ end
29
+ @foo_factory_method = lambda { |arg1, arg2| Foo.new(arg1, arg2) }
30
+ end
31
+ describe ' when adding new factory method' do
32
+ before do
33
+ @factory = Dokkit::Factory.new
34
+ end
35
+ it 'should add new factory method for a particular class of objects' do
36
+ @factory.add(:foo => @foo_factory_method)
37
+ @factory.methods[:foo].should == @foo_factory_method
38
+ end
39
+ end
40
+ describe ' when client require an object instance' do
41
+ before do
42
+ @factory = Dokkit::Factory.new do |factory|
43
+ factory.add(:foo => @foo_factory_method)
44
+ end
45
+ end
46
+ it 'should construct an instance for the given class' do
47
+ instance = @factory.get(:foo, 'arg1', 'arg2')
48
+ instance.is_a?(Foo).should be_true
49
+ end
50
+ it 'should correctly process constructor arguments' do
51
+ instance = @factory.get(:foo, 'arg1', 'arg2')
52
+ instance.arg1.should == 'arg1'
53
+ instance.arg2.should == 'arg2'
54
+ end
55
+ it 'should correctly store instances' do
56
+ instance_1 = @factory.get(:foo, 'arg1', 'arg2')
57
+ instance_2 = @factory.get(:foo, 'arg3', 'arg4')
58
+ @factory.instances.should == { [:foo, 'arg1', 'arg2'] => instance_1, [:foo, 'arg3', 'arg4'] => instance_2}
59
+ end
60
+ it 'should instantiate only one object for a given class and arguments set' do
61
+ instance_1 = @factory.get(:foo, 'arg1', 'arg2')
62
+ instance_1.object_id.should == @factory.get(:foo, 'arg1', 'arg2').object_id
63
+ instance_1.object_id.should_not == @factory.get(:foo, 'arg3', 'arg4').object_id
64
+ instance_1.object_id.should == @factory.get(:foo, 'arg1', 'arg2').object_id
65
+ end
66
+ end
67
+ end
68
+
69
+
@@ -10,35 +10,34 @@
10
10
  #
11
11
 
12
12
 
13
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
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
18
  require 'dokkit/filters/deplate'
19
- require File.dirname(__FILE__) + '/spec_helper.rb'
20
19
 
21
- describe Dokkit::Filters::DeplateHTML do
20
+ describe Dokkit::Filter::DeplateHTML do
22
21
  before do
23
- @deplate = Dokkit::Filters::DeplateHTML.new
22
+ @deplate = Dokkit::Filter::DeplateHTML.new
24
23
  end
25
24
  it 'should transform deplate wiki text in html' do
26
25
  @deplate.filter('* Header').should =~ /\<h1.*\>1&nbsp;Header\<\/h1\>/
27
26
  end
28
27
  end
29
28
 
30
- describe Dokkit::Filters::DeplateLatex do
29
+ describe Dokkit::Filter::DeplateLatex do
31
30
  before do
32
- @deplate = Dokkit::Filters::DeplateLatex.new
31
+ @deplate = Dokkit::Filter::DeplateLatex.new
33
32
  end
34
33
  it 'should transform deplate wiki text in tex' do
35
34
  @deplate.filter('* Header').should =~ /\\section\{Header\}/
36
35
  end
37
36
  end
38
37
 
39
- describe Dokkit::Filters::DeplateText do
38
+ describe Dokkit::Filter::DeplateText do
40
39
  before do
41
- @deplate = Dokkit::Filters::DeplateText.new
40
+ @deplate = Dokkit::Filter::DeplateText.new
42
41
  end
43
42
  it 'should transform deplate wiki text in plain text' do
44
43
  @deplate.filter('* Header').should =~ /\n1 Header\n=+$/
@@ -10,17 +10,16 @@
10
10
  #
11
11
 
12
12
 
13
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
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
18
  require 'dokkit/filters/maruku'
19
- require File.dirname(__FILE__) + '/spec_helper.rb'
20
19
 
21
- describe Dokkit::Filters::MarukuHTML do
20
+ describe Dokkit::Filter::MarukuHTML do
22
21
  before do
23
- @maruku = Dokkit::Filters::MarukuHTML.new
22
+ @maruku = Dokkit::Filter::MarukuHTML.new
24
23
  end
25
24
  it 'should transform markdown text in html' do
26
25
  @result = @maruku.filter('# Header').should =~ /\<h1.*\>Header\<\/h1\>/
@@ -10,17 +10,16 @@
10
10
  #
11
11
 
12
12
 
13
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
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
18
  require 'dokkit/filters/nil'
19
- require File.dirname(__FILE__) + '/spec_helper.rb'
20
19
 
21
- describe Dokkit::Filters::Nil do
20
+ describe Dokkit::Filter::Nil do
22
21
  before do
23
- @nil = Dokkit::Filters::Nil.new
22
+ @nil = Dokkit::Filter::Nil.new
24
23
  end
25
24
  it 'should not transform source file' do
26
25
  @result = @nil.filter('Do *not* transform this text.').should == 'Do *not* transform this text.'
@@ -2,21 +2,14 @@
2
2
  # File 'recursivemerge_spec.rb' created on 09 feb 2008 at 19:08:20.
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-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
6
6
  #
7
- # To execute this spec run:
8
- #
9
- # spec spec/recursivemerge_spec.rb
10
- #
11
-
12
7
 
13
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../lib')))
8
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__),'../../lib')))
14
9
 
15
10
  require 'rubygems'
16
11
  require 'spec'
17
- require 'dokkit'
18
- require 'dokkit/recursivemerge'
19
- require File.dirname(__FILE__) + '/spec_helper.rb'
12
+ require 'dokkit/hash'
20
13
 
21
14
  describe Hash do
22
15
  describe 'when two hash with depth 0 are merged' do
@@ -37,7 +30,7 @@ describe Hash do
37
30
  @h1.recursive_merge(@h2).should == { :depth1 => { :a => "a'", :b => "b", :c => "c"}, :b => "b'" }
38
31
  end
39
32
  end
40
- describe Hash, 'when two hash with depth 2 and depth 1 are merged' do
33
+ describe 'when two hash with depth 2 and depth 1 are merged' do
41
34
  before do
42
35
  @h1 = { :depth1 => { :depth2 => { :a => "a", :b => "b" } }, :b => "b" }
43
36
  @h2 = { :depth1 => { :a => "a'", :b => "b'", :c => "c"}, :b => "b" }
@@ -46,7 +39,7 @@ describe Hash do
46
39
  @h1.recursive_merge(@h2).should == { :depth1 => {:depth2 => { :a => "a", :b => "b" }, :a => "a'", :b => "b'", :c => "c"}, :b => "b" }
47
40
  end
48
41
  end
49
- describe Hash, ' when a block is passed to recursive_merge' do
42
+ describe 'when a block is passed to recursive_merge' do
50
43
  it 'should use the block to store values' do
51
44
  { :a => 'a' }.recursive_merge({ :a => ['b', 'c'] }) do |key, value, other_value|
52
45
  if(value.class == String && other_value.class == Array)
@@ -57,13 +50,10 @@ describe Hash do
57
50
  end.should == { :a => ['a', 'b', 'c'] }
58
51
  end
59
52
  end
60
- end
61
-
62
- describe ConfigHash do
63
53
  describe 'when a string and an array are merged' do
64
54
  before do
65
- @h1 = { :a => 'a' }.extend ConfigHash
66
- @h2 = { :a => ['b', 'c'] }.extend ConfigHash
55
+ @h1 = { :a => 'a' }
56
+ @h2 = { :a => ['b', 'c'] }
67
57
  end
68
58
  it 'should concatenate the string and the array' do
69
59
  @h1.recursive_merge(@h2).should == { :a => ['a', 'b', 'c'] }
@@ -72,20 +62,28 @@ describe ConfigHash do
72
62
  end
73
63
  describe 'when two array are merged' do
74
64
  before do
75
- @h1 = { :a => { :b => ['a', 'b'] } }.extend ConfigHash
76
- @h2 = { :a => { :b => ['c', 'd'] } }.extend ConfigHash
65
+ @h1 = { :a => { :b => ['a', 'b'] } }
66
+ @h2 = { :a => { :b => ['c', 'd'] } }
77
67
  end
78
68
  it 'should concatenate the arrays' do
79
69
  @h1.recursive_merge(@h2).should == { :a => { :b => ['a', 'b', 'c', 'd'] } }
80
70
  end
81
- end
82
- describe 'when layout and config keys are merged' do
83
- before do
84
- @h1 = { :layout => ['layout_1', 'layout_2'], :config => 'config' }.extend ConfigHash
85
- @h2 = { :layout => ['layout_3', 'layout_4'], :config => ['config_1', 'config_2'] }.extend ConfigHash
71
+ end
72
+ describe 'when a :clear key is encountered' do
73
+ it 'should stop merging string and string' do
74
+ { :a => 'a', :b => 'b' }.recursive_merge({ :a => 'clear', :c => 'c' }).should == { :a => nil, :b => 'b', :c => 'c' }
75
+ end
76
+ it 'should stop merging symbol and string' do
77
+ { :a => :a, :b => 'b' }.recursive_merge({ :a => 'clear', :c => 'c' }).should == { :a => nil, :b => 'b', :c => 'c' }
78
+ end
79
+ it 'should stop merging arrays' do
80
+ { :a => ['a', 'b'], :b => 'b' }.recursive_merge({ :a => ['a', 'clear'], :c => 'c' }).should == { :a => ['a'], :b => 'b', :c => 'c' }
86
81
  end
87
- it 'should store the rvalue' do
88
- @h1.recursive_merge(@h2).should == { :layout => ['layout_3', 'layout_4'], :config => ['config_1', 'config_2'] }
82
+ it 'should stop merging array and string' do
83
+ { :a => ['a', 'b'], :b => 'b' }.recursive_merge({ :a => 'clear', :c => 'c' }).should == { :a => nil, :b => 'b', :c => 'c' }
89
84
  end
90
- end
85
+ it 'should stop merging string and array' do
86
+ { :a => 'a', :b => 'b' }.recursive_merge({ :a => ['clear', 'b'], :c => 'c' }).should == { :a => ['b'], :b => 'b', :c => 'c' }
87
+ end
88
+ end
91
89
  end