nanoc 4.0.2 → 4.1.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +17 -0
- data/Gemfile +50 -46
- data/Gemfile.lock +365 -0
- data/Guardfile +3 -0
- data/NEWS.md +21 -0
- data/README.md +1 -1
- data/lib/nanoc/base.rb +3 -15
- data/lib/nanoc/base/checksummer.rb +3 -14
- data/lib/nanoc/base/compilation/compiler.rb +112 -283
- data/lib/nanoc/base/compilation/compiler_dsl.rb +29 -37
- data/lib/nanoc/base/compilation/dependency_tracker.rb +25 -170
- data/lib/nanoc/base/compilation/filter.rb +3 -4
- data/lib/nanoc/base/compilation/item_rep_repo.rb +33 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +39 -53
- data/lib/nanoc/base/compilation/rule.rb +13 -24
- data/lib/nanoc/base/compilation/rule_context.rb +29 -15
- data/lib/nanoc/base/entities.rb +10 -0
- data/lib/nanoc/base/{source_data → entities}/code_snippet.rb +1 -4
- data/lib/nanoc/base/{source_data → entities}/configuration.rb +1 -1
- data/lib/nanoc/base/entities/content.rb +8 -9
- data/lib/nanoc/base/{identifiable_collection.rb → entities/identifiable_collection.rb} +0 -0
- data/lib/nanoc/base/entities/identifier.rb +11 -2
- data/lib/nanoc/base/{source_data → entities}/item.rb +0 -18
- data/lib/nanoc/base/{result_data → entities}/item_rep.rb +15 -13
- data/lib/nanoc/base/entities/rule_memory.rb +54 -0
- data/lib/nanoc/base/entities/rule_memory_action.rb +19 -0
- data/lib/nanoc/base/entities/rule_memory_actions.rb +3 -0
- data/lib/nanoc/base/entities/rule_memory_actions/filter.rb +22 -0
- data/lib/nanoc/base/entities/rule_memory_actions/layout.rb +22 -0
- data/lib/nanoc/base/entities/rule_memory_actions/snapshot.rb +26 -0
- data/lib/nanoc/base/entities/rules_collection.rb +120 -0
- data/lib/nanoc/base/{source_data → entities}/site.rb +11 -10
- data/lib/nanoc/base/repos.rb +2 -0
- data/lib/nanoc/base/repos/checksum_store.rb +3 -9
- data/lib/nanoc/base/repos/compiled_content_cache.rb +0 -5
- data/lib/nanoc/base/{source_data → repos}/data_source.rb +3 -6
- data/lib/nanoc/base/repos/dependency_store.rb +118 -0
- data/lib/nanoc/base/repos/rule_memory_store.rb +1 -5
- data/lib/nanoc/base/repos/site_loader.rb +0 -28
- data/lib/nanoc/base/repos/store.rb +0 -12
- data/lib/nanoc/base/services.rb +8 -0
- data/lib/nanoc/base/services/compiler_loader.rb +49 -0
- data/lib/nanoc/base/services/executor.rb +4 -4
- data/lib/nanoc/base/services/item_rep_builder.rb +30 -0
- data/lib/nanoc/base/services/item_rep_router.rb +55 -0
- data/lib/nanoc/base/services/item_rep_selector.rb +39 -0
- data/lib/nanoc/base/services/item_rep_writer.rb +2 -0
- data/lib/nanoc/base/services/postprocessor.rb +26 -0
- data/lib/nanoc/base/services/preprocessor.rb +26 -0
- data/lib/nanoc/base/services/recording_executor.rb +36 -22
- data/lib/nanoc/base/services/rule_memory_calculator.rb +84 -0
- data/lib/nanoc/base/services/rules_loader.rb +29 -0
- data/lib/nanoc/base/views.rb +6 -0
- data/lib/nanoc/base/views/config_view.rb +8 -2
- data/lib/nanoc/base/views/identifiable_collection_view.rb +5 -4
- data/lib/nanoc/base/views/item_rep_collection_view.rb +7 -6
- data/lib/nanoc/base/views/item_rep_view.rb +13 -12
- data/lib/nanoc/base/views/item_view.rb +18 -12
- data/lib/nanoc/base/views/layout_view.rb +1 -1
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +2 -1
- data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +1 -1
- data/lib/nanoc/base/views/mutable_item_collection_view.rb +4 -7
- data/lib/nanoc/base/views/post_compile_item_collection_view.rb +8 -0
- data/lib/nanoc/base/views/post_compile_item_view.rb +7 -0
- data/lib/nanoc/base/views/site_view.rb +3 -2
- data/lib/nanoc/base/views/view.rb +12 -0
- data/lib/nanoc/base/views/view_context.rb +12 -0
- data/lib/nanoc/cli/commands/compile.rb +13 -15
- data/lib/nanoc/cli/commands/create-site.rb +15 -0
- data/lib/nanoc/cli/commands/prune.rb +1 -1
- data/lib/nanoc/cli/commands/shell.rb +3 -3
- data/lib/nanoc/cli/commands/show-data.rb +5 -5
- data/lib/nanoc/cli/commands/show-rules.rb +2 -1
- data/lib/nanoc/cli/error_handler.rb +28 -30
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +1 -1
- data/lib/nanoc/extra/checking/check.rb +8 -7
- data/lib/nanoc/extra/checking/checks/external_links.rb +14 -1
- data/lib/nanoc/extra/checking/runner.rb +1 -1
- data/lib/nanoc/extra/deployer.rb +3 -3
- data/lib/nanoc/extra/piper.rb +5 -5
- data/lib/nanoc/extra/pruner.rb +8 -7
- data/lib/nanoc/filters/relativize_paths.rb +48 -32
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -1
- data/lib/nanoc/helpers/blogging.rb +15 -7
- data/lib/nanoc/helpers/capturing.rb +56 -13
- data/lib/nanoc/helpers/link_to.rb +2 -2
- data/lib/nanoc/helpers/tagging.rb +5 -10
- data/lib/nanoc/helpers/text.rb +9 -11
- data/lib/nanoc/version.rb +1 -1
- data/nanoc-4.0.2.gem +0 -0
- data/tags +1175 -0
- data/test/base/test_compiler.rb +48 -98
- data/test/base/test_compiler_dsl.rb +113 -39
- data/test/base/test_dependency_tracker.rb +80 -79
- data/test/base/test_outdatedness_checker.rb +39 -26
- data/test/base/test_site.rb +0 -97
- data/test/cli/commands/test_compile.rb +2 -3
- data/test/extra/checking/checks/test_external_links.rb +25 -0
- data/test/extra/deployers/test_fog.rb +12 -6
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_erubis.rb +1 -1
- data/test/filters/test_haml.rb +1 -1
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_sass.rb +1 -0
- data/test/filters/test_xsl.rb +7 -8
- data/test/helper.rb +0 -2
- data/test/helpers/test_blogging.rb +26 -23
- data/test/helpers/test_capturing.rb +131 -12
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_link_to.rb +1 -1
- data/test/helpers/test_rendering.rb +16 -24
- data/test/helpers/test_tagging.rb +13 -10
- data/test/helpers/test_xml_sitemap.rb +25 -21
- metadata +36 -14
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -35
- data/lib/nanoc/base/compilation/rules_collection.rb +0 -245
- data/test/base/test_rule_context.rb +0 -78
data/test/helper.rb
CHANGED
@@ -33,14 +33,12 @@ module Nanoc::TestHelpers
|
|
33
33
|
libs.each do |lib|
|
34
34
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && lib == 'nokogiri' && disable_nokogiri?
|
35
35
|
skip 'Pure Java Nokogiri has issues that cause problems with nanoc (see https://github.com/nanoc/nanoc/pull/422) -- run without DISABLE_NOKOGIRI to enable Nokogiri tests'
|
36
|
-
return
|
37
36
|
end
|
38
37
|
|
39
38
|
begin
|
40
39
|
require lib
|
41
40
|
rescue LoadError
|
42
41
|
skip "requiring #{lib} failed"
|
43
|
-
return
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -47,7 +47,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
47
47
|
@items[2].expects(:compiled_content).with(snapshot: :pre).returns('item 2 content')
|
48
48
|
|
49
49
|
# Mock site
|
50
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
50
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
51
51
|
|
52
52
|
# Create feed item
|
53
53
|
@item = mock
|
@@ -78,7 +78,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
78
78
|
@items[2].expects(:compiled_content).returns('item 2 content')
|
79
79
|
|
80
80
|
# Mock site
|
81
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
81
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
82
82
|
|
83
83
|
# Create feed item
|
84
84
|
@item = mock
|
@@ -99,7 +99,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
99
99
|
@items = [mock_item, mock_item]
|
100
100
|
|
101
101
|
# Mock site
|
102
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
102
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
103
103
|
|
104
104
|
# Create feed item
|
105
105
|
@item = mock
|
@@ -124,7 +124,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
124
124
|
@items = [mock_item, mock_article]
|
125
125
|
|
126
126
|
# Mock site
|
127
|
-
@config = Nanoc::ConfigView.new({ base_url: nil })
|
127
|
+
@config = Nanoc::ConfigView.new({ base_url: nil }, nil)
|
128
128
|
|
129
129
|
# Create feed item
|
130
130
|
@item = mock
|
@@ -149,7 +149,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
149
149
|
@items = [mock_item, mock_article]
|
150
150
|
|
151
151
|
# Mock site
|
152
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
152
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
153
153
|
|
154
154
|
# Create feed item
|
155
155
|
@item = mock
|
@@ -174,7 +174,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
174
174
|
@items = [mock_item, mock_article]
|
175
175
|
|
176
176
|
# Mock site
|
177
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
177
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
178
178
|
|
179
179
|
# Create feed item
|
180
180
|
@item = mock
|
@@ -204,7 +204,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
204
204
|
@items[0].expects(:compiled_content).returns('item 1 content')
|
205
205
|
|
206
206
|
# Mock site
|
207
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com/' })
|
207
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com/' }, nil)
|
208
208
|
|
209
209
|
# Create feed item
|
210
210
|
@item = mock
|
@@ -246,7 +246,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
246
246
|
@items = [mock_item, mock_article]
|
247
247
|
|
248
248
|
# Mock site
|
249
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
249
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
250
250
|
|
251
251
|
# Create feed item
|
252
252
|
@item = mock
|
@@ -273,7 +273,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
273
273
|
@items[2].stubs(:[]).with(:created_at).returns(nil)
|
274
274
|
|
275
275
|
# Mock site
|
276
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
276
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
277
277
|
|
278
278
|
# Create feed item
|
279
279
|
@item = mock
|
@@ -299,7 +299,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
299
299
|
@items[1].expects(:compiled_content).with(snapshot: :pre).returns('asdf')
|
300
300
|
|
301
301
|
# Mock site
|
302
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
302
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
303
303
|
|
304
304
|
# Create feed item
|
305
305
|
@item = mock
|
@@ -325,10 +325,13 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
325
325
|
|
326
326
|
# Mock site
|
327
327
|
@config = Nanoc::ConfigView.new(
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
328
|
+
{
|
329
|
+
author_name: 'Bob',
|
330
|
+
author_uri: 'http://example.com/~bob/',
|
331
|
+
title: 'My Blog Or Something',
|
332
|
+
base_url: 'http://example.com',
|
333
|
+
},
|
334
|
+
nil,
|
332
335
|
)
|
333
336
|
|
334
337
|
# Create feed item
|
@@ -353,7 +356,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
353
356
|
@items[1].expects(:compiled_content).with(snapshot: :pre).returns('asdf')
|
354
357
|
|
355
358
|
# Mock site
|
356
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
359
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
357
360
|
|
358
361
|
# Create feed item
|
359
362
|
@item = mock
|
@@ -377,7 +380,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
377
380
|
end
|
378
381
|
|
379
382
|
# Mock site
|
380
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
383
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
381
384
|
|
382
385
|
# Create feed item
|
383
386
|
@item = mock
|
@@ -410,7 +413,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
410
413
|
@items[1].stubs(:[]).with(:created_at).returns('22-03-2009')
|
411
414
|
|
412
415
|
# Mock site
|
413
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
416
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
414
417
|
|
415
418
|
# Create feed item
|
416
419
|
@item = mock
|
@@ -439,7 +442,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
439
442
|
@items[1].stubs(:[]).with(:created_at).returns('01-01-2014')
|
440
443
|
|
441
444
|
# Mock site
|
442
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
445
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
443
446
|
|
444
447
|
# Create feed item
|
445
448
|
@item = mock
|
@@ -463,7 +466,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
463
466
|
@items = [mock_article]
|
464
467
|
|
465
468
|
# Mock site
|
466
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
469
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
467
470
|
|
468
471
|
# Create feed item
|
469
472
|
@item = mock
|
@@ -484,7 +487,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
484
487
|
@items = [mock_article]
|
485
488
|
|
486
489
|
# Mock site
|
487
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
490
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
488
491
|
|
489
492
|
# Create feed item
|
490
493
|
@item = mock
|
@@ -505,7 +508,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
505
508
|
@items = [mock_article]
|
506
509
|
|
507
510
|
# Mock site
|
508
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
511
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
509
512
|
|
510
513
|
# Create feed item
|
511
514
|
@item = mock
|
@@ -526,7 +529,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
526
529
|
@items = [mock_article]
|
527
530
|
|
528
531
|
# Mock site
|
529
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
532
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
530
533
|
|
531
534
|
# Create feed item
|
532
535
|
@item = mock
|
@@ -548,7 +551,7 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
|
|
548
551
|
@items[0].stubs(:path).returns(nil)
|
549
552
|
|
550
553
|
# Mock site
|
551
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
554
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
552
555
|
|
553
556
|
# Create feed item
|
554
557
|
@item = mock
|
@@ -17,8 +17,8 @@ class Nanoc::Helpers::CapturingTest < Nanoc::TestCase
|
|
17
17
|
# Build site
|
18
18
|
site = Nanoc::Int::SiteLoader.new.new_empty
|
19
19
|
item = Nanoc::Int::Item.new('moo', {}, '/blah/')
|
20
|
-
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty)
|
21
|
-
@item = Nanoc::ItemView.new(item)
|
20
|
+
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty, nil)
|
21
|
+
@item = Nanoc::ItemView.new(item, nil)
|
22
22
|
|
23
23
|
# Evaluate content
|
24
24
|
result = ::ERB.new(content).result(binding)
|
@@ -32,8 +32,8 @@ class Nanoc::Helpers::CapturingTest < Nanoc::TestCase
|
|
32
32
|
require 'erb'
|
33
33
|
|
34
34
|
# Build site
|
35
|
-
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty)
|
36
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('moo', {}, '/blah/'))
|
35
|
+
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty, nil)
|
36
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('moo', {}, '/blah/'), nil)
|
37
37
|
|
38
38
|
# Capture
|
39
39
|
_erbout = 'foo'
|
@@ -59,15 +59,15 @@ head
|
|
59
59
|
<% content_for :box do %>
|
60
60
|
basic
|
61
61
|
<% end %>
|
62
|
-
<% content_for :
|
62
|
+
<% content_for :outerbox do %>
|
63
63
|
before <%= content_for @item, :box %> after
|
64
64
|
<% end %>
|
65
|
-
<%= content_for @item, :
|
65
|
+
<%= content_for @item, :outerbox %>
|
66
66
|
foot
|
67
67
|
EOS
|
68
68
|
|
69
|
-
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty)
|
70
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'))
|
69
|
+
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty, nil)
|
70
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'), nil)
|
71
71
|
|
72
72
|
result = ::ERB.new(content).result(binding)
|
73
73
|
|
@@ -84,16 +84,16 @@ EOS
|
|
84
84
|
io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
|
85
85
|
end
|
86
86
|
|
87
|
-
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty)
|
88
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'))
|
87
|
+
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty, nil)
|
88
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'), nil)
|
89
89
|
content = '<% content_for :a do %>Content One<% end %>'
|
90
90
|
::ERB.new(content).result(binding)
|
91
91
|
|
92
92
|
assert_equal 'Content One', content_for(@item, :a)
|
93
93
|
assert_equal nil, content_for(@item, :b)
|
94
94
|
|
95
|
-
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty)
|
96
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'))
|
95
|
+
@site = Nanoc::SiteView.new(Nanoc::Int::SiteLoader.new.new_empty, nil)
|
96
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/'), nil)
|
97
97
|
content = '<% content_for :b do %>Content Two<% end %>'
|
98
98
|
::ERB.new(content).result(binding)
|
99
99
|
|
@@ -101,6 +101,125 @@ EOS
|
|
101
101
|
assert_equal 'Content Two', content_for(@item, :b)
|
102
102
|
end
|
103
103
|
|
104
|
+
def test_content_for_with_existing_symbol
|
105
|
+
with_site do |_site|
|
106
|
+
# Prepare
|
107
|
+
File.open('lib/helpers.rb', 'w') do |io|
|
108
|
+
io.write 'include Nanoc::Helpers::Capturing'
|
109
|
+
end
|
110
|
+
File.open('content/includer.erb', 'w') do |io|
|
111
|
+
io.write '[<%= content_for(@items["/includee/"], :blah) %>]'
|
112
|
+
end
|
113
|
+
File.open('Rules', 'w') do |io|
|
114
|
+
io.write "compile '*' do ; filter :erb ; end\n"
|
115
|
+
io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
|
116
|
+
end
|
117
|
+
|
118
|
+
File.open('content/includee.erb', 'w') do |io|
|
119
|
+
io.write '{<% content_for :blah do %>First content<% end %><% content_for :blah do %>Second content<% end %>}'
|
120
|
+
end
|
121
|
+
|
122
|
+
# Using the same symbols twice now raises an error, to be changed to concatenating in a future version
|
123
|
+
assert_raises do
|
124
|
+
Nanoc::CLI.run(%w(compile))
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_content_for_with_existing_symbol_with_error_option
|
130
|
+
with_site do |_site|
|
131
|
+
# Prepare
|
132
|
+
File.open('lib/helpers.rb', 'w') do |io|
|
133
|
+
io.write 'include Nanoc::Helpers::Capturing'
|
134
|
+
end
|
135
|
+
File.open('content/includer.erb', 'w') do |io|
|
136
|
+
io.write '[<%= content_for(@items["/includee/"], :blah) %>]'
|
137
|
+
end
|
138
|
+
File.open('Rules', 'w') do |io|
|
139
|
+
io.write "compile '*' do ; filter :erb ; end\n"
|
140
|
+
io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
|
141
|
+
end
|
142
|
+
|
143
|
+
File.open('content/includee.erb', 'w') do |io|
|
144
|
+
io.write '{<% content_for :blah do %>First content<% end %><% content_for :blah, existing: :error do %>Second content<% end %>}'
|
145
|
+
end
|
146
|
+
|
147
|
+
assert_raises do
|
148
|
+
Nanoc::CLI.run(%w(compile))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_content_for_with_existing_symbol_with_overwrite_option
|
154
|
+
with_site do |_site|
|
155
|
+
# Prepare
|
156
|
+
File.open('lib/helpers.rb', 'w') do |io|
|
157
|
+
io.write 'include Nanoc::Helpers::Capturing'
|
158
|
+
end
|
159
|
+
File.open('content/includer.erb', 'w') do |io|
|
160
|
+
io.write '[<%= content_for(@items["/includee/"], :blah) %>]'
|
161
|
+
end
|
162
|
+
File.open('Rules', 'w') do |io|
|
163
|
+
io.write "compile '*' do ; filter :erb ; end\n"
|
164
|
+
io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
|
165
|
+
end
|
166
|
+
|
167
|
+
File.open('content/includee.erb', 'w') do |io|
|
168
|
+
io.write '{<% content_for :blah do %>First content<% end %><% content_for :blah, existing: :overwrite do %>Second content<% end %>}'
|
169
|
+
end
|
170
|
+
|
171
|
+
Nanoc::CLI.run(%w(compile))
|
172
|
+
assert_equal '[Second content]', File.read('output/includer/index.html')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_content_for_with_existing_symbol_with_append_option
|
177
|
+
with_site do |_site|
|
178
|
+
# Prepare
|
179
|
+
File.open('lib/helpers.rb', 'w') do |io|
|
180
|
+
io.write 'include Nanoc::Helpers::Capturing'
|
181
|
+
end
|
182
|
+
File.open('content/includer.erb', 'w') do |io|
|
183
|
+
io.write '[<%= content_for(@items["/includee/"], :blah) %>]'
|
184
|
+
end
|
185
|
+
File.open('Rules', 'w') do |io|
|
186
|
+
io.write "compile '*' do ; filter :erb ; end\n"
|
187
|
+
io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
|
188
|
+
end
|
189
|
+
|
190
|
+
File.open('content/includee.erb', 'w') do |io|
|
191
|
+
io.write '{<% content_for :blah do %>First content<% end %><% content_for :blah, existing: :append do %>Second content<% end %>}'
|
192
|
+
end
|
193
|
+
|
194
|
+
Nanoc::CLI.run(%w(compile))
|
195
|
+
assert_equal '[First contentSecond content]', File.read('output/includer/index.html')
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_content_for_with_existing_symbol_with_unrecognised_option
|
200
|
+
with_site do |_site|
|
201
|
+
# Prepare
|
202
|
+
File.open('lib/helpers.rb', 'w') do |io|
|
203
|
+
io.write 'include Nanoc::Helpers::Capturing'
|
204
|
+
end
|
205
|
+
File.open('content/includer.erb', 'w') do |io|
|
206
|
+
io.write '[<%= content_for(@items["/includee/"], :blah) %>]'
|
207
|
+
end
|
208
|
+
File.open('Rules', 'w') do |io|
|
209
|
+
io.write "compile '*' do ; filter :erb ; end\n"
|
210
|
+
io.write "route '*' do ; item.identifier + 'index.html' ; end\n"
|
211
|
+
end
|
212
|
+
|
213
|
+
File.open('content/includee.erb', 'w') do |io|
|
214
|
+
io.write '{<% content_for :blah, existing: :donkey do %>First content<% end %>}'
|
215
|
+
end
|
216
|
+
|
217
|
+
assert_raises(ArgumentError) do
|
218
|
+
Nanoc::CLI.run(%w(compile))
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
104
223
|
def test_dependencies
|
105
224
|
with_site do |_site|
|
106
225
|
# Prepare
|
@@ -11,7 +11,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
|
|
11
11
|
|
12
12
|
# Mock item and rep
|
13
13
|
@item_rep = mock
|
14
|
-
@item_rep = Nanoc::ItemRepView.new(@item_rep)
|
14
|
+
@item_rep = Nanoc::ItemRepView.new(@item_rep, nil)
|
15
15
|
|
16
16
|
# Evaluate content
|
17
17
|
result = ::ERB.new(content).result(binding)
|
@@ -32,8 +32,8 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
|
|
32
32
|
item = Nanoc::Int::Item.new('stuff', { title: 'Bar...' }, '/foo.md')
|
33
33
|
item_rep = Nanoc::Int::ItemRep.new(item, :default)
|
34
34
|
|
35
|
-
@item = Nanoc::ItemView.new(item)
|
36
|
-
@item_rep = Nanoc::ItemRepView.new(item_rep)
|
35
|
+
@item = Nanoc::ItemView.new(item, nil)
|
36
|
+
@item_rep = Nanoc::ItemRepView.new(item_rep, nil)
|
37
37
|
|
38
38
|
result = ::ERB.new(content).result(binding)
|
39
39
|
|
@@ -64,7 +64,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
|
|
64
64
|
|
65
65
|
# Mock item and rep
|
66
66
|
@item_rep = mock
|
67
|
-
@item_rep = Nanoc::ItemRepView.new(@item_rep)
|
67
|
+
@item_rep = Nanoc::ItemRepView.new(@item_rep, nil)
|
68
68
|
|
69
69
|
# Evaluate content
|
70
70
|
result = ::ERB.new(content).result(binding)
|
@@ -82,7 +82,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
|
|
82
82
|
|
83
83
|
# Mock item and rep
|
84
84
|
@item_rep = mock
|
85
|
-
@item_rep = Nanoc::ItemRepView.new(@item_rep)
|
85
|
+
@item_rep = Nanoc::ItemRepView.new(@item_rep, nil)
|
86
86
|
|
87
87
|
# Evaluate content
|
88
88
|
result = ::Haml::Engine.new(content).render(binding)
|
@@ -102,7 +102,7 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
|
|
102
102
|
|
103
103
|
# Mock item and rep
|
104
104
|
@item_rep = mock
|
105
|
-
@item_rep = Nanoc::ItemRepView.new(@item_rep)
|
105
|
+
@item_rep = Nanoc::ItemRepView.new(@item_rep, nil)
|
106
106
|
|
107
107
|
::ERB.new(content).result(binding)
|
108
108
|
|
@@ -12,9 +12,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
15
|
-
site.
|
16
|
-
@
|
17
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
15
|
+
@site = Nanoc::SiteView.new(site, nil)
|
16
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
18
17
|
|
19
18
|
assert_equal('This is the /foo/ layout.', render('/foo/'))
|
20
19
|
end
|
@@ -31,9 +30,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
31
30
|
end
|
32
31
|
|
33
32
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
34
|
-
site.
|
35
|
-
@
|
36
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
33
|
+
@site = Nanoc::SiteView.new(site, nil)
|
34
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
37
35
|
|
38
36
|
assert_equal('This is the /foo/ layout.', render('/foo'))
|
39
37
|
end
|
@@ -50,9 +48,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
50
48
|
end
|
51
49
|
|
52
50
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
53
|
-
site.
|
54
|
-
@
|
55
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
51
|
+
@site = Nanoc::SiteView.new(site, nil)
|
52
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
56
53
|
|
57
54
|
assert_equal('I am the Nanoc::LayoutView class.', render('/foo/'))
|
58
55
|
end
|
@@ -69,9 +66,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
69
66
|
end
|
70
67
|
|
71
68
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
72
|
-
site.
|
73
|
-
@
|
74
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
69
|
+
@site = Nanoc::SiteView.new(site, nil)
|
70
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
75
71
|
|
76
72
|
assert_equal('I am the Nanoc::Int::Layout class.', render('/foo/'))
|
77
73
|
end
|
@@ -80,9 +76,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
80
76
|
def test_render_with_unknown_layout
|
81
77
|
with_site do |site|
|
82
78
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
83
|
-
site.
|
84
|
-
@
|
85
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
79
|
+
@site = Nanoc::SiteView.new(site, nil)
|
80
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
86
81
|
|
87
82
|
assert_raises(Nanoc::Int::Errors::UnknownLayout) do
|
88
83
|
render '/dsfghjkl/'
|
@@ -99,9 +94,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
99
94
|
File.open('layouts/foo.erb', 'w').close
|
100
95
|
|
101
96
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
102
|
-
site.
|
103
|
-
@
|
104
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
97
|
+
@site = Nanoc::SiteView.new(site, nil)
|
98
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
105
99
|
|
106
100
|
assert_raises(Nanoc::Int::Errors::CannotDetermineFilter) do
|
107
101
|
render '/foo/'
|
@@ -118,9 +112,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
118
112
|
File.open('layouts/foo.erb', 'w').close
|
119
113
|
|
120
114
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
121
|
-
site.
|
122
|
-
@
|
123
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
115
|
+
@site = Nanoc::SiteView.new(site, nil)
|
116
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
124
117
|
|
125
118
|
assert_raises(Nanoc::Int::Errors::UnknownFilter) do
|
126
119
|
render '/foo/'
|
@@ -139,9 +132,8 @@ class Nanoc::Helpers::RenderingTest < Nanoc::TestCase
|
|
139
132
|
end
|
140
133
|
|
141
134
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
142
|
-
site.
|
143
|
-
@
|
144
|
-
@layouts = Nanoc::LayoutCollectionView.new(site.layouts)
|
135
|
+
@site = Nanoc::SiteView.new(site, nil)
|
136
|
+
@layouts = Nanoc::LayoutCollectionView.new(site.layouts, nil)
|
145
137
|
|
146
138
|
_erbout = '[erbout-before]'
|
147
139
|
result = render '/foo/' do
|