ãã¼ã«ã«å¤æ°éé¢ãã¦eval
ãã¼ã«ã«å¤æ°ã"cpp"(ã¨"_erbout")ã ãã®æ°è¦ã¹ã³ã¼ããä½ã£ã¦ããã§evalãããã£ãã
ç¾å¨ã®å®è£ ã§ã¯ã¡ã½ããå ã¡ã½ãããå®ç¾©ãã¦ãã£ã¦ããã®bindingã§evalãã¦ã¾ãã
ãã£ã¨ããæ¸ãæ¹ãããã°æãã¦ãã ããã
http://websvn.nyaxtstep.com/viewvc.cgi/configpp/configpp.rb
ConfigPP::ConfigPP.processæç²ã
# second pass : actually parse the file using erb out_filename = @out_filename ? @out_filename : filename def evalenv cpp = ConfigPPRuntime.new(@options) binding end erb = ERB.new(File.readlines(filepath), nil, @erb_trimming) erb.filename = File.basename(filepath) puts erb.result(evalenv)
追è¨ï¼
åçã«æ°è¦ã¯ã©ã¹ãä½ãããã«ãã¦ãcppãã¯ã©ã¹å¤æ°ã«ããã°ãããããããªãã試ãã
ãããªæãã«ãªã£ãã
# second pass : actually parse the file using erb out_filename = @out_filename ? @out_filename : filename evalenvklass = Class.new erb = ERB.new(File.readlines(filepath), nil, @erb_trimming) erb.def_method(evalenvklass, '_process', File.basename(filepath)) options = @options evalenv = evalenvklass.new evalenv.instance_eval do @cpp = ConfigPPUtil.new(filename, versioninfo, options) end puts evalenv._process