preparation*: | def untabify(str, width=8) list = str.split(/\t/) last = list.pop sb = '' list.each do |s| column = (n = s.rindex(?\n)) ? s.length - n - 1 : s.length n = width - (column % width) sb << s << (' ' * n) end sb << last return sb end properties: - tagfile : html-css parameters: - u : users-guide - all : [ $(u).html ] recipes: - product: :default ingreds: [ :all ] - product: :doc ingreds: [ users-guide.html ] - product: :clear method*: | rm_rf 'guide.d', '*.html' - product: :clean method*: | rm_rf 'guide.d', '*.toc.html' - product: :all ingreds: [ $(all) ] - product: $(u).html ingreds: [ $(u).txt ] byprods: [ $(u).toc.html ] method*: | dir = "../test/data/$(u)" mkdir_p dir rm_rf "#{dir}/*" sys "retrieve -d #{dir} #{@ingred}" for filename in Dir.glob("#{dir}/*.*_filter") content = File.read(filename) name = (filename =~ /\.(\w+)_filter$/) && $1 case name when 'comment' content.gsub!(/\s*\#.*$/, '') fname = filename.sub(/\.comment_filter$/, '') File.open(fname, 'w') {|f| f.write(content) } when 'split' contents = content.split(/^\$ /).select{|s| !s.empty?}.collect{|s| '$ '+s} i = 0 for cont in contents i += 1 fname = filename.sub(/\.(\w+).(\w+)_filter$/, "#{i}.\\1") File.open(fname, 'w') { |f| f.write(cont) } end end File.unlink(filename) end sys "kwaser -t $(tagfile) -T #{@ingred} > #{@byprod}" sys "kwaser -t $(tagfile) #{@ingred} > #{@product}" rm "#{@byprod}" - product: :test ingreds: [ $(u).html ] method*: | currdir = Dir.pwd chdir '../test' do sys 'ruby test-users-guide.rb' end - product: notext.txt ingreds: [ ../test/test-notext.yaml, Rookbook.yaml ] desc: create 'notext.txt' from 'test-notext.yaml' method*: | require 'yaml' s = untabify(File.read(@ingred)) list = [] YAML.load_documents(s) { |ydoc| list << ydoc } list.flatten! entry = list.first ydoc = {} list.each do |hash| %w[input output].each do |key| hash[key].gsub!(/^\./, '') if hash.key?(key) end ydoc[hash['name']] = hash end text = entry['document'] require 'erubis' eruby = Erubis::Eruby.new(text, :pattern=>'\[% %\]') #p ydoc.keys #puts eruby.src result = eruby.result(binding()) File.open(@product, 'w') { |f| f.write(result) }