dokkit 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGES +15 -1
  2. data/LICENSE +673 -19
  3. data/README +32 -0
  4. data/Rakefile +59 -25
  5. data/bin/dokkit +48 -38
  6. data/lib/dokkit/#render_task_factory.rb# +94 -0
  7. data/lib/dokkit/app.rb +212 -257
  8. data/lib/dokkit/deplate/fmt/latex-notemplate.rb +3 -1
  9. data/lib/dokkit/dokkittasks.rb +45 -15
  10. data/lib/dokkit/filters/deplate.rb +11 -5
  11. data/lib/dokkit/hash.rb +41 -0
  12. data/lib/dokkit/models/Rakefile.tpl +9 -0
  13. data/lib/dokkit/models/share/builtin.rf +28 -0
  14. data/lib/dokkit/page.rb +161 -20
  15. data/lib/dokkit/render_task_factory.rb +91 -0
  16. data/lib/dokkit.rb +35 -42
  17. data/tests/data/output/simple_document/README +57 -0
  18. data/tests/data/output/simple_document/Rakefile +7 -0
  19. data/tests/data/output/simple_document/doc/config/simple_document.yaml +5 -0
  20. data/tests/data/output/simple_document/doc/pages/simple_document.dpl +12 -0
  21. data/{lib/dokkit/projects/website → tests/data/output/website_project}/Rakefile +2 -1
  22. data/tests/data/projects/simple-document/README +57 -0
  23. data/tests/data/projects/simple-document/Rakefile +22 -0
  24. data/tests/data/projects/simple-document/doc/config/author.yaml +4 -0
  25. data/tests/data/projects/simple-document/doc/config/model.yaml +18 -0
  26. data/tests/data/projects/simple-document/doc/config/simple_document.yaml +6 -0
  27. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +8 -0
  28. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +10 -0
  29. data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +8 -0
  30. data/tests/data/projects/simple-document/doc/layouts/semantic.cache +23 -0
  31. data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +23 -0
  32. data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +12 -0
  33. data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +12 -0
  34. data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +12 -0
  35. data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +4 -0
  36. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +12 -0
  37. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +3 -0
  38. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +2 -0
  39. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +12 -0
  40. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +12 -0
  41. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +8 -0
  42. data/tests/spec_page.rb +25 -0
  43. data/tests/test.rb +2 -0
  44. data/tests/test_application.rb +40 -0
  45. data/tests/test_builtin_tasks.rb +37 -0
  46. data/tests/test_config.rb +108 -0
  47. data/tests/test_core.rb +12 -0
  48. data/tests/test_dokkit_commandline.rb +18 -0
  49. data/tests/test_exception.rb +7 -0
  50. data/tests/test_filters.rb +1 -1
  51. data/tests/test_layout.rb +64 -0
  52. data/tests/test_options.rb +33 -0
  53. data/tests/test_project_tasks.rb +48 -0
  54. data/tests/test_recursive_merge.rb +42 -0
  55. data/tests/test_task_factory.rb +38 -0
  56. metadata +138 -94
  57. data/Rakefile.old +0 -62
  58. data/lib/dokkit/builtin.rake +0 -55
  59. data/lib/dokkit/projects/invoice/Rakefile +0 -100
  60. data/lib/dokkit/projects/invoice/doc/config/company.yaml +0 -12
  61. data/lib/dokkit/projects/invoice/doc/config/customer.yaml +0 -4
  62. data/lib/dokkit/projects/invoice/doc/layouts/invoice.dpltex +0 -90
  63. data/lib/dokkit/projects/invoice/doc/pages/COMMON.rb +0 -12
  64. data/lib/dokkit/projects/invoice/doc/pages/invoice.rb +0 -5
  65. data/lib/dokkit/projects/invoice/doc/pages/invoice.yamltex +0 -16
  66. data/lib/dokkit/projects/invoice/doc/res/tex/deplate.sty +0 -46
  67. data/lib/dokkit/projects/invoice/doc/res/tex/images/logo.eps +0 -209
  68. data/lib/dokkit/projects/invoice/doc/res/tex/include/deplate.sty +0 -46
  69. data/lib/dokkit/projects/invoice/doc/res/tex/include/layout.inc +0 -24
  70. data/lib/dokkit/projects/invoice/doc/res/tex/include/macro.inc +0 -67
  71. data/lib/dokkit/projects/invoice/doc/res/tex/include/packages.inc +0 -51
  72. data/lib/dokkit/projects/invoice/lib/invoice.rb +0 -104
  73. data/lib/dokkit/projects/tech_report/README +0 -49
  74. data/lib/dokkit/projects/tech_report/Rakefile +0 -102
  75. data/lib/dokkit/projects/tech_report/doc/config/company.yaml +0 -13
  76. data/lib/dokkit/projects/tech_report/doc/config/tech_report.yaml +0 -3
  77. data/lib/dokkit/projects/tech_report/doc/layouts/report.dpltex +0 -40
  78. data/lib/dokkit/projects/tech_report/doc/pages/COMMON.rb +0 -12
  79. data/lib/dokkit/projects/tech_report/doc/pages/report.dpltex +0 -37
  80. data/lib/dokkit/projects/tech_report/doc/pages/report.inc +0 -2
  81. data/lib/dokkit/projects/tech_report/doc/pages/report.rb +0 -3
  82. data/lib/dokkit/projects/tech_report/doc/res/attachments/attachment_2 +0 -0
  83. data/lib/dokkit/projects/tech_report/doc/res/tex/images/logo.eps +0 -311
  84. data/lib/dokkit/projects/tech_report/doc/res/tex/include/deplate.sty +0 -46
  85. data/lib/dokkit/projects/tech_report/doc/res/tex/include/layout.inc +0 -24
  86. data/lib/dokkit/projects/tech_report/doc/res/tex/include/macro.inc +0 -67
  87. data/lib/dokkit/projects/tech_report/doc/res/tex/include/packages.inc +0 -48
  88. data/lib/dokkit/projects/tech_report/doc/res/tex/report.bib +0 -4
  89. data/lib/dokkit/projects/tech_report/lib/tech_report.rb +0 -17
  90. data/lib/dokkit/projects/website/README +0 -49
  91. /data/{lib/dokkit/projects/invoice → tests/data/output/website_project}/README +0 -0
  92. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/layouts/normal.thtml +0 -0
  93. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/COMMON.rb +0 -0
  94. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/deplate.dplhtml +0 -0
  95. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.rb +0 -0
  96. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.thtml +0 -0
  97. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/res/images/rote-tiny.png +0 -0
  98. /data/{lib/dokkit/projects/tech_report/doc/res/attachments/attachment_1 → tests/pages/test.dpltex} +0 -0
@@ -0,0 +1,18 @@
1
+ #----------------------------------------------------------------------
2
+ #
3
+ # model.yaml created on 19 set 2007 at 22:37:25.
4
+ # See 'dokkit.rb' or LICENSE for licence information.
5
+ #
6
+ # (c)2007 Andrea Fazzi (and contributors).
7
+ #
8
+ # This is a config file for the current document. This file is written
9
+ # using YAML so you can easily modify it using YAML syntax. For further
10
+ # information about YAML please visit http://yaml.org.
11
+ #
12
+ #----------------------------------------------------------------------
13
+
14
+ model:
15
+ name: simpledocument
16
+ version: 0.1.0
17
+ language: en
18
+
@@ -0,0 +1,6 @@
1
+ document:
2
+ title: A simple document
3
+ author: John Doe
4
+
5
+
6
+
@@ -0,0 +1,8 @@
1
+ <html> <!-- Custom layout for simple_document -->
2
+ <head>
3
+ <title><%= @config['document']['title'] %></title>
4
+ </head>
5
+ <body>
6
+ <%= @content_for_layout %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,10 @@
1
+ \documentclass[a4paper,10pt]{article} % custom layout for simple_document
2
+
3
+ \title{<%= @config['title'] %>}
4
+ \author{<%= @config['author'] %>
5
+
6
+ \begin{document}
7
+
8
+ <%= @content_for_layout %>
9
+
10
+ \end{document}
@@ -0,0 +1,8 @@
1
+ <html> <!-- Custom layout with custom name for simple_document -->
2
+ <head>
3
+ <title><%= @config['document']['title'] %></title>
4
+ </head>
5
+ <body>
6
+ <%= @content_for_layout %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,23 @@
1
+ ;; Object layouts/
2
+ ;; SEMANTICDB Tags save file
3
+ (semanticdb-project-database-file "layouts/"
4
+ :tables (list
5
+ (semanticdb-table "layout_with_custom_name.html"
6
+ :major-mode 'html-mode
7
+ :tags '(("" section nil nil [81 142]) ("" section nil nil [142 147]))
8
+ :file "layout_with_custom_name.html"
9
+ :pointmax 194
10
+ :unmatched-syntax 'nil
11
+ )
12
+ (semanticdb-table "another_simple_document.html"
13
+ :major-mode 'html-mode
14
+ :tags '(("" section nil nil [64 125]) ("" section nil nil [125 130]))
15
+ :file "another_simple_document.html"
16
+ :pointmax 177
17
+ :unmatched-syntax 'nil
18
+ )
19
+ )
20
+ :file "semantic.cache"
21
+ :semantic-tag-version "2.0pre3"
22
+ :semanticdb-version "2.0pre3"
23
+ )
@@ -0,0 +1,23 @@
1
+ #-------------------------------------------------------------------------
2
+ #
3
+ # COMMON.yaml created on 01 ott 2007 at 15:21:20.
4
+ # See 'dokkit.rb' or LICENSE for licence information.
5
+ #
6
+ # (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
7
+ #
8
+ # This is a config file for the current document. This file is written
9
+ # using YAML so you can easily modify it using YAML syntax. For further
10
+ # information about YAML please visit http://yaml.org/.
11
+ #
12
+ #-------------------------------------------------------------------------
13
+
14
+ document:
15
+ title: A common title for document in pages dir
16
+ author:
17
+ name: John
18
+ surname: Doe
19
+ common_key: A common value for documents in pages dir
20
+
21
+
22
+
23
+
@@ -0,0 +1,12 @@
1
+ * Abstract
2
+ From a document of Jim{cite: author:jim}
3
+
4
+ * Introduction
5
+
6
+ * Main section
7
+
8
+ ** Subsection One
9
+ ** Subsection Two
10
+
11
+ * Conclusions
12
+
@@ -0,0 +1,12 @@
1
+ * Abstract
2
+ From a document of Jim{cite: author:jim}
3
+
4
+ * Introduction
5
+
6
+ * Main section
7
+
8
+ ** Subsection One
9
+ ** Subsection Two
10
+
11
+ * Conclusions
12
+
@@ -0,0 +1,12 @@
1
+ * Abstract
2
+ From a document of Jim{cite: author:jim}
3
+
4
+ * Introduction
5
+
6
+ * Main section
7
+
8
+ ** Subsection One
9
+ ** Subsection Two
10
+
11
+ * Conclusions
12
+
@@ -0,0 +1,4 @@
1
+ document:
2
+ title: A simple document in a subdirectory
3
+ common_key: A common value for documents in subdir
4
+
@@ -0,0 +1,12 @@
1
+ * Abstract
2
+ From a document of Jim{cite: author:jim}
3
+
4
+ * Introduction
5
+
6
+ * Main section
7
+
8
+ ** Subsection One
9
+ ** Subsection Two
10
+
11
+ * Conclusions
12
+
@@ -0,0 +1,2 @@
1
+ document:
2
+ common_key: A common value for documents in subdir/subdir
@@ -0,0 +1,12 @@
1
+ * Abstract
2
+ From a document of Jim{cite: author:jim}
3
+
4
+ * Introduction
5
+
6
+ * Main section
7
+
8
+ ** Subsection One
9
+ ** Subsection Two
10
+
11
+ * Conclusions
12
+
@@ -0,0 +1,12 @@
1
+ * Abstract
2
+ From a document of Jim{cite: author:jim}
3
+
4
+ * Introduction
5
+
6
+ * Main section
7
+
8
+ ** Subsection One
9
+ ** Subsection Two
10
+
11
+ * Conclusions
12
+
@@ -0,0 +1,8 @@
1
+ document:
2
+ layout: layout_with_custom_name
3
+ title: A simple document with layout with custom name
4
+ config: []
5
+ - author
6
+ - notexists
7
+
8
+
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'dokkit'
4
+
5
+ context 'A new page' do
6
+
7
+ setup do
8
+ @config_page_complete = { :fn => 'test.dpltex',
9
+ :layout_dir => 'layouts/',
10
+ :pages_dir => 'pages/',
11
+ :config_dir => 'config'
12
+ }
13
+
14
+ @config_page_incomplete = { :fn => 'test.dpltex', :pages_dir => 'pages/' }
15
+ end
16
+
17
+ specify 'should be correctly initialized if fn, layout_dir, pages_dir and config_dir are given' do
18
+ Rote::Page.new(@config_page_complete)
19
+ end
20
+
21
+ specify 'should have correct defaults for pages_dir, layout_dir and config_dir' do
22
+ Rote::Page.new(@config_page_incomplete)
23
+ end
24
+
25
+ end
data/tests/test.rb ADDED
@@ -0,0 +1,2 @@
1
+ break test_builtin_tasks.rb:45
2
+ break app.rb:211
@@ -0,0 +1,40 @@
1
+ #
2
+ # File 'test_application.rb' created on 22 Oct 2007 at 16:25:05.
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 unit test run:
8
+ #
9
+ # ruby test/test_application.rb
10
+ #
11
+
12
+ require 'rubygems'
13
+ require 'test/unit'
14
+ require 'dokkit'
15
+ require 'dokkit/app'
16
+
17
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
18
+
19
+ class TestApplication < Test::Unit::TestCase
20
+ def setup
21
+ end
22
+ def teardown
23
+ end
24
+ # The tests below need dokkit-model-simple-document gem to pass.
25
+ # Run:
26
+ # $ gem install dokkit-model-simpledocument
27
+ # to install the simpledocument model.
28
+ def test_fetch_models
29
+ assert(File.exists?(Dokkit.fetch_models['simple-document']))
30
+ end
31
+ def test_model_dir
32
+ assert(File.exists?(Dokkit.model_dir('simple-document')))
33
+ end
34
+ def test_model_layout_dir
35
+ assert(File.exists?(Dokkit.model_layout_dir('simple-document')))
36
+ end
37
+ def test_config_dir
38
+ assert(File.exists?(Dokkit.model_config_dir('simple-document')))
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'dokkit'
4
+ require 'dokkit/app'
5
+ require 'rake'
6
+
7
+
8
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
9
+
10
+ class TestBuiltinTask < Test::Unit::TestCase
11
+ OUTPUT_DIR = 'tests/data/output'
12
+ def setup
13
+ ARGV.clear
14
+ end
15
+ def test_builtin_task
16
+ Dokkit.application.init
17
+ Dokkit.application.define_builtin_tasks
18
+ assert_equal('create', Dokkit.application['create'].to_s)
19
+ end
20
+ def test_create_default_project_task
21
+ Dokkit.application.init
22
+ Dokkit.application.define_builtin_tasks
23
+ ARGV.push("create", "#{OUTPUT_DIR}/simple_document")
24
+ Dokkit.application.run
25
+ dir_content = Dir["#{OUTPUT_DIR}/simple_document/*"]
26
+ assert(!dir_content.empty? && !dir_content.include?('lib'))
27
+ end
28
+ def test_create_website_task
29
+ Dokkit.application.init
30
+ Dokkit.application.do_option('--project',"website")
31
+ Dokkit.application.define_builtin_tasks
32
+ ARGV.push("create", "#{OUTPUT_DIR}/website_project")
33
+ Dokkit.application.run
34
+ assert(Dir["#{OUTPUT_DIR}/website_project/*"].size > 1)
35
+ end
36
+ end
37
+
@@ -0,0 +1,108 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'dokkit'
4
+ require 'dokkit/app'
5
+ require 'dokkit/page'
6
+ require 'rake'
7
+
8
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
9
+
10
+ class TestConfig < Test::Unit::TestCase
11
+ PROJECT_DIR = File.join(Dokkit.tests_dir, 'data/projects/simple-document/')
12
+ def setup
13
+ Dir.chdir PROJECT_DIR
14
+ @simple_document = Rote::Page.new(
15
+ {
16
+ :fn => 'simple_document.dpl',
17
+ :pages_dir => 'doc/pages',
18
+ :layout_dir => 'doc/layouts',
19
+ :config_dir => 'doc/config',
20
+ :layout_defext => '.html',
21
+ :template_defext => '.dpl'
22
+ }
23
+ )
24
+
25
+ @simple_document_in_subdir = Rote::Page.new(
26
+ {
27
+ :fn => 'subdir/simple_document_in_subdir.dpl',
28
+ :pages_dir => 'doc/pages',
29
+ :layout_dir => 'doc/layouts',
30
+ :config_dir => 'doc/config',
31
+ :layout_defext => '.html',
32
+ :template_defext => '.dpl'
33
+ }
34
+ )
35
+
36
+ @another_simple_document_in_subdir = Rote::Page.new(
37
+ {
38
+ :fn => 'subdir/subdir/another_simple_document_in_subdir.dpl',
39
+ :pages_dir => 'doc/pages',
40
+ :layout_dir => 'doc/layouts',
41
+ :config_dir => 'doc/config',
42
+ :layout_defext => '.html',
43
+ :template_defext => '.dpl'
44
+ }
45
+ )
46
+
47
+ @another_simple_document = Rote::Page.new(
48
+ {
49
+ :fn => 'another_simple_document.dpl',
50
+ :pages_dir => 'doc/pages',
51
+ :layout_dir => 'doc/layouts',
52
+ :config_dir => 'doc/config',
53
+ :layout_defext => '.html',
54
+ :template_defext => '.dpl'
55
+ }
56
+ )
57
+ @yet_another_simple_document = Rote::Page.new(
58
+ {
59
+ :fn => 'yet_another_simple_document.dpl',
60
+ :pages_dir => 'doc/pages',
61
+ :layout_dir => 'doc/layouts',
62
+ :config_dir => 'doc/config',
63
+ :layout_defext => '.html',
64
+ :template_defext => '.dpl'
65
+ }
66
+ )
67
+ end
68
+ def test_model_key
69
+ assert @simple_document.instance_eval { @config['model'] }
70
+ end
71
+ def test_model_name_key
72
+ assert @simple_document.instance_eval { @config['model']['name'] }
73
+ end
74
+ def test_model_version_key
75
+ assert @simple_document.instance_eval { @config['model']['version'] }
76
+ end
77
+ def test_simple_document_default_config
78
+ assert_equal('A simple document', @simple_document.instance_eval { @config['document']['title'] })
79
+ end
80
+ def test_simple_document_common
81
+ assert_nil @simple_document.instance_eval { @config['document']['author']['name'] }
82
+ assert_equal('A common value for documents in pages dir', @simple_document.instance_eval { @config['document']['common_key'] })
83
+ end
84
+ def test_simple_document_in_subdir_config
85
+ assert_equal('A simple document in a subdirectory', @simple_document_in_subdir.instance_eval { @config['document']['title'] })
86
+ end
87
+ def test_simple_document_in_subdir_common
88
+ assert_equal('A simple document in a subdirectory', @simple_document_in_subdir.instance_eval { @config['document']['title'] })
89
+ assert_equal('A common value for documents in subdir', @simple_document_in_subdir.instance_eval { @config['document']['common_key'] })
90
+ assert_equal('John', @simple_document_in_subdir.instance_eval { @config['document']['author']['name'] })
91
+ end
92
+ def test_another_simple_document_in_subdir_common
93
+ assert_equal('A simple document in a subdirectory', @another_simple_document_in_subdir.instance_eval { @config['document']['title'] })
94
+ assert_equal('A common value for documents in subdir/subdir', @another_simple_document_in_subdir.instance_eval { @config['document']['common_key'] })
95
+ assert_equal('John', @another_simple_document_in_subdir.instance_eval { @config['document']['author']['name'] })
96
+ end
97
+ def test_another_simple_document_layout
98
+ assert_equal(['another_simple_document.html'], @another_simple_document.instance_eval { @layout_names })
99
+ end
100
+ def test_yet_another_simple_document_layout
101
+ assert_equal(['yet_another_simple_document.html', 'layout_with_custom_name.html'], @yet_another_simple_document.instance_eval { @layout_names })
102
+ end
103
+ def test_yet_another_simple_document_common
104
+ assert_equal('A simple document with layout with custom name', @yet_another_simple_document.instance_eval { @config['document']['title'] })
105
+ assert_equal('John', @yet_another_simple_document.instance_eval { @config['document']['author']['name'] })
106
+ assert_equal('john.doe@organization.org', @yet_another_simple_document.instance_eval { @config['document']['author']['email'] })
107
+ end
108
+ end
@@ -0,0 +1,12 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ nil
5
+ end
6
+
7
+ # make sure we're testing this version, not an installed Gem!
8
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
9
+
10
+ require 'tests/test_builtin_tasks.rb'
11
+ require 'tests/test_dokkit_commandline.rb'
12
+
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'dokkit'
4
+ require 'dokkit/app'
5
+ require 'rake'
6
+
7
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
8
+
9
+ class TestDirectoryOption < Test::Unit::TestCase
10
+ def setup
11
+ ARGV.clear
12
+ ARGV.push('--directory','tests/data/projects/tech_report')
13
+ end
14
+ def test_directory_option
15
+ Dokkit.application.load_rakefile
16
+ assert_equal('doc', Dokkit.application['doc'].to_s)
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ def test_exception
2
+ raise "File doesn't exist" if !File.exists?('null')
3
+ end
4
+
5
+ # begin
6
+ # test_exception
7
+ # end
@@ -43,4 +43,4 @@ module Dokkit
43
43
 
44
44
 
45
45
  end
46
-
46
+
@@ -0,0 +1,64 @@
1
+ #
2
+ # File 'test_layout.rb' created on 15 ott 2007 at 13:24:26.
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 unit test run:
8
+ #
9
+ # ruby test/test_layout.rb
10
+ #
11
+
12
+ require 'rubygems'
13
+ require 'test/unit'
14
+ require 'dokkit'
15
+ require 'dokkit/app'
16
+ require 'dokkit/page'
17
+
18
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
19
+
20
+ class TestLayout < Test::Unit::TestCase
21
+ PROJECT_DIR = File.join(Dokkit.tests_dir, 'data/projects/simple_document/')
22
+ def setup
23
+ Dir.chdir PROJECT_DIR
24
+ @simple_document = Rote::Page.new(
25
+ {
26
+ :fn => 'simple_document.dpl',
27
+ :pages_dir => 'doc/pages',
28
+ :layout_dir => 'doc/layouts',
29
+ :config_dir => 'doc/config',
30
+ :layout_defext => '.html',
31
+ :template_defext => '.dpl'
32
+ }
33
+ )
34
+ @simple_document_without_layout = Rote::Page.new(
35
+ {
36
+ :fn => 'simple_document_without_layout.dpl',
37
+ :pages_dir => 'doc/pages',
38
+ :layout_dir => 'doc/layouts',
39
+ :config_dir => 'doc/config',
40
+ :layout_defext => '.html',
41
+ :template_defext => '.dpl'
42
+ }
43
+ )
44
+ @another_simple_document = Rote::Page.new(
45
+ {
46
+ :fn => 'another_simple_document.dpl',
47
+ :pages_dir => 'doc/pages',
48
+ :layout_dir => 'doc/layouts',
49
+ :config_dir => 'doc/config',
50
+ :layout_defext => '.html',
51
+ :template_defext => '.dpl'
52
+ }
53
+ )
54
+ end
55
+ def teardown
56
+ end
57
+ def test_default_layout
58
+ assert_equal(['simple_document.html'], @simple_document.instance_eval { @layout_names })
59
+ assert_equal(['simple_document.html'], @simple_document_without_layout.instance_eval { @layout_names })
60
+ end
61
+ def test_overrided_layout
62
+ assert_equal(['another_simple_document.html'], @another_simple_document.instance_eval { @layout_names })
63
+ end
64
+ end
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ nil
5
+ end
6
+
7
+ # make sure we're testing this version, not an installed Gem!
8
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
9
+
10
+ require 'test/unit'
11
+ require 'dokkit'
12
+ require 'dokkit/app'
13
+ require 'rake'
14
+
15
+ # set dokkit_lib path
16
+ $:.each do |it|
17
+ if File.exists?(File.join(it,'dokkit/builtin.rake'))
18
+ DOKKIT_LIB = it
19
+ break
20
+ end
21
+ end
22
+
23
+ class TestOption < Test::Unit::TestCase
24
+
25
+ def test_change_dir
26
+ Dokkit::Application.new DOKKIT_LIB do |dokkit|
27
+ dokkit.do_option('--directory','/home/andrea')
28
+ dokkit.do_option('--tasks',nil)
29
+ dokkit.run
30
+ assert_equal('/home/andrea',Dir.pwd)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,48 @@
1
+ #
2
+ # File 'test_project_tasks.rb' created on 09 ott 2007 at 17:04:01.
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 unit test run:
8
+ #
9
+ # ruby test/test_project_tasks.rb
10
+ #
11
+
12
+ require 'rubygems'
13
+ require 'test/unit'
14
+ require 'dokkit'
15
+ require 'dokkit/app'
16
+ require 'rake'
17
+
18
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__),'../lib'))
19
+
20
+ class TestProjectTask < Test::Unit::TestCase
21
+ PROJECT_DIR = File.join(Dokkit.tests_dir, 'data/projects')
22
+ def setup
23
+ end
24
+ def teardown
25
+ Dokkit.application.run ['--directory', File.join(PROJECT_DIR, 'simple-document'), 'clobber']
26
+ end
27
+ def test_default_render_task
28
+ Dokkit.application.run ['--directory', File.join(PROJECT_DIR, 'simple-document')]
29
+ File.open(File.join(PROJECT_DIR, 'simple-document/html/simple_document.html')) do |file|
30
+ assert_equal('<html>', file.gets.chomp)
31
+ end
32
+ File.open(File.join(PROJECT_DIR, 'simple-document/html/another_simple_document.html')) do |file|
33
+ assert_equal('<html> <!-- Custom layout for simple_document -->', file.gets.chomp)
34
+ end
35
+ File.open(File.join(PROJECT_DIR, 'simple-document/html/simple_document_without_layout.html')) do |file|
36
+ assert_equal('<html>', file.gets.chomp)
37
+ end
38
+ end
39
+ def test_render_tex_task
40
+ Dokkit.application.run ['--directory', File.join(PROJECT_DIR, 'simple-document'), 'render_tex']
41
+ File.open(File.join(PROJECT_DIR, 'simple-document/tex/simple_document.tex')) do |file|
42
+ assert_match(/documentclass/, file.gets.chomp)
43
+ end
44
+ File.open(File.join(PROJECT_DIR, 'simple-document/tex/another_simple_document.tex')) do |file|
45
+ assert_match(/documentclass.*% custom/, file.gets.chomp)
46
+ end
47
+ end
48
+ end