nanoc 4.8.2 → 4.8.3

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +13 -1
  3. data/lib/nanoc/base/entities/document.rb +6 -1
  4. data/lib/nanoc/base/entities/identifier.rb +10 -3
  5. data/lib/nanoc/cli/command_runner.rb +27 -4
  6. data/lib/nanoc/cli/commands/view.rb +6 -2
  7. data/lib/nanoc/spec.rb +10 -0
  8. data/lib/nanoc/version.rb +1 -1
  9. data/spec/nanoc/base/entities/document_spec.rb +30 -0
  10. data/spec/nanoc/base/entities/identifier_spec.rb +13 -3
  11. data/spec/nanoc/base/item_rep_writer_spec.rb +1 -1
  12. data/spec/nanoc/base/services/executor_spec.rb +1 -1
  13. data/spec/nanoc/base/views/document_view_spec.rb +13 -13
  14. data/spec/nanoc/base/views/item_rep_view_spec.rb +15 -15
  15. data/spec/nanoc/base/views/item_view_spec.rb +21 -12
  16. data/spec/nanoc/base/views/layout_view_spec.rb +2 -2
  17. data/spec/nanoc/base/views/mutable_document_view_spec.rb +3 -3
  18. data/spec/nanoc/base/views/mutable_identifiable_collection_view_spec.rb +4 -4
  19. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +5 -5
  20. data/spec/nanoc/base/views/mutable_item_view_spec.rb +3 -3
  21. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +5 -5
  22. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +2 -2
  23. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +1 -1
  24. data/spec/nanoc/cli/command_runner_spec.rb +90 -0
  25. data/spec/nanoc/cli/commands/show_rules_spec.rb +1 -0
  26. data/spec/nanoc/cli/commands/view_spec.rb +13 -0
  27. data/spec/nanoc/cli_spec.rb +1 -1
  28. data/spec/nanoc/data_sources/filesystem_spec.rb +1 -1
  29. data/spec/nanoc/helpers/blogging_spec.rb +18 -18
  30. data/spec/nanoc/helpers/link_to_spec.rb +8 -8
  31. data/spec/spec_helper.rb +7 -8
  32. data/test/base/test_data_source.rb +8 -8
  33. data/test/base/test_item_array.rb +11 -11
  34. data/test/cli/commands/test_compile.rb +2 -2
  35. data/test/filters/test_handlebars.rb +3 -3
  36. data/test/filters/test_mustache.rb +2 -2
  37. data/test/filters/test_relativize_paths.rb +29 -29
  38. data/test/filters/test_sass.rb +1 -1
  39. data/test/filters/test_xsl.rb +6 -6
  40. data/test/helpers/test_capturing.rb +1 -1
  41. data/test/helpers/test_xml_sitemap.rb +15 -15
  42. metadata +4 -3
@@ -36,21 +36,21 @@ describe Nanoc::Helpers::LinkTo, helper: true do
36
36
 
37
37
  context 'with rep' do
38
38
  before do
39
- ctx.create_item('content', {}, '/target/')
40
- ctx.create_rep(ctx.items['/target/'], '/target.html')
39
+ ctx.create_item('content', {}, '/target')
40
+ ctx.create_rep(ctx.items['/target'], '/target.html')
41
41
  end
42
42
 
43
- let(:target) { ctx.items['/target/'].reps[:default] }
43
+ let(:target) { ctx.items['/target'].reps[:default] }
44
44
 
45
45
  it { is_expected.to eql('<a href="/target.html">Text</a>') }
46
46
  end
47
47
 
48
48
  context 'with item' do
49
49
  before do
50
- ctx.create_item('content', {}, '/target/')
50
+ ctx.create_item('content', {}, '/target')
51
51
  end
52
52
 
53
- let(:target) { ctx.items['/target/'] }
53
+ let(:target) { ctx.items['/target'] }
54
54
 
55
55
  before do
56
56
  ctx.create_rep(target, '/target.html')
@@ -77,11 +77,11 @@ describe Nanoc::Helpers::LinkTo, helper: true do
77
77
 
78
78
  context 'with nil path' do
79
79
  before do
80
- ctx.create_item('content', {}, '/target/')
81
- ctx.create_rep(ctx.items['/target/'], nil)
80
+ ctx.create_item('content', {}, '/target')
81
+ ctx.create_rep(ctx.items['/target'], nil)
82
82
  end
83
83
 
84
- let(:target) { ctx.items['/target/'].reps[:default] }
84
+ let(:target) { ctx.items['/target'].reps[:default] }
85
85
 
86
86
  it 'raises' do
