Guest User

Untitled

a guest
Oct 18th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # vim: filetype=ruby
  2. output "compiled/files"
  3.  
  4. class AsyFilter < Rake::Pipeline::Filter
  5. attr_accessor :config
  6.  
  7. def initialize
  8. @output_name_generator = proc { |fn, wrap|
  9. @config = {'ext' => 'png', 'opt' => ''}
  10.  
  11. /^---$(.*?)^---$/m.match(wrap.read) do
  12. require 'yaml'
  13. config.merge!(YAML::load($1))
  14. end
  15. ext = config['ext']
  16. fn.sub(/\.[^.]+$/, '.' + ext)
  17. }
  18. end
  19.  
  20. def generate_output(inputs, output)
  21. system("asy #{config['opt']} -f #{config['ext']} -o " +
  22. File.join(output.root,output.path) + " " +
  23. File.join(inputs[0].root, inputs[0].path))
  24. end
  25. end
  26.  
  27. input "files" do
  28. match '**/*.asy' do
  29. filter AsyFilter
  30. end
  31.  
  32. filter Rake::Pipeline::ConcatFilter
  33. end
Add Comment
Please, Sign In to add comment