Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure dependency graph includes preprocessor items #893

Merged
merged 1 commit into from Jul 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/nanoc/base/compilation/compiler.rb
Expand Up @@ -98,6 +98,10 @@ def run
end

def load_stores
# FIXME: icky hack to update the dependency store’s list of objects
# (does not include preprocessed objects otherwise)
dependency_store.objects = site.items.to_a + site.layouts.to_a

stores.each(&:load)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nanoc/base/repos/dependency_store.rb
Expand Up @@ -2,7 +2,7 @@ module Nanoc::Int
# @api private
class DependencyStore < ::Nanoc::Int::Store
# @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout>]
attr_reader :objects
attr_accessor :objects

# @param [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] objects
def initialize(objects)
Expand Down
30 changes: 30 additions & 0 deletions spec/nanoc/regressions/gh_885_spec.rb
@@ -0,0 +1,30 @@
describe 'GH-885', site: true, stdio: true do
before do
File.write(
'content/index.html',
"<%= @items['/hello.*'].compiled_content %> - <%= Time.now.to_f %>",
)

File.write('Rules', <<EOS)
preprocess do
items.create('hi!', {}, '/hello.html')
end

compile '/**/*' do
filter :erb
write item.identifier.without_ext + '.html'
end
EOS
end

example do
Nanoc::CLI.run(%w(compile))
before = File.read('output/index.html')

sleep(0.1)
Nanoc::CLI.run(%w(compile))
after = File.read('output/index.html')
expect(after).to eql(before)
expect(after).to match(/\Ahi! - \d+/)
end
end
26 changes: 26 additions & 0 deletions spec/nanoc/regressions/gh_891_spec.rb
@@ -0,0 +1,26 @@
describe 'GH-891', site: true, stdio: true do
before do
File.write('layouts/foo.erb', 'giraffes? <%= yield %>')
File.write('Rules', <<EOS)
preprocess do
items.create('yes!', {}, '/hello.html')
end

compile '/**/*' do
layout '/foo.*'
write item.identifier.without_ext + '.html'
end

layout '/foo.*', :erb
EOS
end

example do
Nanoc::CLI.run(%w(compile))
expect(File.read('output/hello.html')).to include('giraffes?')

File.write('layouts/foo.erb', 'donkeys? <%= yield %>')
Nanoc::CLI.run(%w(compile))
expect(File.read('output/hello.html')).to include('donkeys?')
end
end