Created
June 7, 2012 04:37
-
-
Save pluskid/2886598 to your computer and use it in GitHub Desktop.
rules for rake-pipeline of my blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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