dokkit 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -59
- data/lib/dokkit.rb +1 -1
- data/lib/dokkit/environment/basic.rb +23 -8
- data/lib/dokkit/filters.rb +1 -0
- data/lib/dokkit/filters/erb.rb +3 -3
- data/lib/dokkit/filters/haml.rb +31 -0
- data/lib/dokkit/models/simple/doc/layouts/simple.html +1 -1
- data/lib/dokkit/resource/document.rb +59 -63
- metadata +3 -61
- data/spec/dokkit/application_spec.rb +0 -141
- data/spec/dokkit/cache/cache_spec.rb +0 -87
- data/spec/dokkit/dokkit_spec.rb +0 -20
- data/spec/dokkit/environment/basic_spec.rb +0 -138
- data/spec/dokkit/environment/helpers/extmap_spec.rb +0 -52
- data/spec/dokkit/environment/helpers/fileselection_spec.rb +0 -80
- data/spec/dokkit/environment/helpers/test_data/doc/pages/document_1.ext_1 +0 -0
- data/spec/dokkit/environment/helpers/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/environment/helpers/test_data/doc/pages/document_3.ext_3 +0 -0
- data/spec/dokkit/environment/test_data/doc/data/data +0 -0
- data/spec/dokkit/environment/test_data/doc/pages/document_1 +0 -0
- data/spec/dokkit/environment/test_data/doc/pages/document_1.yaml +0 -3
- data/spec/dokkit/environment/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/environment/test_data/doc/pages/subdir/document_1 +0 -0
- data/spec/dokkit/factory/factory_spec.rb +0 -69
- data/spec/dokkit/filters/deplate_spec.rb +0 -47
- data/spec/dokkit/filters/erb_spec.rb +0 -26
- data/spec/dokkit/filters/maruku_spec.rb +0 -28
- data/spec/dokkit/filters/nil_spec.rb +0 -29
- data/spec/dokkit/filters/tidy_spec.rb +0 -48
- data/spec/dokkit/hash_spec.rb +0 -89
- data/spec/dokkit/logging/logger_spec.rb +0 -138
- data/spec/dokkit/logging/observers/console_spec.rb +0 -68
- data/spec/dokkit/resource/data_spec.rb +0 -32
- data/spec/dokkit/resource/document_spec.rb +0 -523
- data/spec/dokkit/resource/extensions/html_spec.rb +0 -35
- data/spec/dokkit/resource/extensions/url_spec.rb +0 -29
- data/spec/dokkit/resource/filenamehelper_spec.rb +0 -33
- data/spec/dokkit/resource/test_data/doc/configs/config_1.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/configs/config_2.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/configs/required.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/configs/subdir/document.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/layouts/container.html +0 -6
- data/spec/dokkit/resource/test_data/doc/layouts/layout.html +0 -6
- data/spec/dokkit/resource/test_data/doc/layouts/layout.latex +0 -8
- data/spec/dokkit/resource/test_data/doc/layouts/nested/nested.html +0 -4
- data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.html +0 -6
- data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.latex +0 -8
- data/spec/dokkit/resource/test_data/doc/pages/COMMON.yaml +0 -4
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_config.ext +0 -7
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_errors.ext +0 -12
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_targets.ext +0 -19
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nested_layout.ext +0 -13
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nil_target.ext +0 -5
- data/spec/dokkit/resource/test_data/doc/pages/document_with_not_defined_target.ext +0 -6
- data/spec/dokkit/resource/test_data/doc/pages/document_with_one_target.ext +0 -8
- data/spec/dokkit/resource/test_data/doc/pages/document_with_postfilter.ext +0 -10
- data/spec/dokkit/resource/test_data/doc/pages/subdir/COMMON.yaml +0 -3
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.ext +0 -8
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.yaml +0 -5
- data/spec/dokkit/tasklib/clean_spec.rb +0 -75
- data/spec/dokkit/tasklib/render_spec.rb +0 -125
- data/spec/dokkit/tasklib/test_data/doc/data/data_1 +0 -0
- data/spec/dokkit/tasklib/test_data/doc/pages/document_1 +0 -0
- data/spec/dokkit/tasklib/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model1/doc/pages/model1 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model2/doc/pages/model2 +0 -0
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -139
@@ -1,141 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'application_spec.rb' created on 08 mag 2008 at 17:26:24.
|
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/application'
|
13
|
-
require 'spec/spec_helper'
|
14
|
-
|
15
|
-
describe Dokkit::Application, ' options behaviour' do
|
16
|
-
include SpecHelper::CaptureOutput, SpecHelper::Logger
|
17
|
-
before(:all) do
|
18
|
-
@initial_dir = Dir.pwd
|
19
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
20
|
-
end
|
21
|
-
after(:all) do
|
22
|
-
Dir.chdir(@initial_dir)
|
23
|
-
end
|
24
|
-
before do
|
25
|
-
@logger = logger
|
26
|
-
@dokkit = Dokkit::Application.new(@logger, { :dokkit_dir => 'dokkit', :model_dir => 'models', :default_model => 'model1' })
|
27
|
-
end
|
28
|
-
after do
|
29
|
-
ARGV.clear
|
30
|
-
end
|
31
|
-
it 'should set default model' do
|
32
|
-
@dokkit.default_model.should == 'model1'
|
33
|
-
end
|
34
|
-
it 'should display version number' do
|
35
|
-
ARGV << '--version'
|
36
|
-
capture_stdout do
|
37
|
-
lambda do
|
38
|
-
@dokkit.run
|
39
|
-
end.should raise_error(SystemExit)
|
40
|
-
end.should match(/dokkit, version \d.\d.\d/)
|
41
|
-
end
|
42
|
-
#FIXME: Code duplication here ...
|
43
|
-
it 'should alias --help option with --usage' do
|
44
|
-
ARGV << '--help'
|
45
|
-
@output = capture_stdout do
|
46
|
-
lambda do
|
47
|
-
@dokkit.run
|
48
|
-
end.should raise_error(SystemExit)
|
49
|
-
end
|
50
|
-
@output.should match(/Usage: dokkit/)
|
51
|
-
@output.should match(/Recognized options/)
|
52
|
-
end
|
53
|
-
it 'should display usage information' do
|
54
|
-
ARGV << '--usage'
|
55
|
-
@output = capture_stdout do
|
56
|
-
lambda do
|
57
|
-
@dokkit.run
|
58
|
-
end.should raise_error(SystemExit)
|
59
|
-
end
|
60
|
-
@output.should match(/Usage: dokkit/)
|
61
|
-
@output.should match(/Recognized options/)
|
62
|
-
end
|
63
|
-
it 'should display the list of available models' do
|
64
|
-
ARGV << '--list'
|
65
|
-
@logger.should_receive(:info).with(/model[1-2]/).twice
|
66
|
-
lambda do
|
67
|
-
@dokkit.run
|
68
|
-
end.should raise_error(SystemExit)
|
69
|
-
end
|
70
|
-
it 'should fail if the number of commandline argument is less than one' do
|
71
|
-
@output = capture_stdout do
|
72
|
-
lambda do
|
73
|
-
@dokkit.run
|
74
|
-
end.should raise_error(SystemExit)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe Dokkit::Application, ' creating new documentation environment based on builtin model' do
|
80
|
-
include SpecHelper::CaptureOutput, SpecHelper::Logger
|
81
|
-
before(:all) do
|
82
|
-
@initial_dir = Dir.pwd
|
83
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
84
|
-
end
|
85
|
-
after(:all) do
|
86
|
-
Dir.chdir(@initial_dir)
|
87
|
-
end
|
88
|
-
before do
|
89
|
-
@logger = logger
|
90
|
-
@dokkit = Dokkit::Application.new(@logger)
|
91
|
-
end
|
92
|
-
after do
|
93
|
-
ARGV.clear
|
94
|
-
FileUtils.rm_rf 'project'
|
95
|
-
end
|
96
|
-
it 'should copy builtin model directory structure on destination dir' do
|
97
|
-
ARGV << 'project'
|
98
|
-
@dokkit.run
|
99
|
-
File.exists?('project/doc/pages/simple.deplate').should be_true
|
100
|
-
end
|
101
|
-
it 'should fail if the destination directory exists' do
|
102
|
-
ARGV << 'project'
|
103
|
-
FileUtils.mkdir 'project'
|
104
|
-
@logger.should_receive(:error).with(/already exists/)
|
105
|
-
@dokkit.run
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe Dokkit::Application, ' creating new documentation environment based on user models' do
|
110
|
-
include SpecHelper::CaptureOutput, SpecHelper::Logger
|
111
|
-
before(:all) do
|
112
|
-
@initial_dir = Dir.pwd
|
113
|
-
Dir.chdir(File.join(File.dirname(__FILE__), SpecHelper::Path::TEST_DATA))
|
114
|
-
end
|
115
|
-
after(:all) do
|
116
|
-
Dir.chdir(@initial_dir)
|
117
|
-
end
|
118
|
-
before do
|
119
|
-
@logger = logger
|
120
|
-
@dokkit = Dokkit::Application.new(@logger, { :dokkit_dir => 'dokkit', :model_dir => 'models', :default_model => 'model1' })
|
121
|
-
end
|
122
|
-
after do
|
123
|
-
ARGV.clear
|
124
|
-
FileUtils.rm_rf 'project'
|
125
|
-
end
|
126
|
-
it 'should copy model1 directory structure on destination dir' do
|
127
|
-
ARGV << 'project'
|
128
|
-
@dokkit.run
|
129
|
-
File.exists?('project/doc/pages/model1').should be_true
|
130
|
-
end
|
131
|
-
it 'should copy model2 directory structure on destination dir' do
|
132
|
-
ARGV.concat(['--model', 'model2', 'project'])
|
133
|
-
@dokkit.run
|
134
|
-
File.exists?('project/doc/pages/model2').should be_true
|
135
|
-
end
|
136
|
-
it 'should fail if not existent model is specified' do
|
137
|
-
ARGV.concat(['--model', 'notexists', 'project'])
|
138
|
-
@logger.should_receive(:error).with(/not found/)
|
139
|
-
@dokkit.run
|
140
|
-
end
|
141
|
-
end
|
@@ -1,87 +0,0 @@
|
|
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/cache'
|
19
|
-
require 'spec/spec_helper'
|
20
|
-
|
21
|
-
describe Dokkit::Cache do
|
22
|
-
include SpecHelper::Path
|
23
|
-
|
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
|
-
|
32
|
-
describe ' when initialized' do
|
33
|
-
before do
|
34
|
-
mkdir '.cache_test' unless File.exists?('.cache_test')
|
35
|
-
File.open(base_path('.cache_test/deps.rake'), 'w') do |file|
|
36
|
-
file.write YAML::dump({ document_path('document_1') => { 'html' => [document_path('document_1.dep')] } } )
|
37
|
-
end
|
38
|
-
@cache = Dokkit::Cache.new('deps.rake', '.cache_test')
|
39
|
-
end
|
40
|
-
it 'should import the cache file (if exists)' do
|
41
|
-
@cache.deps.should == { document_path('document_1') => { 'html' => [document_path('document_1.dep')] } }
|
42
|
-
end
|
43
|
-
after do
|
44
|
-
@cache.clean
|
45
|
-
rm_rf base_path('.cache_test')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#add_dependency' do
|
50
|
-
before do
|
51
|
-
@cache = Dokkit::Cache.new('deps.rake', '.cache_test')
|
52
|
-
end
|
53
|
-
it 'should add dependecies to the given document' do
|
54
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_1.dep')
|
55
|
-
@cache.deps.should == { document_path('document_1') => { 'html' => [document_path('document_1.dep')] } }
|
56
|
-
end
|
57
|
-
it 'should not add an existing dependency to the given document' do
|
58
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_1.dep')
|
59
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_1.dep')
|
60
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_2.dep')
|
61
|
-
@cache.deps.should == { document_path('document_1') => { 'html' => ['doc/pages/document_1.dep', 'doc/pages/document_2.dep'] } }
|
62
|
-
end
|
63
|
-
after do
|
64
|
-
@cache.clean
|
65
|
-
rm_rf '.cache_test'
|
66
|
-
@cache = nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#save' do
|
71
|
-
before do
|
72
|
-
@cache = Dokkit::Cache.new('deps.rake', '.cache_test')
|
73
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_1.dep')
|
74
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_2.dep')
|
75
|
-
@cache.add_dependency(document_path('document_1'), 'html', 'doc/pages/document_3.dep')
|
76
|
-
end
|
77
|
-
it 'should save the dependencies to file' do
|
78
|
-
@cache.save
|
79
|
-
File.exists?(base_path('.cache_test/deps.rake')).should be_true
|
80
|
-
end
|
81
|
-
after do
|
82
|
-
@cache.clean
|
83
|
-
rm_rf '.cache_test'
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
data/spec/dokkit/dokkit_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
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
|
-
|
@@ -1,138 +0,0 @@
|
|
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 ERB filter instance through filter factory' do
|
99
|
-
@container.filter_factory.get('erb', binding).is_a?(Filter::ERB).should be_true
|
100
|
-
end
|
101
|
-
it 'should construct a DeplateHTML filter instance through filter factory' do
|
102
|
-
@container.filter_factory.get('deplate-html').is_a?(Filter::DeplateHTML).should be_true
|
103
|
-
end
|
104
|
-
it 'should construct a DeplateText filter instance through filter factory' do
|
105
|
-
@container.filter_factory.get('deplate-text').is_a?(Filter::DeplateText).should be_true
|
106
|
-
end
|
107
|
-
it 'should construct a DeplateLatex filter instance through filter factory' do
|
108
|
-
@container.filter_factory.get('deplate-latex').is_a?(Filter::DeplateLatex).should be_true
|
109
|
-
end
|
110
|
-
it 'should construct a MarukuHTML filter instance through filter factory' do
|
111
|
-
@container.filter_factory.get('maruku-html').is_a?(Filter::MarukuHTML).should be_true
|
112
|
-
end
|
113
|
-
it 'should define render tasklib' do
|
114
|
-
@rake.tasks.should include(task('render:all'))
|
115
|
-
@rake.tasks.should include(task('render:data'))
|
116
|
-
end
|
117
|
-
it 'should define clean tasklib' do
|
118
|
-
@rake.tasks.should include(task('clean:all'))
|
119
|
-
@rake.tasks.should include(task('clean:output'))
|
120
|
-
@rake.tasks.should include(task('clean:cache'))
|
121
|
-
end
|
122
|
-
describe ' when an extension block is provided' do
|
123
|
-
before do
|
124
|
-
module Extension; def foo; end; end
|
125
|
-
end
|
126
|
-
before do
|
127
|
-
@container = Container.new do |c|
|
128
|
-
c.logger.level = Logging::OFF
|
129
|
-
c.extmap.include('document_1*').map { |document| document.extend Extension }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
it 'should map the extension to the corresponding document' do
|
133
|
-
@container.resource_factory.get(:document, 'doc/pages/document_1').respond_to?(:foo).should be_true
|
134
|
-
@container.resource_factory.get(:document, 'doc/pages/document_2').respond_to?(:foo).should be_false
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1,52 +0,0 @@
|
|
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
|
-
|
@@ -1,80 +0,0 @@
|
|
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
|
-
|