Guest User

Untitled

a guest
Jun 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. module Nanoc3::Filters
  2. class Tar < Nanoc3::Filter
  3.  
  4. type :text => :binary
  5. identifier :tar
  6.  
  7. def run(filename, params={})
  8. # Stores the filenames of all reps to include
  9. filenames = []
  10.  
  11. # For each item to include (as identifier)
  12. @item[:identifiers].each do |identifier|
  13. # Find the default representation (you could pick another one too)
  14. rep = @items.find { |i| i.identifier == identifier }.rep_named(:default)
  15.  
  16. # Notify to create a dependency
  17. Nanoc3::NotificationCenter.post(:visit_started, rep.item)
  18. Nanoc3::NotificationCenter.post(:visit_ended, rep.item)
  19.  
  20. # Raise unmet dependency error if item is not yet compiled
  21. raise Nanoc3::Errors::UnmetDependency.new(rep) if !rep.compiled?
  22.  
  23. # Add it to list of files to tar
  24. filenames << rep.raw_path
  25. end
  26.  
  27. # Tar
  28. system('tar', '-c', '-j', '-f', output_filename, *filenames)
  29. end
  30.  
  31. end
  32. end
Add Comment
Please, Sign In to add comment