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

Fix fetching text content of now-binary item rep #1036

Merged
merged 1 commit into from Dec 24, 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
13 changes: 7 additions & 6 deletions lib/nanoc/base/entities/item_rep.rb
Expand Up @@ -64,11 +64,6 @@ def binary?
# @return [String] The compiled content at the given snapshot (or the
# default snapshot if no snapshot is specified)
def compiled_content(snapshot: nil)
# Make sure we're not binary
if binary?
raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(self)
end

# Get name of last pre-layout snapshot
snapshot_name = snapshot || (@snapshot_contents[:pre] ? :pre : :last)
is_moving = [:pre, :post, :last].include?(snapshot_name)
Expand All @@ -93,7 +88,13 @@ def compiled_content(snapshot: nil)
return compiled_content(snapshot: snapshot)
end

@snapshot_contents[snapshot_name].string
# Verify snapshot is not binary
snapshot_content = @snapshot_contents[snapshot_name]
if snapshot_content.binary?
raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(self)
end

snapshot_content.string
end

contract Symbol => C::Bool
Expand Down