#!/usr/bin/env ruby target = (__FILE__).gsub(/_small/, '') CONFIG_FILE = 'plot_config.rb' config = { :SMALL_PLOT => '1, 0.6' } if FileTest::exist?(CONFIG_FILE) then puts "CONFIG_FILE ON!" eval(open(CONFIG_FILE).read) end script = '' on_modified_target = false open(target).each{|line| if line =~ /def Plotter::plot file_name/ then on_modified_target = true script += <<-'__STRING__' def Plotter::plot file_name Gnuplot.open{|gp| Gnuplot::Plot::new(gp){|plot| file_name.gsub!(/\.eps/, '_small.eps') puts "drawing #{file_name} ..." plot.terminal "postscript eps enhanced color" plot.output file_name __STRING__ script += <<-__STRING__ plot.set('size', '#{config[:SMALL_PLOT]}') __STRING__ script += <<-'__STRING__' yield plot } } end __STRING__ next elsif on_modified_target then if line =~ /end/ then on_modified_target = false end next end script += line } #puts script eval(script)