nanoc 4.7.6 → 4.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/NEWS.md +7 -0
  4. data/lib/nanoc/base/entities/identifiable_collection.rb +8 -8
  5. data/lib/nanoc/base/entities/outdatedness_reasons.rb +0 -5
  6. data/lib/nanoc/base/repos/dependency_store.rb +23 -9
  7. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +2 -1
  8. data/lib/nanoc/base/services/compiler_loader.rb +1 -1
  9. data/lib/nanoc/base/services/outdatedness_checker.rb +0 -1
  10. data/lib/nanoc/base/services/outdatedness_rules.rb +0 -1
  11. data/lib/nanoc/cli/commands/compile.rb +1 -0
  12. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +1 -1
  13. data/lib/nanoc/filters/colorize_syntax.rb +54 -316
  14. data/lib/nanoc/filters/colorize_syntax/colorizers.rb +177 -0
  15. data/lib/nanoc/version.rb +1 -1
  16. data/spec/nanoc/base/compiler_spec.rb +5 -2
  17. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +29 -0
  18. data/spec/nanoc/base/repos/dependency_store_spec.rb +79 -79
  19. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +5 -2
  20. data/spec/nanoc/base/services/dependency_tracker_spec.rb +7 -1
  21. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +6 -7
  22. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +3 -56
  23. data/spec/nanoc/base/views/document_view_spec.rb +7 -1
  24. data/spec/nanoc/base/views/item_rep_view_spec.rb +7 -1
  25. data/spec/nanoc/base/views/item_view_spec.rb +7 -1
  26. data/spec/nanoc/cli/commands/compile/diff_generator_spec.rb +44 -0
  27. data/spec/nanoc/cli/commands/show_data_spec.rb +1 -5
  28. data/spec/nanoc/integration/compile_command_spec.rb +31 -0
  29. data/test/base/test_dependency_tracker.rb +106 -86
  30. data/test/filters/test_xsl.rb +5 -1
  31. metadata +5 -3
  32. data/lib/nanoc/base/services/outdatedness_rules/paths_modified.rb +0 -20
@@ -26,7 +26,7 @@ describe Nanoc::Int::Compiler::Stages::CompileReps do
26
26
  let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
27
27
 
28
28
  let(:outdatedness_store) { Nanoc::Int::OutdatednessStore.new(site: site, reps: reps) }
29
- let(:dependency_store) { Nanoc::Int::DependencyStore.new(items.to_a) }
29
+ let(:dependency_store) { Nanoc::Int::DependencyStore.new(items, layouts) }
30
30
 
31
31
  let(:rep) { Nanoc::Int::ItemRep.new(item, :default) }
32
32
  let(:item) { Nanoc::Int::Item.new('<%= 1 + 2 %>', {}, '/hi.md') }
@@ -43,9 +43,12 @@ describe Nanoc::Int::Compiler::Stages::CompileReps do
43
43
  end
44
44
 
45
45
  let(:config) { Nanoc::Int::Configuration.new.with_defaults }
46
- let(:layouts) { [] }
47
46
  let(:code_snippets) { [] }
48
47
 
48
+ let(:layouts) do
49
+ Nanoc::Int::IdentifiableCollection.new(config)
50
+ end
51
+
49
52
  let(:items) do
50
53
  Nanoc::Int::IdentifiableCollection.new(
51
54
  config,
@@ -1,12 +1,18 @@
1
1
  describe Nanoc::Int::DependencyTracker do
2
2
  let(:tracker) { described_class.new(store) }
3
3
 
4
- let(:store) { Nanoc::Int::DependencyStore.new([]) }
4
+ let(:store) { Nanoc::Int::DependencyStore.new(empty_identifiable_collection, empty_identifiable_collection) }
5
5
 
6
6
  let(:item_a) { Nanoc::Int::Item.new('a', {}, '/a.md') }
7
7
  let(:item_b) { Nanoc::Int::Item.new('b', {}, '/b.md') }
8
8
  let(:item_c) { Nanoc::Int::Item.new('c', {}, '/c.md') }
9
9
 
10
+ let(:empty_identifiable_collection) do
11
+ Nanoc::Int::IdentifiableCollection.new(config)
12
+ end
13
+
14
+ let(:config) { Nanoc::Int::Configuration.new.with_defaults }
15
+
10
16
  shared_examples 'a null dependency tracker' do
11
17
  let(:tracker) { Nanoc::Int::DependencyTracker::Null.new }
12
18
 
@@ -13,10 +13,11 @@ describe Nanoc::Int::OutdatednessChecker do
13
13
  let(:checksum_store) { double(:checksum_store) }
14
14
 
15
15
  let(:dependency_store) do
16
- Nanoc::Int::DependencyStore.new(objects)
16
+ Nanoc::Int::DependencyStore.new(items, layouts)
17
17
  end
18
18
 
19
- let(:objects) { [item] }
19
+ let(:items) { Nanoc::Int::IdentifiableCollection.new(config, [item]) }
20
+ let(:layouts) { Nanoc::Int::IdentifiableCollection.new(config) }
20
21
 
21
22
  let(:site) do
22
23
  Nanoc::Int::Site.new(
@@ -49,8 +50,6 @@ describe Nanoc::Int::OutdatednessChecker do
49
50
  let(:item_rep) { Nanoc::Int::ItemRep.new(item, :default) }
50
51
  let(:item) { Nanoc::Int::Item.new('stuff', {}, '/foo.md') }
51
52
 
52
- let(:objects) { [item] }
53
-
54
53
  before do
55
54
  reps << item_rep
56
55
  action_sequence_store[item_rep] = old_action_sequence_for_item_rep.serialize
@@ -59,7 +58,7 @@ describe Nanoc::Int::OutdatednessChecker do
59
58
  describe 'basic outdatedness reasons' do
60
59
  subject { outdatedness_checker.send(:basic).outdatedness_status_for(obj).reasons.first }
61
60
 
62
- let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
61
+ let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: items.to_a + layouts.to_a) }
63
62
 
64
63
  let(:config) { Nanoc::Int::Configuration.new }
65
64
 
@@ -114,14 +113,14 @@ describe Nanoc::Int::OutdatednessChecker do
114
113
  describe '#outdated_due_to_dependencies?' do
115
114
  subject { outdatedness_checker.send(:outdated_due_to_dependencies?, item) }
116
115
 
117
- let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
116
+ let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: items.to_a + layouts.to_a) }
118
117
 
119
118
  let(:other_item) { Nanoc::Int::Item.new('other stuff', {}, '/other.md') }
120
119
  let(:other_item_rep) { Nanoc::Int::ItemRep.new(other_item, :default) }
121
120
 
122
121
  let(:config) { Nanoc::Int::Configuration.new }
123
122
 
124
- let(:objects) { [item, other_item] }
123
+ let(:items) { Nanoc::Int::IdentifiableCollection.new(config, [item, other_item]) }
125
124
 
126
125
  let(:old_action_sequence_for_other_item_rep) do
127
126
  Nanoc::Int::ActionSequence.new(other_item_rep).tap do |seq|
@@ -32,11 +32,12 @@ describe Nanoc::Int::OutdatednessRules do
32
32
 
33
33
  let(:action_sequences) { {} }
34
34
  let(:reps) { Nanoc::Int::ItemRepRepo.new }
35
- let(:dependency_store) { Nanoc::Int::DependencyStore.new(dependency_store_objects) }
35
+ let(:dependency_store) { Nanoc::Int::DependencyStore.new(items, layouts) }
36
36
  let(:action_sequence_store) { Nanoc::Int::ActionSequenceStore.new }
37
37
  let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
38
38
 
39
- let(:dependency_store_objects) { [item] }
39
+ let(:items) { Nanoc::Int::IdentifiableCollection.new(config, [item]) }
40
+ let(:layouts) { Nanoc::Int::IdentifiableCollection.new(config) }
40
41
 
41
42
  before do
42
43
  allow(site).to receive(:code_snippets).and_return(code_snippets)
@@ -332,60 +333,6 @@ describe Nanoc::Int::OutdatednessRules do
332
333
  end
333
334
  end
334
335
 
335
- context 'PathsModified' do
336
- let(:rule_class) { Nanoc::Int::OutdatednessRules::PathsModified }
337
-
338
- let(:action_sequences) { { item_rep => new_mem } }
339
-
340
- context 'old mem does not exist' do
341
- let(:new_mem) do
342
- Nanoc::Int::ActionSequence.new(item_rep).tap do |mem|
343
- mem.add_snapshot(:donkey, '/foo.md')
344
- mem.add_filter(:asdf, {})
345
- end
346
- end
347
-
348
- it { is_expected.to be }
349
- end
350
-
351
- context 'old mem exists' do
352
- let(:old_mem) do
353
- Nanoc::Int::ActionSequence.new(item_rep).tap do |mem|
354
- mem.add_filter(:erb, {})
355
- mem.add_snapshot(:donkey, '/foo.md')
356
- end
357
- end
358
-
359
- before do
360
- action_sequence_store[item_rep] = old_mem.serialize
361
- end
362
-
363
- context 'paths in memory are the same' do
364
- let(:new_mem) do
365
- Nanoc::Int::ActionSequence.new(item_rep).tap do |mem|
366
- mem.add_snapshot(:donkey, '/foo.md')
367
- mem.add_filter(:asdf, {})
368
- end
369
- end
370
-
371
- it { is_expected.not_to be }
372
- end
373
-
374
- context 'paths in memory are different' do
375
- let(:new_mem) do
376
- Nanoc::Int::ActionSequence.new(item_rep).tap do |mem|
377
- mem.add_filter(:erb, {})
378
- mem.add_snapshot(:donkey, '/foo.md')
379
- mem.add_filter(:donkey, {})
380
- mem.add_snapshot(:giraffe, '/bar.md')
381
- end
382
- end
383
-
384
- it { is_expected.to be }
385
- end
386
- end
387
- end
388
-
389
336
  describe '#{Content,Attributes}Modified' do
390
337
  subject do
391
338
  [
@@ -12,9 +12,15 @@ shared_examples 'a document view' do
12
12
  end
13
13
 
14
14
  let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(dependency_store) }
15
- let(:dependency_store) { Nanoc::Int::DependencyStore.new([]) }
15
+ let(:dependency_store) { Nanoc::Int::DependencyStore.new(empty_identifiable_collection, empty_identifiable_collection) }
16
16
  let(:base_item) { Nanoc::Int::Item.new('base', {}, '/base.md') }
17
17
 
18
+ let(:empty_identifiable_collection) do
19
+ Nanoc::Int::IdentifiableCollection.new(config)
20
+ end
21
+
22
+ let(:config) { Nanoc::Int::Configuration.new.with_defaults }
23
+
18
24
  before do
19
25
  dependency_tracker.enter(base_item)
20
26
  end
@@ -15,9 +15,15 @@ describe Nanoc::ItemRepView do
15
15
  let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
16
16
 
17
17
  let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(dependency_store) }
18
- let(:dependency_store) { Nanoc::Int::DependencyStore.new([]) }
18
+ let(:dependency_store) { Nanoc::Int::DependencyStore.new(empty_identifiable_collection, empty_identifiable_collection) }
19
19
  let(:base_item) { Nanoc::Int::Item.new('base', {}, '/base.md') }
20
20
 
21
+ let(:empty_identifiable_collection) do
22
+ Nanoc::Int::IdentifiableCollection.new(config)
23
+ end
24
+
25
+ let(:config) { Nanoc::Int::Configuration.new.with_defaults }
26
+
21
27
  before do
22
28
  dependency_tracker.enter(base_item)
23
29
  end
@@ -16,12 +16,18 @@ describe Nanoc::ItemWithRepsView do
16
16
  let(:reps) { [] }
17
17
  let(:items) { [] }
18
18
  let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(dependency_store) }
19
- let(:dependency_store) { Nanoc::Int::DependencyStore.new([]) }
19
+ let(:dependency_store) { Nanoc::Int::DependencyStore.new(empty_identifiable_collection, empty_identifiable_collection) }
20
20
  let(:compilation_context) { double(:compilation_context) }
21
21
  let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
22
22
 
23
23
  let(:base_item) { Nanoc::Int::Item.new('base', {}, '/base.md') }
24
24
 
25
+ let(:empty_identifiable_collection) do
26
+ Nanoc::Int::IdentifiableCollection.new(config)
27
+ end
28
+
29
+ let(:config) { Nanoc::Int::Configuration.new.with_defaults }
30
+
25
31
  before do
26
32
  dependency_tracker.enter(base_item)
27
33
  end
@@ -0,0 +1,44 @@
1
+ describe Nanoc::CLI::Commands::CompileListeners::DiffGenerator do
2
+ describe '.enable_for?' do
3
+ subject { described_class.enable_for?(command_runner) }
4
+
5
+ let(:options) { {} }
6
+ let(:config_hash) { {} }
7
+
8
+ let(:arguments) { double(:arguments) }
9
+ let(:command) { double(:command) }
10
+
11
+ let(:site) do
12
+ Nanoc::Int::Site.new(
13
+ config: config,
14
+ code_snippets: code_snippets,
15
+ data_source: Nanoc::Int::InMemDataSource.new(items, layouts),
16
+ )
17
+ end
18
+
19
+ let(:config) { Nanoc::Int::Configuration.new(hash: config_hash).with_defaults }
20
+ let(:items) { [] }
21
+ let(:layouts) { [] }
22
+ let(:code_snippets) { [] }
23
+
24
+ let(:command_runner) do
25
+ Nanoc::CLI::Commands::Compile.new(options, arguments, command).tap do |cr|
26
+ cr.site = site
27
+ end
28
+ end
29
+
30
+ context 'default' do
31
+ it { is_expected.not_to be }
32
+ end
33
+
34
+ context 'enabled in config' do
35
+ let(:config_hash) { { enable_output_diff: true } }
36
+ it { is_expected.to be }
37
+ end
38
+
39
+ context 'enabled on command line' do
40
+ let(:options) { { diff: true } }
41
+ it { is_expected.to be }
42
+ end
43
+ end
44
+ end
@@ -28,11 +28,7 @@ describe Nanoc::CLI::Commands::ShowData, stdio: true do
28
28
  let(:config) { Nanoc::Int::Configuration.new }
29
29
 
30
30
  let(:dependency_store) do
31
- Nanoc::Int::DependencyStore.new(objects)
32
- end
33
-
34
- let(:objects) do
35
- items.to_a + layouts.to_a
31
+ Nanoc::Int::DependencyStore.new(items, layouts)
36
32
  end
37
33
 
38
34
  let(:layouts) do
@@ -0,0 +1,31 @@
1
+ describe 'Compile command', site: true, stdio: true do
2
+ describe 'diff generation' do
3
+ before do
4
+ File.write('content/foo.md', "I am foo!\n")
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/foo.*' do
8
+ write '/foo.html'
9
+ end
10
+ EOS
11
+ end
12
+
13
+ it 'does not generate diff by default' do
14
+ FileUtils.mkdir_p('output')
15
+ File.write('output/foo.html', "I am old foo!\n")
16
+
17
+ Nanoc::CLI.run(%w[compile])
18
+
19
+ expect(File.file?('output.diff')).not_to be
20
+ end
21
+
22
+ it 'honors --diff' do
23
+ FileUtils.mkdir_p('output')
24
+ File.write('output/foo.html', "I am old foo!\n")
25
+
26
+ Nanoc::CLI.run(%w[compile --diff])
27
+
28
+ expect(File.file?('output.diff')).to be
29
+ end
30
+ end
31
+ end
@@ -2,242 +2,262 @@ require 'helper'
2
2
 
3
3
  class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
4
4
  def test_initialize
5
- # Mock items
6
- items = [
5
+ # Mock objects
6
+ config = Nanoc::Int::Configuration.new.with_defaults
7
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
8
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
7
9
  Nanoc::Int::Item.new('a', {}, '/a.md'),
8
10
  Nanoc::Int::Item.new('b', {}, '/b.md'),
9
- ]
11
+ ])
10
12
 
11
13
  # Create
12
- store = Nanoc::Int::DependencyStore.new(items)
14
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
13
15
 
14
16
  # Verify no dependencies yet
15
- assert_empty store.objects_causing_outdatedness_of(items[0])
16
- assert_empty store.objects_causing_outdatedness_of(items[1])
17
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[0])
18
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[1])
17
19
  end
18
20
 
19
21
  def test_record_dependency
20
- # Mock items
21
- items = [
22
+ # Mock objects
23
+ config = Nanoc::Int::Configuration.new.with_defaults
24
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
25
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
22
26
  Nanoc::Int::Item.new('a', {}, '/a.md'),
23
27
  Nanoc::Int::Item.new('b', {}, '/b.md'),
24
- ]
28
+ ])
25
29
 
26
30
  # Create
27
- store = Nanoc::Int::DependencyStore.new(items)
31
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
28
32
 
29
33
  # Record some dependencies
30
- store.record_dependency(items[0], items[1])
34
+ store.record_dependency(items.to_a[0], items.to_a[1])
31
35
 
32
36
  # Verify dependencies
33
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
37
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
34
38
  end
35
39
 
36
40
  def test_record_dependency_no_self
37
- # Mock items
38
- items = [
41
+ # Mock objects
42
+ config = Nanoc::Int::Configuration.new.with_defaults
43
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
44
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
39
45
  Nanoc::Int::Item.new('a', {}, '/a.md'),
40
46
  Nanoc::Int::Item.new('b', {}, '/b.md'),
41
- ]
47
+ ])
42
48
 
43
49
  # Create
44
- store = Nanoc::Int::DependencyStore.new(items)
50
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
45
51
 
46
52
  # Record some dependencies
47
- store.record_dependency(items[0], items[0])
48
- store.record_dependency(items[0], items[1])
53
+ store.record_dependency(items.to_a[0], items.to_a[0])
54
+ store.record_dependency(items.to_a[0], items.to_a[1])
49
55
 
50
56
  # Verify dependencies
51
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
57
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
52
58
  end
53
59
 
54
60
  def test_record_dependency_no_doubles
55
- # Mock items
56
- items = [
61
+ # Mock objects
62
+ config = Nanoc::Int::Configuration.new.with_defaults
63
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
64
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
57
65
  Nanoc::Int::Item.new('a', {}, '/a.md'),
58
66
  Nanoc::Int::Item.new('b', {}, '/b.md'),
59
- ]
67
+ ])
60
68
 
61
69
  # Create
62
- store = Nanoc::Int::DependencyStore.new(items)
70
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
63
71
 
64
72
  # Record some dependencies
65
- store.record_dependency(items[0], items[1])
66
- store.record_dependency(items[0], items[1])
67
- store.record_dependency(items[0], items[1])
73
+ store.record_dependency(items.to_a[0], items.to_a[1])
74
+ store.record_dependency(items.to_a[0], items.to_a[1])
75
+ store.record_dependency(items.to_a[0], items.to_a[1])
68
76
 
69
77
  # Verify dependencies
70
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
78
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
71
79
  end
72
80
 
73
81
  def test_objects_causing_outdatedness_of
74
- # Mock items
75
- items = [
82
+ # Mock objects
83
+ config = Nanoc::Int::Configuration.new.with_defaults
84
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
85
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
76
86
  Nanoc::Int::Item.new('a', {}, '/a.md'),
77
87
  Nanoc::Int::Item.new('b', {}, '/b.md'),
78
88
  Nanoc::Int::Item.new('c', {}, '/c.md'),
79
- ]
89
+ ])
80
90
 
81
91
  # Create
82
- store = Nanoc::Int::DependencyStore.new(items)
92
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
83
93
 
84
94
  # Record some dependencies
85
- store.record_dependency(items[0], items[1])
86
- store.record_dependency(items[1], items[2])
95
+ store.record_dependency(items.to_a[0], items.to_a[1])
96
+ store.record_dependency(items.to_a[1], items.to_a[2])
87
97
 
88
98
  # Verify dependencies
89
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
99
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
90
100
  end
91
101
 
92
102
  def test_store_graph_and_load_graph_simple
93
- # Mock items
94
- items = [
103
+ # Mock objects
104
+ config = Nanoc::Int::Configuration.new.with_defaults
105
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
106
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
95
107
  Nanoc::Int::Item.new('a', {}, '/a.md'),
96
108
  Nanoc::Int::Item.new('b', {}, '/b.md'),
97
109
  Nanoc::Int::Item.new('c', {}, '/c.md'),
98
110
  Nanoc::Int::Item.new('d', {}, '/d.md'),
99
- ]
111
+ ])
100
112
 
101
113
  # Create
102
- store = Nanoc::Int::DependencyStore.new(items)
114
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
103
115
 
104
116
  # Record some dependencies
105
- store.record_dependency(items[0], items[1])
106
- store.record_dependency(items[1], items[2])
107
- store.record_dependency(items[1], items[3])
117
+ store.record_dependency(items.to_a[0], items.to_a[1])
118
+ store.record_dependency(items.to_a[1], items.to_a[2])
119
+ store.record_dependency(items.to_a[1], items.to_a[3])
108
120
 
109
121
  # Store
110
122
  store.store
111
123
  assert File.file?(store.filename)
112
124
 
113
125
  # Re-create
114
- store = Nanoc::Int::DependencyStore.new(items)
126
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
115
127
 
116
128
  # Load
117
129
  store.load
118
130
 
119
131
  # Check loaded graph
120
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
121
- assert_contains_exactly [items[2], items[3]], store.objects_causing_outdatedness_of(items[1])
122
- assert_empty store.objects_causing_outdatedness_of(items[2])
123
- assert_empty store.objects_causing_outdatedness_of(items[3])
132
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
133
+ assert_contains_exactly [items.to_a[2], items.to_a[3]], store.objects_causing_outdatedness_of(items.to_a[1])
134
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[2])
135
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[3])
124
136
  end
125
137
 
126
138
  def test_store_graph_and_load_graph_with_removed_items
127
- # Mock items
128
- items = [
139
+ # Mock objects
140
+ config = Nanoc::Int::Configuration.new.with_defaults
141
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
142
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
129
143
  Nanoc::Int::Item.new('a', {}, '/a.md'),
130
144
  Nanoc::Int::Item.new('b', {}, '/b.md'),
131
145
  Nanoc::Int::Item.new('c', {}, '/c.md'),
132
146
  Nanoc::Int::Item.new('d', {}, '/d.md'),
133
- ]
147
+ ])
134
148
 
135
149
  # Create new and old lists
136
- old_items = [items[0], items[1], items[2], items[3]]
137
- new_items = [items[0], items[1], items[2]]
150
+ old_items = Nanoc::Int::IdentifiableCollection.new(config, [items.to_a[0], items.to_a[1], items.to_a[2], items.to_a[3]])
151
+ new_items = Nanoc::Int::IdentifiableCollection.new(config, [items.to_a[0], items.to_a[1], items.to_a[2]])
138
152
 
139
153
  # Create
140
- store = Nanoc::Int::DependencyStore.new(old_items)
154
+ store = Nanoc::Int::DependencyStore.new(old_items, layouts)
141
155
 
142
156
  # Record some dependencies
143
- store.record_dependency(old_items[0], old_items[1])
144
- store.record_dependency(old_items[1], old_items[2])
145
- store.record_dependency(old_items[1], old_items[3])
157
+ store.record_dependency(items.to_a[0], items.to_a[1])
158
+ store.record_dependency(items.to_a[1], items.to_a[2])
159
+ store.record_dependency(items.to_a[1], items.to_a[3])
146
160
 
147
161
  # Store
148
162
  store.store
149
163
  assert File.file?(store.filename)
150
164
 
151
165
  # Re-create
152
- store = Nanoc::Int::DependencyStore.new(new_items)
166
+ store = Nanoc::Int::DependencyStore.new(new_items, layouts)
153
167
 
154
168
  # Load
155
169
  store.load
156
170
 
157
171
  # Check loaded graph
158
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
159
- assert_contains_exactly [items[2], nil], store.objects_causing_outdatedness_of(items[1])
160
- assert_empty store.objects_causing_outdatedness_of(items[2])
172
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
173
+ assert_contains_exactly [items.to_a[2], nil], store.objects_causing_outdatedness_of(items.to_a[1])
174
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[2])
161
175
  end
162
176
 
163
177
  def test_store_graph_with_nils_in_dst
164
- # Mock items
165
- items = [
178
+ # Mock objects
179
+ config = Nanoc::Int::Configuration.new.with_defaults
180
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
181
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
166
182
  Nanoc::Int::Item.new('a', {}, '/a.md'),
167
183
  Nanoc::Int::Item.new('b', {}, '/b.md'),
168
184
  Nanoc::Int::Item.new('c', {}, '/c.md'),
169
- ]
185
+ ])
170
186
 
171
187
  # Create
172
- store = Nanoc::Int::DependencyStore.new(items)
188
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
173
189
 
174
190
  # Record some dependencies
175
- store.record_dependency(items[0], items[1])
176
- store.record_dependency(items[1], nil)
191
+ store.record_dependency(items.to_a[0], items.to_a[1])
192
+ store.record_dependency(items.to_a[1], nil)
177
193
 
178
194
  # Store
179
195
  store.store
180
196
  assert File.file?(store.filename)
181
197
 
182
198
  # Re-create
183
- store = Nanoc::Int::DependencyStore.new(items)
199
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
184
200
 
185
201
  # Load
186
202
  store.load
187
203
 
188
204
  # Check loaded graph
189
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
190
- assert_contains_exactly [nil], store.objects_causing_outdatedness_of(items[1])
205
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
206
+ assert_contains_exactly [nil], store.objects_causing_outdatedness_of(items.to_a[1])
191
207
  end
192
208
 
193
209
  def test_store_graph_with_nils_in_src
194
- # Mock items
195
- items = [
210
+ # Mock objects
211
+ config = Nanoc::Int::Configuration.new.with_defaults
212
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
213
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
196
214
  Nanoc::Int::Item.new('a', {}, '/a.md'),
197
215
  Nanoc::Int::Item.new('b', {}, '/b.md'),
198
216
  Nanoc::Int::Item.new('c', {}, '/c.md'),
199
- ]
217
+ ])
200
218
 
201
219
  # Create
202
- store = Nanoc::Int::DependencyStore.new(items)
220
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
203
221
 
204
222
  # Record some dependencies
205
- store.record_dependency(items[0], items[1])
206
- store.record_dependency(nil, items[2])
223
+ store.record_dependency(items.to_a[0], items.to_a[1])
224
+ store.record_dependency(nil, items.to_a[2])
207
225
 
208
226
  # Store
209
227
  store.store
210
228
  assert File.file?(store.filename)
211
229
 
212
230
  # Re-create
213
- store = Nanoc::Int::DependencyStore.new(items)
231
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
214
232
 
215
233
  # Load
216
234
  store.load
217
235
 
218
236
  # Check loaded graph
219
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
220
- assert_empty store.objects_causing_outdatedness_of(items[1])
237
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
238
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[1])
221
239
  end
222
240
 
223
241
  def test_forget_dependencies_for
224
- # Mock items
225
- items = [
242
+ # Mock objects
243
+ config = Nanoc::Int::Configuration.new.with_defaults
244
+ layouts = Nanoc::Int::IdentifiableCollection.new(config)
245
+ items = Nanoc::Int::IdentifiableCollection.new(config, [
226
246
  Nanoc::Int::Item.new('a', {}, '/a.md'),
227
247
  Nanoc::Int::Item.new('b', {}, '/b.md'),
228
248
  Nanoc::Int::Item.new('c', {}, '/c.md'),
229
- ]
249
+ ])
230
250
 
231
251
  # Create
232
- store = Nanoc::Int::DependencyStore.new(items)
252
+ store = Nanoc::Int::DependencyStore.new(items, layouts)
233
253
 
234
254
  # Record some dependencies
235
- store.record_dependency(items[0], items[1])
236
- store.record_dependency(items[1], items[2])
237
- assert_contains_exactly [items[1]], store.objects_causing_outdatedness_of(items[0])
255
+ store.record_dependency(items.to_a[0], items.to_a[1])
256
+ store.record_dependency(items.to_a[1], items.to_a[2])
257
+ assert_contains_exactly [items.to_a[1]], store.objects_causing_outdatedness_of(items.to_a[0])
238
258
 
239
259
  # Forget dependencies
240
- store.forget_dependencies_for(items[0])
241
- assert_empty store.objects_causing_outdatedness_of(items[0])
260
+ store.forget_dependencies_for(items.to_a[0])
261
+ assert_empty store.objects_causing_outdatedness_of(items.to_a[0])
242
262
  end
243
263
  end