Created
October 23, 2010 09:20
-
-
Save denisdefreyne/641990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Nanoc3::Filters | |
class Tar < Nanoc3::Filter | |
type :text => :binary | |
identifier :tar | |
def run(filename, params={}) | |
# Stores the filenames of all reps to include | |
filenames = [] | |
# For each item to include (as identifier) | |
@item[:identifiers].each do |identifier| | |
# Find the default representation (you could pick another one too) | |
rep = @items.find { |i| i.identifier == identifier }.rep_named(:default) | |
# Notify to create a dependency | |
Nanoc3::NotificationCenter.post(:visit_started, rep.item) | |
Nanoc3::NotificationCenter.post(:visit_ended, rep.item) | |
# Raise unmet dependency error if item is not yet compiled | |
raise Nanoc3::Errors::UnmetDependency.new(rep) if !rep.compiled? | |
# Add it to list of files to tar | |
filenames << rep.raw_path | |
end | |
# Tar | |
system('tar', '-c', '-j', '-f', output_filename, *filenames) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment