Skip to content

Commit

Permalink
fixup! Allow calling #write more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Feb 17, 2017
1 parent bef6896 commit 7e6ee04
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/nanoc/base/services/action_provider.rb
Expand Up @@ -20,7 +20,7 @@ def snapshots_defs_for(_rep)
end

def paths_for(rep)
memory_for(rep).paths
memory_for(rep).compact_snapshots.paths
end

def need_preprocessing?
Expand Down
11 changes: 11 additions & 0 deletions lib/nanoc/base/services/item_rep_router.rb
Expand Up @@ -26,9 +26,20 @@ def initialize(reps, action_provider, site)
def run
assigned_paths = {}
@reps.each do |rep|
# Sigh. We route reps twice, because the first time, the paths might not have converged
# yet. This isn’t ideal, but it’s the only way to work around the divergence issues that
# I can think of. For details, see
# https://github.com/nanoc/nanoc/pull/1085#issuecomment-280628426.

@action_provider.paths_for(rep).each do |(snapshot_names, paths)|
route_rep(rep, paths, snapshot_names, {})
end

@action_provider.paths_for(rep).each do |(snapshot_names, paths)|
route_rep(rep, paths, snapshot_names, assigned_paths)
end

# TODO: verify that paths converge
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/nanoc/base/services/item_rep_router_spec.rb
Expand Up @@ -31,8 +31,8 @@
end

example do
expect(action_provider).to receive(:paths_for).with(reps[0]).and_return(paths_0)
expect(action_provider).to receive(:paths_for).with(reps[1]).and_return(paths_1)
allow(action_provider).to receive(:paths_for).with(reps[0]).and_return(paths_0)
allow(action_provider).to receive(:paths_for).with(reps[1]).and_return(paths_1)

subject

Expand Down
4 changes: 2 additions & 2 deletions test/base/test_compiler.rb
Expand Up @@ -75,11 +75,11 @@ def test_compile_rep_should_write_proper_snapshots_real
site.compile

assert File.file?('output/moo-raw.txt')
# assert File.file?('output/moo-pre.txt')
assert File.file?('output/moo-pre.txt')
assert File.file?('output/moo-post.txt')
assert File.file?('output/moo-last.txt')
assert_equal '<%= 1 %> <%%= 2 %> <%%%= 3 %>', File.read('output/moo-raw.txt')
# assert_equal '1 2 <%= 3 %>', File.read('output/moo-pre.txt')
assert_equal '1 2 <%= 3 %>', File.read('output/moo-pre.txt')
assert_equal 'head 1 2 3 foot', File.read('output/moo-post.txt')
assert_equal 'head 1 2 3 foot', File.read('output/moo-last.txt')
end
Expand Down

0 comments on commit 7e6ee04

Please sign in to comment.