Skip to content

Instantly share code, notes, and snippets.

@pluskid
Created June 7, 2012 04:37
Show Gist options
  • Save pluskid/2886598 to your computer and use it in GitHub Desktop.
Save pluskid/2886598 to your computer and use it in GitHub Desktop.
rules for rake-pipeline of my blog
# vim: filetype=ruby
output "compiled/files"
class AsyFilter < Rake::Pipeline::Filter
attr_accessor :config
def initialize
@output_name_generator = proc { |fn, wrap|
@config = {'ext' => 'png', 'opt' => ''}
/^---$(.*?)^---$/m.match(wrap.read) do
require 'yaml'
config.merge!(YAML::load($1))
end
ext = config['ext']
fn.sub(/\.[^.]+$/, '.' + ext)
}
end
def generate_output(inputs, output)
system("asy #{config['opt']} -f #{config['ext']} -o " +
File.join(output.root,output.path) + " " +
File.join(inputs[0].root, inputs[0].path))
end
end
input "files" do
match '**/*.asy' do
filter AsyFilter
end
filter Rake::Pipeline::ConcatFilter
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment