nanoc 4.0.0b3 → 4.0.0b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -2
- data/NEWS.md +10 -0
- data/TODO.md +15 -0
- data/lib/nanoc/base.rb +4 -27
- data/lib/nanoc/base/checksummer.rb +69 -19
- data/lib/nanoc/base/compilation/compiler.rb +14 -12
- data/lib/nanoc/base/compilation/compiler_dsl.rb +2 -0
- data/lib/nanoc/base/compilation/filter.rb +4 -2
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +7 -7
- data/lib/nanoc/base/compilation/rule.rb +5 -6
- data/lib/nanoc/base/compilation/rule_context.rb +16 -34
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
- data/lib/nanoc/base/compilation/rules_collection.rb +4 -10
- data/lib/nanoc/base/context.rb +2 -0
- data/lib/nanoc/base/core_ext/array.rb +0 -10
- data/lib/nanoc/base/core_ext/hash.rb +0 -10
- data/lib/nanoc/base/core_ext/pathname.rb +0 -9
- data/lib/nanoc/base/core_ext/string.rb +0 -10
- data/lib/nanoc/base/entities.rb +5 -0
- data/lib/nanoc/base/entities/content.rb +86 -0
- data/lib/nanoc/base/entities/document.rb +56 -0
- data/lib/nanoc/base/{source_data → entities}/identifier.rb +12 -1
- data/lib/nanoc/base/entities/layout.rb +8 -0
- data/lib/nanoc/base/{pattern.rb → entities/pattern.rb} +0 -0
- data/lib/nanoc/base/errors.rb +2 -1
- data/lib/nanoc/base/result_data/item_rep.rb +13 -278
- data/lib/nanoc/base/services.rb +5 -0
- data/lib/nanoc/base/services/executor.rb +141 -0
- data/lib/nanoc/base/services/item_rep_writer.rb +40 -0
- data/lib/nanoc/base/{notification_center.rb → services/notification_center.rb} +0 -0
- data/lib/nanoc/base/services/recording_executor.rb +41 -0
- data/lib/nanoc/base/{temp_filename_factory.rb → services/temp_filename_factory.rb} +0 -0
- data/lib/nanoc/base/source_data/code_snippet.rb +0 -6
- data/lib/nanoc/base/source_data/data_source.rb +4 -3
- data/lib/nanoc/base/source_data/item.rb +23 -213
- data/lib/nanoc/base/source_data/site.rb +0 -1
- data/lib/nanoc/base/views.rb +18 -0
- data/lib/nanoc/base/views/config.rb +1 -1
- data/lib/nanoc/base/views/item.rb +8 -73
- data/lib/nanoc/base/views/item_rep.rb +9 -0
- data/lib/nanoc/base/views/item_rep_collection.rb +17 -0
- data/lib/nanoc/base/views/layout.rb +1 -40
- data/lib/nanoc/base/views/mixins/document.rb +76 -0
- data/lib/nanoc/base/views/mixins/mutable_document.rb +22 -0
- data/lib/nanoc/base/views/mutable_identifiable_collection.rb +1 -1
- data/lib/nanoc/base/views/mutable_item.rb +1 -18
- data/lib/nanoc/base/views/mutable_item_collection.rb +6 -2
- data/lib/nanoc/base/views/mutable_layout.rb +1 -8
- data/lib/nanoc/cli/commands/compile.rb +1 -2
- data/lib/nanoc/cli/commands/create-site.rb +5 -5
- data/lib/nanoc/cli/commands/show-data.rb +11 -1
- data/lib/nanoc/data_sources/filesystem.rb +17 -10
- data/lib/nanoc/helpers/capturing.rb +1 -2
- data/lib/nanoc/helpers/filtering.rb +13 -1
- data/lib/nanoc/helpers/rendering.rb +4 -2
- data/lib/nanoc/version.rb +1 -1
- data/test/base/core_ext/array_spec.rb +0 -7
- data/test/base/core_ext/hash_spec.rb +0 -13
- data/test/base/core_ext/pathname_spec.rb +0 -33
- data/test/base/core_ext/string_spec.rb +0 -10
- data/test/base/test_compiler_dsl.rb +3 -3
- data/test/base/test_data_source.rb +2 -2
- data/test/base/test_item.rb +5 -129
- data/test/base/test_item_rep.rb +26 -558
- data/test/base/test_layout.rb +2 -26
- data/test/base/test_rule.rb +3 -3
- data/test/base/test_rule_context.rb +34 -15
- data/test/data_sources/test_filesystem.rb +2 -2
- data/test/data_sources/test_filesystem_unified.rb +39 -33
- data/test/extra/checking/checks/test_html.rb +0 -1
- data/test/extra/checking/checks/test_mixed_content.rb +3 -3
- data/test/extra/deployers/test_fog.rb +24 -24
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_sass.rb +10 -5
- data/test/filters/test_xsl.rb +6 -0
- data/test/helpers/test_capturing.rb +0 -1
- data/test/helpers/test_filtering.rb +5 -19
- data/test/helpers/test_tagging.rb +6 -6
- metadata +18 -11
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -109
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -97
- data/lib/nanoc/base/source_data/layout.rb +0 -111
- data/test/base/checksummer_spec.rb +0 -256
- data/test/base/test_item_rep_recorder_proxy.rb +0 -17
data/test/base/test_layout.rb
CHANGED
@@ -5,32 +5,8 @@ class Nanoc::Int::LayoutTest < Nanoc::TestCase
|
|
5
5
|
assert_equal({ foo: 'bar' }, layout.attributes)
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
# Create layout
|
8
|
+
def test_attributes
|
10
9
|
layout = Nanoc::Int::Layout.new('content', { 'foo' => 'bar' }, '/foo/')
|
11
|
-
|
12
|
-
# Check attributes
|
13
|
-
assert_equal('bar', layout[:foo])
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_lookup_with_unknown_attribute
|
17
|
-
# Create layout
|
18
|
-
layout = Nanoc::Int::Layout.new('content', { 'foo' => 'bar' }, '/foo/')
|
19
|
-
|
20
|
-
# Check attributes
|
21
|
-
assert_equal(nil, layout[:filter])
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_dump_and_load
|
25
|
-
layout = Nanoc::Int::Layout.new(
|
26
|
-
'foobar',
|
27
|
-
{ a: { b: 123 } },
|
28
|
-
'/foo/')
|
29
|
-
|
30
|
-
layout = Marshal.load(Marshal.dump(layout))
|
31
|
-
|
32
|
-
assert_equal Nanoc::Identifier.new('/foo/'), layout.identifier
|
33
|
-
assert_equal 'foobar', layout.raw_content
|
34
|
-
assert_equal({ a: { b: 123 } }, layout.attributes)
|
10
|
+
assert_equal({ foo: 'bar' }, layout.attributes)
|
35
11
|
end
|
36
12
|
end
|
data/test/base/test_rule.rb
CHANGED
@@ -12,11 +12,11 @@ class Nanoc::Int::RuleTest < Nanoc::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_matches
|
15
|
-
pattern = Nanoc::Int::Pattern.from(%r
|
15
|
+
pattern = Nanoc::Int::Pattern.from(%r{/(.*)/(.*)/})
|
16
16
|
identifier = '/anything/else/'
|
17
|
-
expected =
|
17
|
+
expected = %w(anything else)
|
18
18
|
|
19
|
-
rule = Nanoc::Int::Rule.new(pattern, :string,
|
19
|
+
rule = Nanoc::Int::Rule.new(pattern, :string, proc {})
|
20
20
|
|
21
21
|
assert_equal expected, rule.send(:matches, identifier)
|
22
22
|
end
|
@@ -15,15 +15,24 @@ class Nanoc::Int::RuleContextTest < Nanoc::TestCase
|
|
15
15
|
compiler = Nanoc::Int::Compiler.new(site)
|
16
16
|
|
17
17
|
# Create context
|
18
|
-
|
18
|
+
executor = nil
|
19
|
+
rule_context = Nanoc::Int::RuleContext.new(rep: rep, executor: executor, compiler: compiler)
|
19
20
|
|
20
|
-
# Check
|
21
|
-
assert_equal
|
22
|
-
assert_equal
|
23
|
-
assert_equal
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
21
|
+
# Check classes
|
22
|
+
assert_equal Nanoc::ItemRepView, rule_context.rep.class
|
23
|
+
assert_equal Nanoc::ItemView, rule_context.item.class
|
24
|
+
assert_equal Nanoc::SiteView, rule_context.site.class
|
25
|
+
assert_equal Nanoc::ConfigView, rule_context.config.class
|
26
|
+
assert_equal Nanoc::LayoutCollectionView, rule_context.layouts.class
|
27
|
+
assert_equal Nanoc::ItemCollectionView, rule_context.items.class
|
28
|
+
|
29
|
+
# Check content
|
30
|
+
assert_equal rep, rule_context.rep.unwrap
|
31
|
+
assert_equal item, rule_context.item.unwrap
|
32
|
+
assert_equal site, rule_context.site.unwrap
|
33
|
+
assert_equal config, rule_context.config.unwrap
|
34
|
+
assert_equal layouts, rule_context.layouts.unwrap
|
35
|
+
assert_equal items, rule_context.items.unwrap
|
27
36
|
end
|
28
37
|
|
29
38
|
def test_actions
|
@@ -41,19 +50,29 @@ class Nanoc::Int::RuleContextTest < Nanoc::TestCase
|
|
41
50
|
# Mock rep
|
42
51
|
rep = mock
|
43
52
|
rep.stubs(:item).returns(item)
|
44
|
-
rep.expects(:filter).with(:foo, { bar: 'baz' })
|
45
|
-
rep.expects(:layout).with('foo')
|
46
|
-
rep.expects(:snapshot).with('awesome')
|
47
53
|
|
48
54
|
# Mock compiler
|
49
55
|
compiler = Nanoc::Int::Compiler.new(site)
|
50
56
|
|
51
57
|
# Create context
|
52
|
-
|
58
|
+
executor = nil
|
59
|
+
rule_context = Nanoc::Int::RuleContext.new(rep: rep, executor: executor, compiler: compiler)
|
53
60
|
|
54
61
|
# Check
|
55
|
-
|
56
|
-
|
57
|
-
|
62
|
+
assert_raises(NoMethodError) do
|
63
|
+
rule_context.instance_eval do
|
64
|
+
item_rep.filter :foo, bar: 'baz'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
assert_raises(NoMethodError) do
|
68
|
+
rule_context.instance_eval do
|
69
|
+
item_rep.layout 'foo'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
assert_raises(NoMethodError) do
|
73
|
+
rule_context.instance_eval do
|
74
|
+
item_rep.snapshot 'awesome'
|
75
|
+
end
|
76
|
+
end
|
58
77
|
end
|
59
78
|
end
|
@@ -105,13 +105,13 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
|
|
105
105
|
File.open(filename, 'w') { |io| io.write('test') }
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
# Check - { './stuff/foo' => ['yaml', ['html', 'md']] }
|
109
109
|
res = data_source.send(:all_split_files_in, '.')
|
110
110
|
assert_equal ['./stuff/foo'], res.keys
|
111
111
|
assert_equal 2, res.values[0].size
|
112
112
|
assert_equal 'yaml', res.values[0][0]
|
113
113
|
assert_equal Array, res.values[0][1].class
|
114
|
-
assert_equal
|
114
|
+
assert_equal %w(html md), res.values[0][1].sort
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_all_split_files_in_with_multiple_content_files
|
@@ -41,31 +41,27 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
41
41
|
expected_out = [
|
42
42
|
klass.new(
|
43
43
|
'test 1',
|
44
|
-
{ 'num' => 1, :filename => 'foo/bar.html', :extension => 'html' },
|
44
|
+
{ 'num' => 1, :filename => 'foo/bar.html', :extension => 'html', mtime: File.mtime('foo/bar.html') },
|
45
45
|
'/bar/',
|
46
|
-
binary: false, mtime: File.mtime('foo/bar.html')
|
47
46
|
),
|
48
47
|
klass.new(
|
49
48
|
'test 2',
|
50
|
-
{ 'num' => 2, :filename => 'foo/b.c.html', :extension => 'c.html' },
|
49
|
+
{ 'num' => 2, :filename => 'foo/b.c.html', :extension => 'c.html', mtime: File.mtime('foo/b.c.html') },
|
51
50
|
'/b/',
|
52
|
-
binary: false, mtime: File.mtime('foo/b.c.html')
|
53
51
|
),
|
54
52
|
klass.new(
|
55
53
|
'test 3',
|
56
|
-
{ 'num' => 3, :filename => 'foo/a/b/c.html', :extension => 'html' },
|
54
|
+
{ 'num' => 3, :filename => 'foo/a/b/c.html', :extension => 'html', mtime: File.mtime('foo/a/b/c.html') },
|
57
55
|
'/a/b/c/',
|
58
|
-
binary: false, mtime: File.mtime('foo/a/b/c.html')
|
59
56
|
)
|
60
57
|
]
|
61
|
-
actual_out = data_source.send(:load_objects, 'foo', 'The Foo', klass).sort_by { |i| i.stuff[0] }
|
58
|
+
actual_out = data_source.send(:load_objects, 'foo', 'The Foo', klass).sort_by { |i| i.stuff[0].string }
|
62
59
|
|
63
60
|
# Check
|
64
61
|
(0..expected_out.size - 1).each do |i|
|
65
|
-
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0], 'content must match'
|
62
|
+
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0].string, 'content must match'
|
66
63
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
67
|
-
|
68
|
-
['num', :filename, :extension].each do |key|
|
64
|
+
['num', :filename, :extension, :mtime].each do |key|
|
69
65
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
70
66
|
end
|
71
67
|
end
|
@@ -110,9 +106,9 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
110
106
|
|
111
107
|
# Check
|
112
108
|
assert_equal 1, items.size
|
113
|
-
assert items[0].binary?
|
114
|
-
assert_equal
|
115
|
-
|
109
|
+
assert items[0].content.binary?
|
110
|
+
assert_equal "#{Dir.getwd}/foo/stuff.dat", items[0].content.filename
|
111
|
+
assert_equal Nanoc::Int::BinaryContent, items[0].content.class
|
116
112
|
end
|
117
113
|
|
118
114
|
def test_load_layouts_with_nil_dir_name
|
@@ -340,10 +336,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
340
336
|
:content_filename => nil,
|
341
337
|
:meta_filename => 'foo/a/b/c.yaml',
|
342
338
|
:extension => nil,
|
343
|
-
:file => nil
|
339
|
+
:file => nil,
|
340
|
+
mtime: File.mtime('foo/a/b/c.yaml')
|
344
341
|
},
|
345
342
|
'/a/b/c/',
|
346
|
-
binary: false, mtime: File.mtime('foo/a/b/c.yaml')
|
347
343
|
),
|
348
344
|
klass.new(
|
349
345
|
'test 2',
|
@@ -352,10 +348,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
352
348
|
:content_filename => 'foo/b.c.html',
|
353
349
|
:meta_filename => 'foo/b.c.yaml',
|
354
350
|
:extension => 'html',
|
355
|
-
:file => File.open('foo/b.c.html')
|
351
|
+
:file => File.open('foo/b.c.html'),
|
352
|
+
mtime: File.mtime('foo/b.c.html') > File.mtime('foo/b.c.yaml') ? File.mtime('foo/b.c.html') : File.mtime('foo/b.c.yaml')
|
356
353
|
},
|
357
354
|
'/b.c/',
|
358
|
-
binary: false, mtime: File.mtime('foo/b.c.html') > File.mtime('foo/b.c.yaml') ? File.mtime('foo/b.c.html') : File.mtime('foo/b.c.yaml')
|
359
355
|
),
|
360
356
|
klass.new(
|
361
357
|
'test 3',
|
@@ -363,10 +359,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
363
359
|
content_filename: 'foo/car.html',
|
364
360
|
meta_filename: nil,
|
365
361
|
extension: 'html',
|
366
|
-
file: File.open('foo/car.html')
|
362
|
+
file: File.open('foo/car.html'),
|
363
|
+
mtime: File.mtime('foo/car.html')
|
367
364
|
},
|
368
365
|
'/car/',
|
369
|
-
binary: false, mtime: File.mtime('foo/car.html')
|
370
366
|
)
|
371
367
|
]
|
372
368
|
|
@@ -375,11 +371,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
375
371
|
|
376
372
|
# Check
|
377
373
|
(0..expected_out.size - 1).each do |i|
|
378
|
-
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0], 'content must match'
|
374
|
+
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0].string, 'content must match'
|
379
375
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
380
|
-
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
381
376
|
|
382
|
-
['num', :content_filename, :meta_filename, :extension].each do |key|
|
377
|
+
['num', :content_filename, :meta_filename, :extension, :mtime].each do |key|
|
383
378
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
384
379
|
end
|
385
380
|
end
|
@@ -423,10 +418,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
423
418
|
:content_filename => nil,
|
424
419
|
:meta_filename => 'foo/a/b/c.yaml',
|
425
420
|
:extension => nil,
|
426
|
-
:file => nil
|
421
|
+
:file => nil,
|
422
|
+
mtime: File.mtime('foo/a/b/c.yaml')
|
427
423
|
},
|
428
424
|
'/a/b/c/',
|
429
|
-
binary: false, mtime: File.mtime('foo/a/b/c.yaml')
|
430
425
|
),
|
431
426
|
klass.new(
|
432
427
|
'test 2',
|
@@ -435,10 +430,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
435
430
|
:content_filename => 'foo/b.html.erb',
|
436
431
|
:meta_filename => 'foo/b.yaml',
|
437
432
|
:extension => 'html.erb',
|
438
|
-
:file => File.open('foo/b.html.erb')
|
433
|
+
:file => File.open('foo/b.html.erb'),
|
434
|
+
mtime: File.mtime('foo/b.html.erb') > File.mtime('foo/b.yaml') ? File.mtime('foo/b.html.erb') : File.mtime('foo/b.yaml')
|
439
435
|
},
|
440
436
|
'/b/',
|
441
|
-
binary: false, mtime: File.mtime('foo/b.html.erb') > File.mtime('foo/b.yaml') ? File.mtime('foo/b.html.erb') : File.mtime('foo/b.yaml')
|
442
437
|
),
|
443
438
|
klass.new(
|
444
439
|
'test 3',
|
@@ -446,10 +441,10 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
446
441
|
content_filename: 'foo/car.html',
|
447
442
|
meta_filename: nil,
|
448
443
|
extension: 'html',
|
449
|
-
file: File.open('foo/car.html')
|
444
|
+
file: File.open('foo/car.html'),
|
445
|
+
mtime: File.mtime('foo/car.html')
|
450
446
|
},
|
451
447
|
'/car/',
|
452
|
-
binary: false, mtime: File.mtime('foo/car.html')
|
453
448
|
)
|
454
449
|
]
|
455
450
|
|
@@ -458,16 +453,27 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
458
453
|
|
459
454
|
# Check
|
460
455
|
(0..expected_out.size - 1).each do |i|
|
461
|
-
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0], 'content must match'
|
456
|
+
assert_equal expected_out[i].stuff[0], actual_out[i].stuff[0].string, 'content must match'
|
462
457
|
assert_equal expected_out[i].stuff[2], actual_out[i].stuff[2], 'identifier must match'
|
463
|
-
assert_equal expected_out[i].stuff[3][:mtime], actual_out[i].stuff[3][:mtime], 'mtime must match'
|
464
458
|
|
465
|
-
['num', :content_filename, :meta_filename, :extension].each do |key|
|
459
|
+
['num', :content_filename, :meta_filename, :extension, :mtime].each do |key|
|
466
460
|
assert_equal expected_out[i].stuff[1][key], actual_out[i].stuff[1][key], "attribute key #{key} must match"
|
467
461
|
end
|
468
462
|
end
|
469
463
|
end
|
470
464
|
|
465
|
+
def test_load_objects_correct_identifier_with_separate_yaml_file
|
466
|
+
data_source = new_data_source({ identifier_type: 'full' })
|
467
|
+
|
468
|
+
FileUtils.mkdir_p('foo')
|
469
|
+
File.write('foo/donkey.jpeg', 'data')
|
470
|
+
File.write('foo/donkey.yaml', "---\nalt: Donkey\n")
|
471
|
+
|
472
|
+
objects = data_source.send(:load_objects, 'foo', 'The Foo', Nanoc::Int::Item)
|
473
|
+
assert_equal 1, objects.size
|
474
|
+
assert_equal '/donkey.jpeg', objects.first.identifier.to_s
|
475
|
+
end
|
476
|
+
|
471
477
|
def test_filename_for
|
472
478
|
data_source = new_data_source
|
473
479
|
|
@@ -517,7 +523,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
517
523
|
items = data_source.items
|
518
524
|
|
519
525
|
assert_equal 1, items.size
|
520
|
-
assert_equal Encoding.find('UTF-8'), items[0].
|
526
|
+
assert_equal Encoding.find('UTF-8'), items[0].content.string.encoding
|
521
527
|
ensure
|
522
528
|
Encoding.default_external = original_default_external_encoding
|
523
529
|
end
|
@@ -548,6 +554,6 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
|
|
548
554
|
# Parse
|
549
555
|
items = data_source.items
|
550
556
|
assert_equal 1, items.size
|
551
|
-
assert_equal Encoding.find('UTF-8'), items[0].
|
557
|
+
assert_equal Encoding.find('UTF-8'), items[0].content.string.encoding
|
552
558
|
end
|
553
559
|
end
|
@@ -34,7 +34,6 @@ class Nanoc::Extra::Checking::Checks::HTMLTest < Nanoc::TestCase
|
|
34
34
|
assert_equal 2, check.issues.size
|
35
35
|
assert_equal 'line 1: no document type declaration; will parse without validation: <h2>Hi!</h1>', check.issues.to_a[0].description
|
36
36
|
assert_equal 'line 1: end tag for element "H1" which is not open: <h2>Hi!</h1>', check.issues.to_a[1].description
|
37
|
-
check.issues.to_a[0].description
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
|
2
2
|
def create_output_file(name, lines)
|
3
3
|
FileUtils.mkdir_p('output')
|
4
|
-
File.open('output/' + name, 'w')
|
4
|
+
File.open('output/' + name, 'w') do |io|
|
5
5
|
io.write(lines.join('\n'))
|
6
|
-
|
6
|
+
end
|
7
7
|
end
|
8
8
|
|
9
9
|
def assert_include(haystack, needle)
|
@@ -137,7 +137,7 @@ class Nanoc::Extra::Checking::Checks::MixedContentTest < Nanoc::TestCase
|
|
137
137
|
issues = check.issues.to_a
|
138
138
|
assert_equal 8, issues.count
|
139
139
|
|
140
|
-
descriptions = issues.map
|
140
|
+
descriptions = issues.map(&:description)
|
141
141
|
issues.each do |issue|
|
142
142
|
assert_equal 'output/foo.html', issue.subject
|
143
143
|
end
|
@@ -62,31 +62,31 @@ class Nanoc::Extra::Deployers::FogTest < Nanoc::TestCase
|
|
62
62
|
def test_run_cdn_with_dry_run
|
63
63
|
if_have 'fog' do
|
64
64
|
begin
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
65
|
+
# Create deployer
|
66
|
+
fog = Nanoc::Extra::Deployers::Fog.new(
|
67
|
+
'output/',
|
68
|
+
{
|
69
|
+
provider: 'aws',
|
70
|
+
cdn_id: 'id-cdn',
|
71
|
+
# FIXME: bucket is necessary for deployer but fog doesn't like it
|
72
|
+
bucket_name: 'doesntmatter',
|
73
|
+
aws_access_key_id: 'meh',
|
74
|
+
aws_secret_access_key: 'dontcare' },
|
75
|
+
dry_run: true)
|
76
|
+
|
77
|
+
# Create site
|
78
|
+
FileUtils.mkdir_p('output')
|
79
|
+
File.open('output/meow', 'w') { |io| io.write 'I am a cat!' }
|
80
|
+
File.open('output/bark', 'w') { |io| io.write 'I am a dog!' }
|
81
|
+
|
82
|
+
# Create local cloud (but not bucket)
|
83
|
+
FileUtils.mkdir_p('mylocalcloud')
|
84
|
+
|
85
|
+
# Run
|
86
|
+
fog.run
|
87
87
|
ensure
|
88
|
-
|
89
|
-
|
88
|
+
# HACK :(
|
89
|
+
::Fog.instance_eval { @mocking = false }
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
data/test/filters/test_less.rb
CHANGED
@@ -2,7 +2,7 @@ class Nanoc::Filters::LessTest < Nanoc::TestCase
|
|
2
2
|
def test_filter
|
3
3
|
if_have 'less' do
|
4
4
|
# Create item
|
5
|
-
@item = Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/')
|
5
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/'))
|
6
6
|
|
7
7
|
# Create filter
|
8
8
|
filter = ::Nanoc::Filters::Less.new(item: @item, items: [@item])
|
@@ -20,7 +20,7 @@ class Nanoc::Filters::LessTest < Nanoc::TestCase
|
|
20
20
|
File.open('content/foo/bar/imported_file.less', 'w') { |io| io.write('p { color: red; }') }
|
21
21
|
|
22
22
|
# Create item
|
23
|
-
@item = Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/')
|
23
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/'))
|
24
24
|
|
25
25
|
# Create filter
|
26
26
|
filter = ::Nanoc::Filters::Less.new(item: @item, items: [@item])
|
@@ -39,7 +39,7 @@ class Nanoc::Filters::LessTest < Nanoc::TestCase
|
|
39
39
|
|
40
40
|
# Create item
|
41
41
|
File.open('content/foo/bar.txt', 'w') { |io| io.write('meh') }
|
42
|
-
@item = Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/')
|
42
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/'))
|
43
43
|
|
44
44
|
# Create filter
|
45
45
|
filter = ::Nanoc::Filters::Less.new(item: @item, items: [@item])
|
@@ -108,7 +108,7 @@ class Nanoc::Filters::LessTest < Nanoc::TestCase
|
|
108
108
|
def test_compression
|
109
109
|
if_have 'less' do
|
110
110
|
# Create item
|
111
|
-
@item = Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/')
|
111
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('blah', { content_filename: 'content/foo/bar.txt' }, '/foo/bar/'))
|
112
112
|
|
113
113
|
# Create filter
|
114
114
|
filter = ::Nanoc::Filters::Less.new(item: @item, items: [@item])
|
data/test/filters/test_sass.rb
CHANGED
@@ -274,7 +274,7 @@ class Nanoc::Filters::SassTest < Nanoc::TestCase
|
|
274
274
|
io.write("p\n color: blue")
|
275
275
|
end
|
276
276
|
|
277
|
-
options = { :
|
277
|
+
options = { filename: File.join(Dir.getwd, 'test.sass') }
|
278
278
|
::Sass::Engine.new('@import "morestuff"', options).render
|
279
279
|
end
|
280
280
|
end
|
@@ -285,10 +285,15 @@ class Nanoc::Filters::SassTest < Nanoc::TestCase
|
|
285
285
|
FileUtils.mkdir_p('content')
|
286
286
|
File.open('content/xyzzy.sass', 'w') { |io| io.write('p\n color: green') }
|
287
287
|
|
288
|
-
items = [
|
289
|
-
|
290
|
-
|
291
|
-
|
288
|
+
items = [
|
289
|
+
Nanoc::ItemView.new(
|
290
|
+
Nanoc::Int::Item.new(
|
291
|
+
'blah',
|
292
|
+
{ content_filename: 'content/xyzzy.sass' },
|
293
|
+
'/blah/',
|
294
|
+
),
|
295
|
+
),
|
296
|
+
]
|
292
297
|
params = { item: items[0], items: items }.merge(params)
|
293
298
|
::Nanoc::Filters::Sass.new(params)
|
294
299
|
end
|