87
87
  expect { subject }.to raise_error(RuntimeError)
@@ -17,6 +17,10 @@ require 'fuubar'
17
17
  Nanoc::CLI.setup
18
18
 
19
19
  RSpec.configure do |c|
20
+ c.include(Nanoc::Spec::Helper)
21
+
22
+ c.include(Nanoc::Spec::HelperHelper, helper: true)
23
+
20
24
  c.fuubar_progress_bar_options = {
21
25
  format: '%c/%C |<%b>%i| %p%%',
22
26
  }
@@ -29,16 +33,13 @@ RSpec.configure do |c|
29
33
 
30
34
  c.around(:each) do |example|
31
35
  Dir.mktmpdir('nanoc-test') do |dir|
32
- FileUtils.cd(dir) do
33
- example.run
34
- end
36
+ chdir(dir) { example.run }
35
37
  end
36
38
  end
37
39
 
38
40
  c.around(:each, chdir: false) do |example|
39
- FileUtils.cd(__dir__ + '/..') do
40
- example.run
41
- end
41
+ Dir.chdir(__dir__ + '/..')
42
+ example.run
42
43
  end
43
44
 
44
45
  c.before(:each) do
@@ -71,8 +72,6 @@ RSpec.configure do |c|
71
72
  File.write('Rules', 'passthrough "/**/*"')
72
73
  end
73
74
 
74
- c.include(Nanoc::Spec::HelperHelper, helper: true)
75
-
76
75
  # Set focus if any
77
76
  if ENV.fetch('FOCUS', false)
78
77
  $stdout.puts "Focusing spec on '#{ENV['FOCUS']}'"
@@ -37,20 +37,20 @@ class Nanoc::DataSourceTest < Nanoc::TestCase
37
37
  def test_new_item
38
38
  data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
39
39
 
40
- item = data_source.new_item('stuff', { title: 'Stuff!' }, '/asdf/', checksum_data: 'abcdef')
40
+ item = data_source.new_item('stuff', { title: 'Stuff!' }, '/asdf', checksum_data: 'abcdef')
41
41
  assert_equal 'stuff', item.content.string
42
42
  assert_equal 'Stuff!', item.attributes[:title]
43
- assert_equal Nanoc::Identifier.new('/asdf/'), item.identifier
43
+ assert_equal Nanoc::Identifier.new('/asdf'), item.identifier
44
44
  assert_equal 'abcdef', item.checksum_data
45
45
  end
46
46
 
47
47
  def test_new_item_with_checksums
48
48
  data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
49
49
 
50
- item = data_source.new_item('stuff', { title: 'Stuff!' }, '/asdf/', content_checksum_data: 'con-cs', attributes_checksum_data: 'attr-cs')
50
+ item = data_source.new_item('stuff', { title: 'Stuff!' }, '/asdf', content_checksum_data: 'con-cs', attributes_checksum_data: 'attr-cs')
51
51
  assert_equal 'stuff', item.content.string
52
52
  assert_equal 'Stuff!', item.attributes[:title]
53
- assert_equal Nanoc::Identifier.new('/asdf/'), item.identifier
53
+ assert_equal Nanoc::Identifier.new('/asdf'), item.identifier
54
54
  assert_equal 'con-cs', item.content_checksum_data
55
55
  assert_equal 'attr-cs', item.attributes_checksum_data
56
56
  end
@@ -58,20 +58,20 @@ class Nanoc::DataSourceTest < Nanoc::TestCase
58
58
  def test_new_layout
59
59
  data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
60
60
 
61
- layout = data_source.new_layout('stuff', { title: 'Stuff!' }, '/asdf/', checksum_data: 'abcdef')
61
+ layout = data_source.new_layout('stuff', { title: 'Stuff!' }, '/asdf', checksum_data: 'abcdef')
62
62
  assert_equal 'stuff', layout.content.string
63
63
  assert_equal 'Stuff!', layout.attributes[:title]
64
- assert_equal Nanoc::Identifier.new('/asdf/'), layout.identifier
64
+ assert_equal Nanoc::Identifier.new('/asdf'), layout.identifier
65
65
  assert_equal 'abcdef', layout.checksum_data
66
66
  end
67
67
 
68
68
  def test_new_layout_with_checksums
69
69
  data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
70
70
 
71
- layout = data_source.new_layout('stuff', { title: 'Stuff!' }, '/asdf/', content_checksum_data: 'con-cs', attributes_checksum_data: 'attr-cs')
71
+ layout = data_source.new_layout('stuff', { title: 'Stuff!' }, '/asdf', content_checksum_data: 'con-cs', attributes_checksum_data: 'attr-cs')
72
72
  assert_equal 'stuff', layout.content.string
