nanoc 4.6.0 → 4.6.1
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.lock +7 -7
- data/NEWS.md +13 -3
- data/README.md +1 -1
- data/lib/nanoc/base/entities/context.rb +14 -2
- data/lib/nanoc/base/services/compiler/phases/cache.rb +32 -0
- data/lib/nanoc/base/services/compiler/phases/mark_done.rb +16 -0
- data/lib/nanoc/base/services/compiler/phases/recalculate.rb +38 -0
- data/lib/nanoc/base/services/compiler/phases/resume.rb +46 -0
- data/lib/nanoc/base/services/compiler/phases/write.rb +19 -0
- data/lib/nanoc/base/services/compiler/phases.rb +8 -0
- data/lib/nanoc/base/services/compiler/stages/cleanup.rb +37 -0
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +65 -0
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +22 -0
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +19 -0
- data/lib/nanoc/base/services/compiler/stages/prune.rb +24 -0
- data/lib/nanoc/base/services/compiler/stages.rb +8 -0
- data/lib/nanoc/base/services/compiler.rb +1 -308
- data/lib/nanoc/base/services/item_rep_selector.rb +38 -6
- data/lib/nanoc/base/services.rb +3 -0
- data/lib/nanoc/cli/commands/compile.rb +32 -29
- data/lib/nanoc/data_sources/filesystem.rb +12 -4
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/base/compiler_spec.rb +0 -77
- data/spec/nanoc/base/services/compiler/stages/cleanup_spec.rb +65 -1
- data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +141 -0
- data/spec/nanoc/base/services/item_rep_selector_spec.rb +16 -1
- data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +3 -3
- data/spec/nanoc/data_sources/filesystem_spec.rb +23 -11
- metadata +16 -3
@@ -0,0 +1,141 @@
|
|
1
|
+
describe Nanoc::Int::Compiler::Stages::CompileReps do
|
2
|
+
let(:stage) do
|
3
|
+
described_class.new(
|
4
|
+
outdatedness_store: outdatedness_store,
|
5
|
+
dependency_store: dependency_store,
|
6
|
+
action_provider: action_provider,
|
7
|
+
compilation_context: compilation_context,
|
8
|
+
compiled_content_cache: compiled_content_cache,
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:compilation_context) do
|
13
|
+
Nanoc::Int::Compiler::CompilationContext.new(
|
14
|
+
action_provider: action_provider,
|
15
|
+
reps: reps,
|
16
|
+
site: site,
|
17
|
+
compiled_content_cache: compiled_content_cache,
|
18
|
+
snapshot_repo: snapshot_repo,
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:action_provider) { double(:action_provider) }
|
23
|
+
let(:reps) { Nanoc::Int::ItemRepRepo.new }
|
24
|
+
let(:compiled_content_cache) { Nanoc::Int::CompiledContentCache.new(items: items) }
|
25
|
+
let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
|
26
|
+
|
27
|
+
let(:outdatedness_store) { Nanoc::Int::OutdatednessStore.new(site: site, reps: reps) }
|
28
|
+
let(:dependency_store) { Nanoc::Int::DependencyStore.new(items.to_a) }
|
29
|
+
|
30
|
+
let(:rep) { Nanoc::Int::ItemRep.new(item, :default) }
|
31
|
+
let(:item) { Nanoc::Int::Item.new('<%= 1 + 2 %>', {}, '/hi.md') }
|
32
|
+
|
33
|
+
let(:other_rep) { Nanoc::Int::ItemRep.new(other_item, :default) }
|
34
|
+
let(:other_item) { Nanoc::Int::Item.new('other content', {}, '/other.md') }
|
35
|
+
|
36
|
+
let(:site) do
|
37
|
+
Nanoc::Int::Site.new(
|
38
|
+
config: config,
|
39
|
+
code_snippets: code_snippets,
|
40
|
+
items: items,
|
41
|
+
layouts: layouts,
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
46
|
+
let(:layouts) { [] }
|
47
|
+
let(:code_snippets) { [] }
|
48
|
+
|
49
|
+
let(:items) do
|
50
|
+
Nanoc::Int::IdentifiableCollection.new(config).tap do |col|
|
51
|
+
col << item
|
52
|
+
col << other_item
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:memory) do
|
57
|
+
actions =
|
58
|
+
[
|
59
|
+
Nanoc::Int::ProcessingActions::Filter.new(:erb, {}),
|
60
|
+
Nanoc::Int::ProcessingActions::Snapshot.new(:last, nil),
|
61
|
+
]
|
62
|
+
|
63
|
+
Nanoc::Int::RuleMemory.new(nil, actions: actions)
|
64
|
+
end
|
65
|
+
|
66
|
+
before do
|
67
|
+
reps << rep
|
68
|
+
reps << other_rep
|
69
|
+
|
70
|
+
reps.each do |rep|
|
71
|
+
rep.snapshot_defs << Nanoc::Int::SnapshotDef.new(:last)
|
72
|
+
end
|
73
|
+
|
74
|
+
allow(action_provider).to receive(:memory_for).with(rep).and_return(memory)
|
75
|
+
allow(action_provider).to receive(:memory_for).with(other_rep).and_return(memory)
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#compile_reps' do
|
79
|
+
subject { stage.run }
|
80
|
+
|
81
|
+
before do
|
82
|
+
allow(action_provider).to receive(:snapshots_defs_for).with(rep).and_return(snapshot_defs_for_rep)
|
83
|
+
allow(action_provider).to receive(:snapshots_defs_for).with(other_rep).and_return(snapshot_defs_for_rep)
|
84
|
+
end
|
85
|
+
|
86
|
+
let(:snapshot_defs_for_rep) do
|
87
|
+
[Nanoc::Int::SnapshotDef.new(:last)]
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:snapshot_defs_for_other_rep) do
|
91
|
+
[Nanoc::Int::SnapshotDef.new(:last)]
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'rep not in outdatedness store' do
|
95
|
+
it 'keeps the item rep out of the outdatedness store' do
|
96
|
+
expect(outdatedness_store.include?(rep)).not_to be
|
97
|
+
expect { subject }.not_to change { outdatedness_store.include?(rep) }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'rep in outdatedness store' do
|
102
|
+
before { outdatedness_store.add(rep) }
|
103
|
+
|
104
|
+
it 'compiles individual reps' do
|
105
|
+
expect { subject }.to change { snapshot_repo.get(rep, :last) }
|
106
|
+
.from(nil)
|
107
|
+
.to(some_textual_content('3'))
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'removes the item rep from the outdatedness store' do
|
111
|
+
expect { subject }.to change { outdatedness_store.include?(rep) }.from(true).to(false)
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'exception' do
|
115
|
+
let(:item) { Nanoc::Int::Item.new('<%= raise "lol" %>', {}, '/hi.md') }
|
116
|
+
|
117
|
+
it 'wraps exception' do
|
118
|
+
expect { subject }.to raise_error(Nanoc::Int::Errors::CompilationError)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'contains the right item rep in the wrapped exception' do
|
122
|
+
expect { subject }.to raise_error do |err|
|
123
|
+
expect(err.item_rep).to eql(rep)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'contains the right wrapped exception' do
|
128
|
+
expect { subject }.to raise_error do |err|
|
129
|
+
expect(err.unwrap).to be_a(RuntimeError)
|
130
|
+
expect(err.unwrap.message).to eq('lol')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'keeps the item rep in the outdatedness store' do
|
135
|
+
expect(outdatedness_store.include?(rep)).to be
|
136
|
+
expect { subject rescue nil }.not_to change { outdatedness_store.include?(rep) }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -147,7 +147,7 @@ describe Nanoc::Int::ItemRepSelector do
|
|
147
147
|
|
148
148
|
example do
|
149
149
|
expect(successfully_yielded).to eq [:b, :c, :d, :e, :a]
|
150
|
-
expect(tentatively_yielded).to eq [:a, :b, :c, :d, :e, :a]
|
150
|
+
expect(tentatively_yielded).to eq [:a, :b, :a, :c, :a, :d, :a, :e, :a]
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -165,5 +165,20 @@ describe Nanoc::Int::ItemRepSelector do
|
|
165
165
|
expect(tentatively_yielded).to eq [:a, :b, :a, :c, :a, :d, :a, :e, :a]
|
166
166
|
end
|
167
167
|
end
|
168
|
+
|
169
|
+
context 'unrelated roots' do
|
170
|
+
let(:dependencies) do
|
171
|
+
{
|
172
|
+
a: [:d],
|
173
|
+
b: [:e],
|
174
|
+
c: [],
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'picks prioritised roots' do
|
179
|
+
expect(successfully_yielded).to eq [:d, :a, :e, :b, :c]
|
180
|
+
expect(tentatively_yielded).to eq [:a, :d, :a, :b, :e, :b, :c]
|
181
|
+
end
|
182
|
+
end
|
168
183
|
end
|
169
184
|
end
|
@@ -27,7 +27,7 @@ describe Nanoc::CLI::Commands::Compile::TimingRecorder, stdio: true do
|
|
27
27
|
Nanoc::Int::NotificationCenter.post(:filtering_ended, rep, :erb)
|
28
28
|
|
29
29
|
expect { listener.stop }
|
30
|
-
.to output(/^erb \| 1
|
30
|
+
.to output(/^erb \| 1 1\.00s 1\.00s 1\.00s 1\.00s$/).to_stdout
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'records multiple from filtering_started to filtering_ended' do
|
@@ -43,7 +43,7 @@ describe Nanoc::CLI::Commands::Compile::TimingRecorder, stdio: true do
|
|
43
43
|
Nanoc::Int::NotificationCenter.post(:filtering_ended, rep, :erb)
|
44
44
|
|
45
45
|
expect { listener.stop }
|
46
|
-
.to output(/^erb \| 2
|
46
|
+
.to output(/^erb \| 2 1\.00s 1\.50s 2\.00s 3\.00s$/).to_stdout
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'records single from filtering_started over compilation_{suspended,started} to filtering_ended' do
|
@@ -61,6 +61,6 @@ describe Nanoc::CLI::Commands::Compile::TimingRecorder, stdio: true do
|
|
61
61
|
|
62
62
|
# FIXME: wrong count (should be 1, not 2)
|
63
63
|
expect { listener.stop }
|
64
|
-
.to output(/^erb \| 2
|
64
|
+
.to output(/^erb \| 2 1\.00s 2\.50s 4\.00s 5\.00s$/).to_stdout
|
65
65
|
end
|
66
66
|
end
|
@@ -47,20 +47,32 @@ describe Nanoc::DataSources::Filesystem do
|
|
47
47
|
expect(subject[0].attributes).to eq(expected_attributes)
|
48
48
|
expect(subject[0].identifier).to eq(Nanoc::Identifier.new('/bar/'))
|
49
49
|
expect(subject[0].checksum_data).to be_nil
|
50
|
-
expect(subject[0].
|
50
|
+
expect(subject[0].attributes_checksum_data).to be_a(String)
|
51
|
+
expect(subject[0].attributes_checksum_data.size).to eq(20)
|
52
|
+
expect(subject[0].content_checksum_data).to be_a(String)
|
53
|
+
expect(subject[0].content_checksum_data.size).to eq(20)
|
51
54
|
end
|
52
55
|
|
53
|
-
|
54
|
-
|
56
|
+
context 'split files' do
|
57
|
+
let(:block) do
|
58
|
+
lambda do
|
59
|
+
FileUtils.mkdir_p('foo')
|
55
60
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
File.write('foo/bar.html', 'test 1')
|
62
|
+
FileUtils.touch('foo/bar.html', mtime: now)
|
63
|
+
|
64
|
+
File.write('foo/bar.yaml', "---\nnum: 1\n")
|
65
|
+
FileUtils.touch('foo/bar.yaml', mtime: now)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'has a different attributes checksum' do
|
70
|
+
expect(block).to change { data_source.send(:load_objects, 'foo', klass)[0].attributes_checksum_data }
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'has the same content checksum' do
|
74
|
+
expect(block).not_to change { data_source.send(:load_objects, 'foo', klass)[0].content_checksum_data }
|
75
|
+
end
|
64
76
|
end
|
65
77
|
end
|
66
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.6.
|
4
|
+
version: 4.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -176,6 +176,18 @@ files:
|
|
176
176
|
- lib/nanoc/base/services/action_provider.rb
|
177
177
|
- lib/nanoc/base/services/checksummer.rb
|
178
178
|
- lib/nanoc/base/services/compiler.rb
|
179
|
+
- lib/nanoc/base/services/compiler/phases.rb
|
180
|
+
- lib/nanoc/base/services/compiler/phases/cache.rb
|
181
|
+
- lib/nanoc/base/services/compiler/phases/mark_done.rb
|
182
|
+
- lib/nanoc/base/services/compiler/phases/recalculate.rb
|
183
|
+
- lib/nanoc/base/services/compiler/phases/resume.rb
|
184
|
+
- lib/nanoc/base/services/compiler/phases/write.rb
|
185
|
+
- lib/nanoc/base/services/compiler/stages.rb
|
186
|
+
- lib/nanoc/base/services/compiler/stages/cleanup.rb
|
187
|
+
- lib/nanoc/base/services/compiler/stages/compile_reps.rb
|
188
|
+
- lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb
|
189
|
+
- lib/nanoc/base/services/compiler/stages/preprocess.rb
|
190
|
+
- lib/nanoc/base/services/compiler/stages/prune.rb
|
179
191
|
- lib/nanoc/base/services/compiler_loader.rb
|
180
192
|
- lib/nanoc/base/services/dependency_tracker.rb
|
181
193
|
- lib/nanoc/base/services/executor.rb
|
@@ -354,6 +366,7 @@ files:
|
|
354
366
|
- spec/nanoc/base/repos/store_spec.rb
|
355
367
|
- spec/nanoc/base/services/compiler/phases/cache_spec.rb
|
356
368
|
- spec/nanoc/base/services/compiler/stages/cleanup_spec.rb
|
369
|
+
- spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb
|
357
370
|
- spec/nanoc/base/services/dependency_tracker_spec.rb
|
358
371
|
- spec/nanoc/base/services/executor_spec.rb
|
359
372
|
- spec/nanoc/base/services/item_rep_router_spec.rb
|
@@ -568,7 +581,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
568
581
|
version: '0'
|
569
582
|
requirements: []
|
570
583
|
rubyforge_project:
|
571
|
-
rubygems_version: 2.6.
|
584
|
+
rubygems_version: 2.6.10
|
572
585
|
signing_key:
|
573
586
|
specification_version: 4
|
574
587
|
summary: A static-site generator with a focus on flexibility.
|