Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment