Advertisement
Guest User

LD25 Rakefile

a guest
Dec 12th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.69 KB | None | 0 0
  1. def generate(from_ext, to_ext, &block)
  2.   Dir["*#{from_ext}"].each do |from|
  3.     to = File.basename(from, from_ext) + to_ext
  4.     file to => [from] do
  5.       case block.arity
  6.       when 1
  7.         block.call from
  8.       when 2
  9.         block.call from, to
  10.       else
  11.         raise 'Block should take 1 or 2 arguments'
  12.       end
  13.     end
  14.   end
  15. end
  16.  
  17. generate '.coffee', '.js' do |from, to|
  18.   sh "coffee -c #{from}"
  19. end
  20.  
  21. generate '.svg', '.png' do |from, to|
  22.   sh "/usr/bin/inkscape --without-gui --export-png=#{to} --export-area-page #{from}"
  23. end
  24.  
  25. generate '.scss', '.css' do |from, to|
  26.   sh "compass compile --quiet --sass-dir . --css-dir . #{from}"
  27. end
  28.  
  29. task :default => Rake::Task::tasks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement