nanoc 4.0.0b4 → 4.0.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +31 -32
- data/NEWS.md +7 -0
- data/README.md +1 -2
- data/Rakefile +2 -11
- data/TODO.md +0 -1
- data/bin/nanoc +4 -0
- data/lib/nanoc/base/checksummer.rb +1 -1
- data/lib/nanoc/base/compilation/compiler.rb +7 -13
- data/lib/nanoc/base/compilation/dependency_tracker.rb +1 -1
- data/lib/nanoc/base/compilation/rule.rb +2 -0
- data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
- data/lib/nanoc/base/entities/identifier.rb +45 -15
- data/lib/nanoc/base/entities/pattern.rb +8 -0
- data/lib/nanoc/base/entities/snapshot_def.rb +16 -0
- data/lib/nanoc/base/entities.rb +1 -0
- data/lib/nanoc/base/plugin_registry.rb +1 -1
- data/lib/nanoc/base/{compilation → repos}/checksum_store.rb +0 -0
- data/lib/nanoc/base/{compilation → repos}/compiled_content_cache.rb +0 -0
- data/lib/nanoc/base/repos/config_loader.rb +67 -0
- data/lib/nanoc/base/{compilation → repos}/rule_memory_store.rb +0 -0
- data/lib/nanoc/base/repos/site_loader.rb +118 -0
- data/lib/nanoc/base/{store.rb → repos/store.rb} +0 -0
- data/lib/nanoc/base/repos.rb +7 -0
- data/lib/nanoc/base/result_data/item_rep.rb +37 -66
- data/lib/nanoc/base/services/executor.rb +15 -9
- data/lib/nanoc/base/services/item_rep_writer.rb +1 -1
- data/lib/nanoc/base/services/recording_executor.rb +4 -4
- data/lib/nanoc/base/source_data/configuration.rb +89 -3
- data/lib/nanoc/base/source_data/data_source.rb +2 -15
- data/lib/nanoc/base/source_data/site.rb +14 -378
- data/lib/nanoc/base/views/{config.rb → config_view.rb} +0 -0
- data/lib/nanoc/base/views/{identifiable_collection.rb → identifiable_collection_view.rb} +0 -0
- data/lib/nanoc/base/views/{item_collection.rb → item_collection_view.rb} +0 -0
- data/lib/nanoc/base/views/{item_rep_collection.rb → item_rep_collection_view.rb} +7 -1
- data/lib/nanoc/base/views/{item_rep.rb → item_rep_view.rb} +0 -0
- data/lib/nanoc/base/views/{item.rb → item_view.rb} +0 -0
- data/lib/nanoc/base/views/{layout_collection.rb → layout_collection_view.rb} +0 -0
- data/lib/nanoc/base/views/{layout.rb → layout_view.rb} +0 -0
- data/lib/nanoc/base/views/mixins/{document.rb → document_view_mixin.rb} +0 -0
- data/lib/nanoc/base/views/mixins/{mutable_document.rb → mutable_document_view_mixin.rb} +0 -0
- data/lib/nanoc/base/views/{mutable_config.rb → mutable_config_view.rb} +0 -0
- data/lib/nanoc/base/views/{mutable_identifiable_collection.rb → mutable_identifiable_collection_view.rb} +0 -0
- data/lib/nanoc/base/views/{mutable_item_collection.rb → mutable_item_collection_view.rb} +0 -0
- data/lib/nanoc/base/views/{mutable_item.rb → mutable_item_view.rb} +0 -0
- data/lib/nanoc/base/views/{mutable_layout_collection.rb → mutable_layout_collection_view.rb} +0 -0
- data/lib/nanoc/base/views/{mutable_layout.rb → mutable_layout_view.rb} +0 -0
- data/lib/nanoc/base/views/{site.rb → site_view.rb} +0 -0
- data/lib/nanoc/base/views.rb +17 -17
- data/lib/nanoc/base.rb +1 -4
- data/lib/nanoc/cli/ansi_string_colorizer.rb +1 -1
- data/lib/nanoc/cli/cleaning_stream.rb +5 -0
- data/lib/nanoc/cli/command_runner.rb +10 -4
- data/lib/nanoc/cli/commands/compile.rb +1 -1
- data/lib/nanoc/cli/commands/create-site.rb +12 -11
- data/lib/nanoc/cli/commands/prune.rb +1 -0
- data/lib/nanoc/cli/commands/show-plugins.rb +4 -4
- data/lib/nanoc/cli/commands/show-rules.rb +21 -30
- data/lib/nanoc/cli/commands/view.rb +1 -1
- data/lib/nanoc/cli/error_handler.rb +1 -1
- data/lib/nanoc/cli.rb +3 -3
- data/lib/nanoc/data_sources/filesystem.rb +4 -4
- data/lib/nanoc/extra/checking/runner.rb +3 -2
- data/lib/nanoc/extra/deployers/rsync.rb +1 -1
- data/lib/nanoc/extra/link_collector.rb +1 -1
- data/lib/nanoc/helpers/capturing.rb +1 -1
- data/lib/nanoc/helpers/rendering.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.gemspec +3 -4
- data/tasks/doc.rake +1 -1
- data/tasks/rubocop.rake +4 -8
- data/tasks/test.rake +11 -27
- data/test/base/test_compiler.rb +21 -16
- data/test/base/test_compiler_dsl.rb +8 -8
- data/test/base/test_item.rb +1 -1
- data/test/base/test_item_rep.rb +16 -14
- data/test/base/test_memoization.rb +1 -38
- data/test/base/test_outdatedness_checker.rb +38 -6
- data/test/base/test_site.rb +19 -121
- data/test/cli/commands/test_compile.rb +1 -1
- data/test/cli/commands/test_create_site.rb +7 -8
- data/test/data_sources/test_filesystem.rb +7 -7
- data/test/data_sources/test_filesystem_unified.rb +17 -17
- data/test/extra/checking/checks/test_mixed_content.rb +8 -8
- data/test/extra/checking/checks/test_stale.rb +3 -4
- data/test/extra/deployers/test_fog.rb +1 -1
- data/test/extra/deployers/test_rsync.rb +2 -2
- data/test/extra/test_filesystem_tools.rb +1 -1
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_handlebars.rb +2 -2
- data/test/filters/test_less.rb +2 -2
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_relativize_paths.rb +1 -1
- data/test/filters/test_sass.rb +6 -6
- data/test/filters/test_xsl.rb +3 -3
- data/test/helper.rb +10 -15
- data/test/helpers/test_blogging.rb +16 -16
- data/test/helpers/test_capturing.rb +6 -6
- data/test/helpers/test_link_to.rb +13 -13
- data/test/helpers/test_rendering.rb +33 -0
- data/test/helpers/test_tagging.rb +8 -8
- metadata +32 -30
- data/test/gem_loader.rb +0 -9
data/test/base/test_item.rb
CHANGED
data/test/base/test_item_rep.rb
CHANGED
@@ -2,10 +2,10 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
2
2
|
def test_compiled_content_with_only_last_available
|
3
3
|
# Create rep
|
4
4
|
item = Nanoc::Int::Item.new(
|
5
|
-
'blah blah blah', {}, '/'
|
5
|
+
'blah blah blah', {}, '/'
|
6
6
|
)
|
7
7
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
8
|
-
rep.
|
8
|
+
rep.snapshot_contents = {
|
9
9
|
last: Nanoc::Int::TextualContent.new('last content'),
|
10
10
|
}
|
11
11
|
rep.expects(:compiled?).returns(true)
|
@@ -17,10 +17,10 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
17
17
|
def test_compiled_content_with_pre_and_last_available
|
18
18
|
# Create rep
|
19
19
|
item = Nanoc::Int::Item.new(
|
20
|
-
'blah blah blah', {}, '/'
|
20
|
+
'blah blah blah', {}, '/'
|
21
21
|
)
|
22
22
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
23
|
-
rep.
|
23
|
+
rep.snapshot_contents = {
|
24
24
|
pre: Nanoc::Int::TextualContent.new('pre content'),
|
25
25
|
last: Nanoc::Int::TextualContent.new('last content'),
|
26
26
|
}
|
@@ -33,10 +33,10 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
33
33
|
def test_compiled_content_with_custom_snapshot
|
34
34
|
# Create rep
|
35
35
|
item = Nanoc::Int::Item.new(
|
36
|
-
'blah blah blah', {}, '/'
|
36
|
+
'blah blah blah', {}, '/'
|
37
37
|
)
|
38
38
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
39
|
-
rep.
|
39
|
+
rep.snapshot_contents = {
|
40
40
|
pre: Nanoc::Int::TextualContent.new('pre content'),
|
41
41
|
last: Nanoc::Int::TextualContent.new('last content'),
|
42
42
|
}
|
@@ -49,10 +49,10 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
49
49
|
def test_compiled_content_with_invalid_snapshot
|
50
50
|
# Create rep
|
51
51
|
item = Nanoc::Int::Item.new(
|
52
|
-
'blah blah blah', {}, '/'
|
52
|
+
'blah blah blah', {}, '/'
|
53
53
|
)
|
54
54
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
55
|
-
rep.
|
55
|
+
rep.snapshot_contents = {
|
56
56
|
pre: Nanoc::Int::TextualContent.new('pre content'),
|
57
57
|
last: Nanoc::Int::TextualContent.new('last content'),
|
58
58
|
}
|
@@ -66,7 +66,7 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
66
66
|
def test_compiled_content_with_uncompiled_content
|
67
67
|
# Create rep
|
68
68
|
item = Nanoc::Int::Item.new(
|
69
|
-
'blah blah', {}, '/'
|
69
|
+
'blah blah', {}, '/'
|
70
70
|
)
|
71
71
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
72
72
|
rep.expects(:compiled?).returns(false)
|
@@ -80,11 +80,11 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
80
80
|
def test_compiled_content_with_moving_pre_snapshot
|
81
81
|
# Create rep
|
82
82
|
item = Nanoc::Int::Item.new(
|
83
|
-
'blah blah', {}, '/'
|
83
|
+
'blah blah', {}, '/'
|
84
84
|
)
|
85
85
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
86
86
|
rep.expects(:compiled?).returns(false)
|
87
|
-
rep.
|
87
|
+
rep.snapshot_contents = {
|
88
88
|
pre: Nanoc::Int::TextualContent.new('pre!'),
|
89
89
|
last: Nanoc::Int::TextualContent.new('last!'),
|
90
90
|
}
|
@@ -98,12 +98,14 @@ class Nanoc::Int::ItemRepTest < Nanoc::TestCase
|
|
98
98
|
def test_compiled_content_with_non_moving_pre_snapshot
|
99
99
|
# Create rep
|
100
100
|
item = Nanoc::Int::Item.new(
|
101
|
-
'blah blah', {}, '/'
|
101
|
+
'blah blah', {}, '/'
|
102
102
|
)
|
103
103
|
rep = Nanoc::Int::ItemRep.new(item, nil)
|
104
104
|
rep.expects(:compiled?).returns(false)
|
105
|
-
rep.
|
106
|
-
|
105
|
+
rep.snapshot_defs = [
|
106
|
+
Nanoc::Int::SnapshotDef.new(:pre, true),
|
107
|
+
]
|
108
|
+
rep.snapshot_contents = {
|
107
109
|
pre: Nanoc::Int::TextualContent.new('pre!'),
|
108
110
|
post: Nanoc::Int::TextualContent.new('post!'),
|
109
111
|
last: Nanoc::Int::TextualContent.new('last!'),
|
@@ -25,32 +25,7 @@ class Nanoc::Int::MemoizationTest < Nanoc::TestCase
|
|
25
25
|
memoize :run
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
extend Nanoc::Int::Memoization
|
30
|
-
|
31
|
-
def initialize(value)
|
32
|
-
@value = value
|
33
|
-
end
|
34
|
-
|
35
|
-
def hash
|
36
|
-
4
|
37
|
-
end
|
38
|
-
|
39
|
-
def eql?(_other)
|
40
|
-
true
|
41
|
-
end
|
42
|
-
|
43
|
-
def ==(_other)
|
44
|
-
true
|
45
|
-
end
|
46
|
-
|
47
|
-
def run(n)
|
48
|
-
@value * 10 + n
|
49
|
-
end
|
50
|
-
memoize :run
|
51
|
-
end
|
52
|
-
|
53
|
-
def test
|
28
|
+
def test_normal
|
54
29
|
sample1a = Sample1.new(10)
|
55
30
|
sample1b = Sample1.new(15)
|
56
31
|
sample2a = Sample2.new(20)
|
@@ -63,16 +38,4 @@ class Nanoc::Int::MemoizationTest < Nanoc::TestCase
|
|
63
38
|
assert_equal 100 * 25 + 7, sample2b.run(7)
|
64
39
|
end
|
65
40
|
end
|
66
|
-
|
67
|
-
def test_equal
|
68
|
-
sample1 = EqualSample.new(2)
|
69
|
-
sample2 = EqualSample.new(3)
|
70
|
-
|
71
|
-
3.times do
|
72
|
-
assert_equal 2 * 10 + 5, sample1.run(5)
|
73
|
-
assert_equal 2 * 10 + 3, sample1.run(3)
|
74
|
-
assert_equal 3 * 10 + 5, sample2.run(5)
|
75
|
-
assert_equal 3 * 10 + 3, sample2.run(3)
|
76
|
-
end
|
77
|
-
end
|
78
41
|
end
|
@@ -5,11 +5,14 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
5
5
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
6
6
|
File.open('lib/stuff.rb', 'w') { |io| io.write('$foo = 123') }
|
7
7
|
|
8
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
8
9
|
site.compile
|
9
10
|
end
|
10
11
|
|
11
12
|
# Check
|
12
13
|
with_site(name: 'foo') do |site|
|
14
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
15
|
+
site.compiler.load
|
13
16
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
14
17
|
rep = site.items['/'].reps[0]
|
15
18
|
assert_nil outdatedness_checker.outdatedness_reason_for(rep)
|
@@ -22,6 +25,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
22
25
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
23
26
|
File.open('lib/stuff.rb', 'w') { |io| io.write('$foo = 123') }
|
24
27
|
|
28
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
25
29
|
site.compile
|
26
30
|
end
|
27
31
|
|
@@ -32,6 +36,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
32
36
|
|
33
37
|
# Check
|
34
38
|
with_site(name: 'foo') do |site|
|
39
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
40
|
+
site.compiler.load
|
35
41
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
36
42
|
rep = site.items.find { |i| i.identifier == '/' }.reps[0]
|
37
43
|
assert_equal ::Nanoc::Int::OutdatednessReasons::NotEnoughData,
|
@@ -45,6 +51,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
45
51
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
46
52
|
File.open('lib/stuff.rb', 'w') { |io| io.write('$foo = 123') }
|
47
53
|
|
54
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
48
55
|
site.compile
|
49
56
|
end
|
50
57
|
|
@@ -55,6 +62,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
55
62
|
|
56
63
|
# Check
|
57
64
|
with_site(name: 'foo') do |site|
|
65
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
66
|
+
site.compiler.load
|
58
67
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
59
68
|
rep = site.items.find { |i| i.identifier == '/' }.reps[0]
|
60
69
|
assert_equal ::Nanoc::Int::OutdatednessReasons::NotWritten,
|
@@ -69,6 +78,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
69
78
|
File.open('content/new.html', 'w') { |io| io.write('o hello too') }
|
70
79
|
File.open('lib/stuff.rb', 'w') { |io| io.write('$foo = 123') }
|
71
80
|
|
81
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
72
82
|
site.compile
|
73
83
|
end
|
74
84
|
|
@@ -79,6 +89,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
79
89
|
|
80
90
|
# Check
|
81
91
|
with_site(name: 'foo') do |site|
|
92
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
93
|
+
site.compiler.load
|
82
94
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
83
95
|
rep = site.items.find { |i| i.identifier == '/new/' }.reps[0]
|
84
96
|
assert_equal ::Nanoc::Int::OutdatednessReasons::SourceModified,
|
@@ -92,6 +104,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
92
104
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
93
105
|
File.open('layouts/default.html', 'w') { |io| io.write('!!! <%= yield %> !!!') }
|
94
106
|
|
107
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
95
108
|
site.compile
|
96
109
|
end
|
97
110
|
|
@@ -103,6 +116,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
103
116
|
# Check
|
104
117
|
with_site(name: 'foo') do |site|
|
105
118
|
# FIXME: ugly fugly hack
|
119
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
106
120
|
site.compiler.load
|
107
121
|
|
108
122
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
@@ -122,6 +136,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
122
136
|
io.write('stuff')
|
123
137
|
end
|
124
138
|
|
139
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
125
140
|
site.compile
|
126
141
|
end
|
127
142
|
|
@@ -135,6 +150,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
135
150
|
# Check
|
136
151
|
with_site(name: 'foo') do |site|
|
137
152
|
# FIXME: ugly fugly hack
|
153
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
138
154
|
site.compiler.load
|
139
155
|
|
140
156
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
@@ -157,6 +173,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
157
173
|
io.write('stuff')
|
158
174
|
end
|
159
175
|
|
176
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
160
177
|
site.compile
|
161
178
|
end
|
162
179
|
|
@@ -170,6 +187,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
170
187
|
# Check
|
171
188
|
with_site(name: 'foo') do |site|
|
172
189
|
# FIXME: ugly fugly hack
|
190
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
173
191
|
site.compiler.load
|
174
192
|
|
175
193
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
@@ -191,6 +209,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
191
209
|
io.write('stuff')
|
192
210
|
end
|
193
211
|
|
212
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
194
213
|
site.compile
|
195
214
|
end
|
196
215
|
|
@@ -202,6 +221,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
202
221
|
# Check
|
203
222
|
with_site(name: 'foo') do |site|
|
204
223
|
# FIXME: ugly fugly hack
|
224
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
205
225
|
site.compiler.load
|
206
226
|
|
207
227
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
@@ -223,6 +243,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
223
243
|
io.write('stuff')
|
224
244
|
end
|
225
245
|
|
246
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
226
247
|
site.compile
|
227
248
|
end
|
228
249
|
|
@@ -236,6 +257,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
236
257
|
# Check
|
237
258
|
with_site(name: 'foo') do |site|
|
238
259
|
# FIXME: ugly fugly hack
|
260
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
239
261
|
site.compiler.load
|
240
262
|
|
241
263
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
@@ -252,6 +274,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
252
274
|
with_site(name: 'foo') do |site|
|
253
275
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
254
276
|
|
277
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
255
278
|
site.compile
|
256
279
|
end
|
257
280
|
|
@@ -262,6 +285,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
262
285
|
|
263
286
|
# Check
|
264
287
|
with_site(name: 'foo') do |site|
|
288
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
289
|
+
site.compiler.load
|
265
290
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
266
291
|
rep = site.items.find { |i| i.identifier == '/' }.reps[0]
|
267
292
|
assert_equal ::Nanoc::Int::OutdatednessReasons::CodeSnippetsModified,
|
@@ -274,6 +299,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
274
299
|
with_site(name: 'foo') do |site|
|
275
300
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
276
301
|
|
302
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
277
303
|
site.compile
|
278
304
|
end
|
279
305
|
|
@@ -291,6 +317,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
291
317
|
|
292
318
|
# Check
|
293
319
|
with_site(name: 'foo') do |site|
|
320
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
321
|
+
site.compiler.load
|
294
322
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
295
323
|
rep = site.items.find { |i| i.identifier == '/' }.reps[0]
|
296
324
|
assert_equal ::Nanoc::Int::OutdatednessReasons::ConfigurationModified,
|
@@ -303,6 +331,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
303
331
|
with_site(name: 'foo') do |site|
|
304
332
|
File.open('content/index.html', 'w') { |io| io.write('o hello') }
|
305
333
|
|
334
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
306
335
|
site.compile
|
307
336
|
end
|
308
337
|
|
@@ -313,6 +342,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
313
342
|
|
314
343
|
# Check
|
315
344
|
with_site(name: 'foo') do |site|
|
345
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
346
|
+
site.compiler.load
|
316
347
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
317
348
|
rep = site.items.find { |i| i.identifier == '/' }.reps[0]
|
318
349
|
assert_nil outdatedness_checker.outdatedness_reason_for(rep)
|
@@ -336,7 +367,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
336
367
|
|
337
368
|
# Compile once
|
338
369
|
FileUtils.cd('foo') do
|
339
|
-
site = Nanoc::Int::
|
370
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
340
371
|
site.compile
|
341
372
|
end
|
342
373
|
|
@@ -354,7 +385,8 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
354
385
|
|
355
386
|
# Check
|
356
387
|
FileUtils.cd('foo') do
|
357
|
-
site = Nanoc::Int::
|
388
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
389
|
+
site.compiler.load
|
358
390
|
outdatedness_checker = site.compiler.send :outdatedness_checker
|
359
391
|
rep = site.items.find { |i| i.identifier == '/' }.reps[0]
|
360
392
|
assert_equal ::Nanoc::Int::OutdatednessReasons::RulesModified,
|
@@ -379,13 +411,13 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
379
411
|
|
380
412
|
# Compile
|
381
413
|
FileUtils.cd('foo') do
|
382
|
-
site = Nanoc::Int::
|
414
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
383
415
|
site.compile
|
384
416
|
end
|
385
417
|
|
386
418
|
# Assert not outdated
|
387
419
|
FileUtils.cd('foo') do
|
388
|
-
site = Nanoc::Int::
|
420
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
389
421
|
outdatedness_checker = site.compiler.outdatedness_checker
|
390
422
|
site.items.each do |item|
|
391
423
|
refute outdatedness_checker.outdated?(item), 'item should not be outdated'
|
@@ -412,13 +444,13 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
|
|
412
444
|
|
413
445
|
# Compile
|
414
446
|
FileUtils.cd('foo') do
|
415
|
-
site = Nanoc::Int::
|
447
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
416
448
|
site.compile
|
417
449
|
end
|
418
450
|
|
419
451
|
# Assert not outdated
|
420
452
|
FileUtils.cd('foo') do
|
421
|
-
site = Nanoc::Int::
|
453
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
422
454
|
outdatedness_checker = site.compiler.outdatedness_checker
|
423
455
|
site.items.each do |item|
|
424
456
|
refute outdatedness_checker.outdated?(item), 'item should not be outdated'
|
data/test/base/test_site.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
class Nanoc::Int::SiteTest < Nanoc::TestCase
|
2
2
|
def test_initialize_with_dir_without_config_yaml
|
3
|
-
assert_raises(Nanoc::Int::
|
4
|
-
Nanoc::Int::
|
3
|
+
assert_raises(Nanoc::Int::ConfigLoader::NoConfigFileFoundError) do
|
4
|
+
Nanoc::Int::SiteLoader.new.new_from_cwd
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_initialize_with_dir_with_config_yaml
|
9
9
|
File.open('config.yaml', 'w') { |io| io.write('output_dir: public_html') }
|
10
|
-
site = Nanoc::Int::
|
10
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
11
11
|
assert_equal 'public_html', site.config[:output_dir]
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_initialize_with_dir_with_nanoc_yaml
|
15
15
|
File.open('nanoc.yaml', 'w') { |io| io.write('output_dir: public_html') }
|
16
|
-
site = Nanoc::Int::
|
16
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
17
17
|
assert_equal 'public_html', site.config[:output_dir]
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_initialize_with_config_hash
|
21
|
-
site = Nanoc::Int::
|
21
|
+
site = Nanoc::Int::SiteLoader.new.new_with_config(foo: 'bar')
|
22
22
|
assert_equal 'bar', site.config[:foo]
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_initialize_with_incomplete_data_source_config
|
26
|
-
site = Nanoc::Int::
|
27
|
-
assert_equal('
|
26
|
+
site = Nanoc::Int::SiteLoader.new.new_with_config(data_sources: [{ items_root: '/bar/' }])
|
27
|
+
assert_equal('filesystem', site.config[:data_sources][0][:type])
|
28
28
|
assert_equal('/bar/', site.config[:data_sources][0][:items_root])
|
29
29
|
assert_equal('/', site.config[:data_sources][0][:layouts_root])
|
30
30
|
assert_equal({}, site.config[:data_sources][0][:config])
|
@@ -56,7 +56,7 @@ EOF
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
site = Nanoc::Int::
|
59
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
60
60
|
assert_nil site.config[:parent_config_file]
|
61
61
|
assert site.config[:enable_output_diff]
|
62
62
|
assert_equal 'bar', site.config[:foo]
|
@@ -70,13 +70,9 @@ parent_config_file: foo/foo.yaml
|
|
70
70
|
EOF
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
Nanoc::Int::
|
73
|
+
assert_raises(Nanoc::Int::ConfigLoader::NoParentConfigFileFoundError) do
|
74
|
+
Nanoc::Int::SiteLoader.new.new_from_cwd
|
75
75
|
end
|
76
|
-
assert_equal(
|
77
|
-
"Could not find parent configuration file 'foo/foo.yaml'",
|
78
|
-
error.message
|
79
|
-
)
|
80
76
|
end
|
81
77
|
|
82
78
|
def test_initialize_with_parent_config_file_cycle
|
@@ -94,13 +90,9 @@ EOF
|
|
94
90
|
end
|
95
91
|
end
|
96
92
|
|
97
|
-
|
98
|
-
Nanoc::Int::
|
93
|
+
assert_raises(Nanoc::Int::ConfigLoader::CyclicalConfigFileError) do
|
94
|
+
Nanoc::Int::SiteLoader.new.new_from_cwd
|
99
95
|
end
|
100
|
-
assert_equal(
|
101
|
-
"Cycle detected. Could not use parent configuration file '../nanoc.yaml'",
|
102
|
-
error.message
|
103
|
-
)
|
104
96
|
end
|
105
97
|
|
106
98
|
def test_load_rules_with_existing_rules_file
|
@@ -111,7 +103,7 @@ EOF
|
|
111
103
|
dsl.expects(:compile).with('*')
|
112
104
|
|
113
105
|
# Create site
|
114
|
-
site = Nanoc::Int::
|
106
|
+
site = Nanoc::Int::SiteLoader.new.new_empty
|
115
107
|
site.compiler.rules_collection.stubs(:dsl).returns(dsl)
|
116
108
|
|
117
109
|
# Create rules file
|
@@ -127,35 +119,6 @@ EOF
|
|
127
119
|
site.compiler.rules_collection.load
|
128
120
|
end
|
129
121
|
|
130
|
-
def test_load_data_sources_first
|
131
|
-
# Create site
|
132
|
-
Nanoc::CLI.run %w( create_site bar)
|
133
|
-
|
134
|
-
FileUtils.cd('bar') do
|
135
|
-
# Create data source code
|
136
|
-
File.open('lib/some_data_source.rb', 'w') do |io|
|
137
|
-
io.write "class FooDataSource < Nanoc::DataSource\n"
|
138
|
-
io.write " identifier :site_test_foo\n"
|
139
|
-
io.write " def items ; [ Nanoc::Int::Item.new('content', {}, '/foo/') ] ; end\n"
|
140
|
-
io.write "end\n"
|
141
|
-
end
|
142
|
-
|
143
|
-
# Update configuration
|
144
|
-
File.open('nanoc.yaml', 'w') do |io|
|
145
|
-
io.write "data_sources:\n"
|
146
|
-
io.write ' - type: site_test_foo'
|
147
|
-
end
|
148
|
-
|
149
|
-
# Create site
|
150
|
-
site = Nanoc::Int::Site.new('.')
|
151
|
-
site.load
|
152
|
-
|
153
|
-
# Check
|
154
|
-
assert_equal 1, site.data_sources.size
|
155
|
-
refute_nil site.items['/foo/']
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
122
|
def test_identifier_classes
|
160
123
|
Nanoc::CLI.run %w( create_site bar)
|
161
124
|
FileUtils.cd('bar') do
|
@@ -165,7 +128,7 @@ EOF
|
|
165
128
|
File.open('content/foo_bar.md', 'w') { |io| io << 'asdf' }
|
166
129
|
File.open('layouts/detail.erb', 'w') { |io| io << 'asdf' }
|
167
130
|
|
168
|
-
site = Nanoc::Int::
|
131
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
169
132
|
|
170
133
|
site.items.each do |item|
|
171
134
|
assert_equal Nanoc::Identifier, item.identifier.class
|
@@ -191,7 +154,7 @@ EOF
|
|
191
154
|
File.open('content/parent/bar.md', 'w') { |io| io << 'asdf' }
|
192
155
|
File.open('content/parent/bar/qux.md', 'w') { |io| io << 'asdf' }
|
193
156
|
|
194
|
-
site = Nanoc::Int::
|
157
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
195
158
|
|
196
159
|
root = site.items.find { |i| i.identifier == '/' }
|
197
160
|
style = site.items.find { |i| i.identifier == '/stylesheet/' }
|
@@ -222,7 +185,7 @@ EOF
|
|
222
185
|
File.open('content/parent/foo.md', 'w') { |io| io << 'asdf' }
|
223
186
|
File.open('content/parent/bar/qux.md', 'w') { |io| io << 'asdf' }
|
224
187
|
|
225
|
-
site = Nanoc::Int::
|
188
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
226
189
|
|
227
190
|
root = site.items.find { |i| i.identifier == '/index.html' }
|
228
191
|
parent = site.items.find { |i| i.identifier == '/parent.md' }
|
@@ -248,8 +211,7 @@ EOF
|
|
248
211
|
File.open('content/sam/index.html', 'w') { |io| io.write('I am Sam, too!') }
|
249
212
|
|
250
213
|
assert_raises(Nanoc::Int::Errors::DuplicateIdentifier) do
|
251
|
-
|
252
|
-
site.load
|
214
|
+
Nanoc::Int::SiteLoader.new.new_from_cwd
|
253
215
|
end
|
254
216
|
end
|
255
217
|
end
|
@@ -261,81 +223,17 @@ EOF
|
|
261
223
|
File.open('layouts/sam/index.html', 'w') { |io| io.write('I am Sam, too!') }
|
262
224
|
|
263
225
|
assert_raises(Nanoc::Int::Errors::DuplicateIdentifier) do
|
264
|
-
|
265
|
-
site.load
|
226
|
+
Nanoc::Int::SiteLoader.new.new_from_cwd
|
266
227
|
end
|
267
228
|
end
|
268
229
|
end
|
269
230
|
end
|
270
231
|
|
271
|
-
describe 'Nanoc::Int::Site#initialize' do
|
272
|
-
include Nanoc::TestHelpers
|
273
|
-
|
274
|
-
it 'should merge default config' do
|
275
|
-
site = Nanoc::Int::Site.new(foo: 'bar')
|
276
|
-
site.config[:foo].must_equal 'bar'
|
277
|
-
site.config[:output_dir].must_equal 'output'
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'should not raise under normal circumstances' do
|
281
|
-
Nanoc::Int::Site.new({})
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'should not raise for non-existant output directory' do
|
285
|
-
Nanoc::Int::Site.new(output_dir: 'fklsdhailfdjalghlkasdflhagjskajdf')
|
286
|
-
end
|
287
|
-
|
288
|
-
it 'should not raise for unknown data sources' do
|
289
|
-
proc do
|
290
|
-
Nanoc::Int::Site.new(data_source: 'fklsdhailfdjalghlkasdflhagjskajdf')
|
291
|
-
end
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
232
|
describe 'Nanoc::Int::Site#compiler' do
|
296
233
|
include Nanoc::TestHelpers
|
297
234
|
|
298
235
|
it 'should not raise under normal circumstances' do
|
299
|
-
site = Nanoc::Int::
|
236
|
+
site = Nanoc::Int::SiteLoader.new.new_empty
|
300
237
|
site.compiler
|
301
238
|
end
|
302
239
|
end
|
303
|
-
|
304
|
-
describe 'Nanoc::Int::Site#data_sources' do
|
305
|
-
include Nanoc::TestHelpers
|
306
|
-
|
307
|
-
it 'should not raise for known data sources' do
|
308
|
-
site = Nanoc::Int::Site.new({})
|
309
|
-
site.data_sources
|
310
|
-
end
|
311
|
-
|
312
|
-
it 'should raise for unknown data sources' do
|
313
|
-
proc do
|
314
|
-
site = Nanoc::Int::Site.new(
|
315
|
-
data_sources: [
|
316
|
-
{ type: 'fklsdhailfdjalghlkasdflhagjskajdf' }
|
317
|
-
]
|
318
|
-
)
|
319
|
-
site.data_sources
|
320
|
-
end.must_raise Nanoc::Int::Errors::UnknownDataSource
|
321
|
-
end
|
322
|
-
|
323
|
-
it 'should also use the toplevel config for data sources' do
|
324
|
-
with_site do
|
325
|
-
File.open('nanoc.yaml', 'w') do |io|
|
326
|
-
io.write "data_sources:\n"
|
327
|
-
io.write " -\n"
|
328
|
-
io.write " type: filesystem\n"
|
329
|
-
io.write " aaa: one\n"
|
330
|
-
io.write " config:\n"
|
331
|
-
io.write " bbb: two\n"
|
332
|
-
end
|
333
|
-
|
334
|
-
site = Nanoc::Int::Site.new('.')
|
335
|
-
data_sources = site.data_sources
|
336
|
-
|
337
|
-
assert data_sources.first.config[:aaa] = 'one'
|
338
|
-
assert data_sources.first.config[:bbb] = 'two'
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|