73
73
  assert_equal 'Stuff!', layout.attributes[:title]
74
- assert_equal Nanoc::Identifier.new('/asdf/'), layout.identifier
74
+ assert_equal Nanoc::Identifier.new('/asdf'), layout.identifier
75
75
  assert_equal 'con-cs', layout.content_checksum_data
76
76
  assert_equal 'attr-cs', layout.attributes_checksum_data
77
77
  end
@@ -6,32 +6,32 @@ class Nanoc::Int::IdentifiableCollectionTest < Nanoc::TestCase
6
6
  def setup
7
7
  super
8
8
 
9
- @one = Nanoc::Int::Item.new('Item One', {}, '/one/')
10
- @two = Nanoc::Int::Item.new('Item Two', {}, '/two/')
9
+ @one = Nanoc::Int::Item.new('Item One', {}, '/one')
10
+ @two = Nanoc::Int::Item.new('Item Two', {}, '/two')
11
11
 
12
12
  @items = Nanoc::Int::ItemCollection.new({}, [@one, @two])
13
13
  end
14
14
 
15
15
  def test_change_item_identifier
16
- assert_equal @one, @items['/one/']
17
- assert_nil @items['/foo/']
16
+ assert_equal @one, @items['/one']
17
+ assert_nil @items['/foo']
18
18
 
19
- @one.identifier = '/foo/'
19
+ @one.identifier = '/foo'
20
20
 
21
- assert_nil @items['/one/']
22
- assert_equal @one, @items['/foo/']
21
+ assert_nil @items['/one']
22
+ assert_equal @one, @items['/foo']
23
23
  end
24
24
 
25
25
  def test_enumerable
26
- assert_equal @one, @items.find { |i| i.identifier == '/one/' }
26
+ assert_equal @one, @items.find { |i| i.identifier == '/one' }
27
27
  end
28
28
 
29
29
  def test_less_than_less_than
30
- assert_nil @items['/foo/']
30
+ assert_nil @items['/foo']
31
31
 
32
- foo = Nanoc::Int::Item.new('Item Foo', {}, '/foo/')
32
+ foo = Nanoc::Int::Item.new('Item Foo', {}, '/foo')
33
33
  @items = Nanoc::Int::ItemCollection.new({}, [@one, @two, foo])
34
34
 
35
- assert_equal foo, @items['/foo/']
35
+ assert_equal foo, @items['/foo']
36
36
  end
37
37
  end
@@ -166,7 +166,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
166
166
 
167
167
  def test_file_action_printer_normal
168
168
  # Create data
169
- item = Nanoc::Int::Item.new('content', {}, '/')
169
+ item = Nanoc::Int::Item.new('content', {}, '/a')
170
170
  rep = Nanoc::Int::ItemRep.new(item, :default)
171
171
  rep.raw_paths[:last] = ['output/foo.txt']
172
172
  rep.compiled = true
@@ -188,7 +188,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
188
188
 
189
189
  def test_file_action_printer_skip
190
190
  # Create data
191
- item = Nanoc::Int::Item.new('content', {}, '/')
191
+ item = Nanoc::Int::Item.new('content', {}, '/a')
192
192
  rep = Nanoc::Int::ItemRep.new(item, :default)
193
193
  rep.raw_paths[:last] = ['output/foo.txt']
194
194
 
@@ -9,12 +9,12 @@ class Nanoc::Filters::HandlebarsTest < Nanoc::TestCase
9
9
  item = Nanoc::Int::Item.new(
10
10
  'content',
11
11
  { title: 'Max Payne', protagonist: 'Max Payne', location: 'here' },
12
- '/games/max-payne/',
12
+ '/games/max-payne',
13
13
  )
14
14
  layout = Nanoc::Int::Layout.new(
15
15
  'layout content',
16
16
  { name: 'Max Payne' },
17
- '/default/',
17
+ '/default',
18
18
  )
19
19
  config = { animals: 'cats and dogs' }
20
20
 
@@ -43,7 +43,7 @@ class Nanoc::Filters::HandlebarsTest < Nanoc::TestCase
43
43
  item = Nanoc::Int::Item.new(
44
44
  'content',
45
45
  { title: 'Max Payne', protagonist: 'Max Payne', location: 'here' },
46
- '/games/max-payne/',
46
+ '/games/max-payne',
47
47
  )
48
48
 
49
49
  # Create filter
@@ -9,7 +9,7 @@ class Nanoc::Filters::MustacheTest < Nanoc::TestCase
9
9
  item = Nanoc::Int::Item.new(
10
10
  'content',
11
11
  { title: 'Max Payne', protagonist: 'Max Payne' },
12
- '/games/max-payne/',
12
+ '/games/max-payne',
13
13
  )
14
14
 
15
15
  # Create filter
@@ -27,7 +27,7 @@ class Nanoc::Filters::MustacheTest < Nanoc::TestCase
27
27
  item = Nanoc::Int::Item.new(
28
28
  'content',
29
29
  { title: 'Max Payne', protagonist: 'Max Payne' },
30
- '/games/max-payne/',
30
+ '/games/max-payne',
31
31
  )
32
32
 
33
33
  # Create filter
@@ -13,7 +13,7 @@ class Nanoc::Filters::RelativizePathsTest < Nanoc::TestCase
13
13
  Nanoc::Int::Item.new(
14
14
  'content',
15
15
  {},
16
- '/foo/bar/baz/',
16
+ '/foo/bar/baz',
17
17
  ),
18
18
  :blah,
19
19
  )
@@ -39,7 +39,7 @@ class Nanoc::Filters::RelativizePathsTest < Nanoc::TestCase
39
39
  Nanoc::Int::Item.new(
40
40
  'content',
41
41
  {},
42
- '/foo/bar/baz/',
42
+ '/foo/bar/baz',
43
43
  ),
44
44
  :blah,
45
45
  )
@@ -65,7 +65,7 @@ class Nanoc::Filters::RelativizePathsTest < Nanoc::TestCase
65
65
  Nanoc::Int::Item.new(
66
66
  'content',
67
67
  {},
68
- '/foo/bar/baz/',
68
+ '/foo/bar/baz',
69
69
  ),
70
70
  :blah,
71
71
  )
@@ -91,7 +91,7 @@ class Nanoc::Filters::RelativizePathsTest < Nanoc::TestCase
91
91
  Nanoc::Int::Item.new(
92
92
  'content',
93
93
  {},
94
- '/foo/bar/baz/',
94
+ '/foo/bar/baz',
95
95
  ),
96
96
  :blah,
97
97
  )
@@ -129,7 +129,7 @@ EOS
129
129
  Nanoc::Int::Item.new(
130
130
  'content',
131
131
  {},
132
- '/foo/bar/baz/',
132
+ '/foo/bar/baz',
133
133
  ),
134
134
  :blah,
135
135
  )
@@ -167,7 +167,7 @@ EOS
167
167
  Nanoc::Int::Item.new(
168
168
  'content',
169
169
  {},
170
- '/foo/bar/baz/',
170
+ '/foo/bar/baz',
171
171
  ),
172
172
  :blah,
173
173
  )
@@ -193,7 +193,7 @@ EOS
193
193
  Nanoc::Int::Item.new(
194
194
  'content',
195
195
  {},
196
- '/foo/bar/baz/',
196
+ '/foo/bar/baz',
197
197
  ),
198
198
  :blah,
199
199
  )
@@ -219,7 +219,7 @@ EOS
219
219
  Nanoc::Int::Item.new(
220
220
  'content',
221
221
  {},
222
- '/foo/bar/baz/',
222
+ '/foo/bar/baz',
223
223
  ),
224
224
  :blah,
225
225
  )
@@ -245,7 +245,7 @@ EOS
245
245
  Nanoc::Int::Item.new(
246
246
  'content',
247
247
  {},
248
- '/foo/bar/baz/',
248
+ '/foo/bar/baz',
249
249
  ),
250
250
  :blah,
251
251
  )
@@ -271,7 +271,7 @@ EOS
271
271
  Nanoc::Int::Item.new(
272
272
  'content',
273
273
  {},
274
- '/foo/bar/baz/',
274
+ '/foo/bar/baz',
275
275
  ),
276
276
  :blah,
277
277
  )
@@ -297,7 +297,7 @@ EOS
297
297
  Nanoc::Int::Item.new(
298
298
  'content',
299
299
  {},
300
- '/foo/bar/baz/',
300
+ '/foo/bar/baz',
301
301
  ),
302
302
  :blah,
303
303
  )
@@ -323,7 +323,7 @@ EOS
323
323
  Nanoc::Int::Item.new(
324
324
  'content',
325
325
  {},
326
- '/foo/bar/baz/',
326
+ '/foo/bar/baz',
327
327
  ),
328
328
  :blah,
329
329
  )
@@ -349,7 +349,7 @@ EOS
349
349
  Nanoc::Int::Item.new(
350
350
  'content',
351
351
  {},
352
- '/foo/bar/baz/',
352
+ '/foo/bar/baz',
353
353
  ),
354
354
  :blah,
355
355
  )
@@ -375,7 +375,7 @@ EOS
375
375
  Nanoc::Int::Item.new(
376
376
  'content',
377
377
  {},
378
- '/foo/bar/baz/',
378
+ '/foo/bar/baz',
379
379
  ),
380
380
  :blah,
381
381
  )
@@ -399,7 +399,7 @@ EOS
399
399
  Nanoc::Int::Item.new(
400
400
  'content',
401
401
  {},
402
- '/foo/bar/baz/',
402
+ '/foo/bar/baz',
403
403
  ),
404
404
  :blah,
405
405
  )
@@ -435,7 +435,7 @@ EOS
435
435
  Nanoc::Int::Item.new(
436
436
  'content',
437
437
  {},
438
- '/foo/bar/baz/',
438
+ '/foo/bar/baz',
439
439
  ),
440
440
  :blah,
441
441
  )
@@ -461,7 +461,7 @@ EOS
461
461
  Nanoc::Int::Item.new(
462
462
  'content',
463
463
  {},
464
- '/foo/bar/baz/',
464
+ '/foo/bar/baz',
465
465
  ),
466
466
  :blah,
467
467
  )
@@ -487,7 +487,7 @@ EOS
487
487
  Nanoc::Int::Item.new(
488
488
  'content',
489
489
  {},
490
- '/foo/bar/baz/',
490
+ '/foo/bar/baz',
491
491
  ),
492
492
  :blah,
493
493
  )
@@ -513,7 +513,7 @@ EOS
513
513
  Nanoc::Int::Item.new(
514
514
  'content',
515
515
  {},
516
- '/foo/bar/baz/',
516
+ '/foo/bar/baz',
517
517
  ),
518
518
  :blah,
519
519
  )
@@ -542,7 +542,7 @@ EOS
542
542
  Nanoc::Int::Item.new(
543
543
  'content',
544
544
  {},
545
- '/foo/bar/baz/',
545
+ '/foo/bar/baz',
546
546
  ),
547
547
  :blah,
548
548
  )
@@ -568,7 +568,7 @@ EOS
568
568
  Nanoc::Int::Item.new(
569
569
  'content',
570
570
  {},
571
- '/foo/bar/baz/',
571
+ '/foo/bar/baz',
572
572
  ),
573
573
  :blah,
574
574
  )
@@ -595,7 +595,7 @@ EOS
595
595
  Nanoc::Int::Item.new(
596
596
  'content',
597
597
  {},
598
- '/foo/bar/baz/',
598
+ '/foo/bar/baz',
599
599
  ),
600
600
  :blah,
601
601
  )
@@ -628,7 +628,7 @@ XML
628
628
  Nanoc::Int::Item.new(
629
629
  'content',
630
630
  {},
631
- '/foo/bar/baz/',
631
+ '/foo/bar/baz',
632
632
  ),
633
633
  :blah,
634
634
  )
@@ -660,7 +660,7 @@ XML
660
660
  Nanoc::Int::Item.new(
661
661
  'content',
662
662
  {},
663
- '/foo/bar/baz/',
663
+ '/foo/bar/baz',
664
664
  ),
665
665
  :blah,
666
666
  )
@@ -697,7 +697,7 @@ XML
697
697
  Nanoc::Int::Item.new(
698
698
  'content',
699
699
  {},
700
- '/foo/bar/baz/',
700
+ '/foo/bar/baz',
701
701
  ),
702
702
  :blah,
703
703
  )
@@ -739,7 +739,7 @@ XML
739
739
  Nanoc::Int::Item.new(
740
740
  'content',
741
741
  {},
742
- '/foo/bar/baz/',
742
+ '/foo/bar/baz',
743
743
  ),
744
744
  :blah,
745
745
  )
@@ -774,7 +774,7 @@ XML
774
774
  Nanoc::Int::Item.new(
775
775
  'content',
776
776
  {},
777
- '/foo/baz/',
777
+ '/foo/baz',
778
778
  ),
779
779
  :blah,
780
780
  )
@@ -808,7 +808,7 @@ XML
808
808
  Nanoc::Int::Item.new(
809
809
  'content',
810
810
  {},
811
- '/foo/baz/',
811
+ '/foo/baz',
812
812
  ),
813
813
  :blah,
814
814
  )
@@ -839,7 +839,7 @@ XML
839
839
  Nanoc::Int::Item.new(
840
840
  'content',
841
841
  {},
842
- '/foo/bar/baz/',
842
+ '/foo/bar/baz',
843
843
  ),
844
844
  :blah,
845
845
  )