Domain specific OptionParser extensions
# File lib/rcodetools/options.rb, line 86 86: def auto_include_paths(include_paths, pwd) 87: if pwd =~ %^(.+)/(lib|bin)! 88: include_paths.unshift("#$1/lib").unshift("#$1/bin") 89: elsif File.file? "#{pwd}/Rakefile" or File.file? "#{pwd}/rakefile" 90: include_paths.unshift("#{pwd}/lib").unshift("#{pwd}/bin") 91: end 92: end
# File lib/rcodetools/options.rb, line 30 30: def handle_interpreter(options) 31: separator "" 32: separator "Interpreter options:" 33: on("-S FILE", "--interpreter FILE", "Use interpreter FILE.") do |interpreter| 34: options[:interpreter] = interpreter 35: end 36: on("-I PATH", "Add PATH to $LOAD_PATH") do |path| 37: options[:include_paths] << path 38: end 39: on("--dev", "Add this project's bin/ and lib/ to $LOAD_PATH.", 40: "A directory with a Rakefile is considered a project base directory.") do 41: auto_include_paths(options[:include_paths], Dir.pwd) 42: end 43: on("-r LIB", "Require LIB before execution.") do |lib| 44: options[:libs] << lib 45: end 46: on("-e EXPR", "--eval=EXPR", "--stub=EXPR", "Evaluate EXPR after execution.") do |expr| 47: options[:evals] << expr 48: end 49: on("--fork", "Use rct-fork-client if rct-fork is running.") do 50: options[:detect_rct_fork] = true 51: end 52: on("--rbtest", "Use rbtest.") do 53: options[:use_rbtest] = true 54: end 55: on("--detect-rbtest", "Use rbtest if '=begin test_*' blocks exist.") do 56: options[:detect_rbtest] = true 57: end 58: end
# File lib/rcodetools/options.rb, line 60 60: def handle_misc(options) 61: separator "" 62: separator "Misc options:" 63: on("--cd DIR", "Change working directory to DIR.") do |dir| 64: options[:wd] = dir 65: end 66: on("--debug", "Write transformed source code to xmp-tmp.PID.rb.") do 67: options[:dump] = "xmp-tmp.#{Process.pid}.rb" 68: end 69: on("--tmpfile", "--tempfile", "Use tmpfile instead of open3. (non-windows)") do 70: options[:execute_ruby_tmpfile] = true 71: end 72: on("-w N", "--width N", Integer, "Set width of multi-line annotation. (xmpfilter only)") do |width| 73: options[:width] = width 74: end 75: separator "" 76: on("-h", "--help", "Show this message") do 77: puts self 78: exit 79: end 80: on("-v", "--version", "Show version information") do 81: puts "#{File.basename($0)} #{XMPFilter::VERSION}" 82: exit 83: end 84: end
# File lib/rcodetools/options.rb, line 10 10: def handle_position(options) 11: separator "" 12: separator "Position options:" 13: on("--line=LINE", "Current line number.") do |n| 14: options[:lineno] = n.to_i 15: end 16: on("--column=COLUMN", "Current column number in BYTE.") do |n| 17: options[:column] = n.to_i 18: end 19: on("-t TEST", "--test=TEST", 20: "Execute test script. ", 21: "TEST is TESTSCRIPT, TESTSCRIPT@TESTMETHOD, or TESTSCRIPT@LINENO.", 22: "You must specify --filename option.") do |t| 23: options[:test_script], options[:test_method] = t.split(/@/) 24: end 25: on("--filename=FILENAME", "Filename of standard input.") do |f| 26: options[:filename] = f 27: end 28: end
# File lib/rcodetools/options.rb, line 86 86: def auto_include_paths(include_paths, pwd) 87: if pwd =~ %^(.+)/(lib|bin)! 88: include_paths.unshift("#$1/lib").unshift("#$1/bin") 89: elsif File.file? "#{pwd}/Rakefile" or File.file? "#{pwd}/rakefile" 90: include_paths.unshift("#{pwd}/lib").unshift("#{pwd}/bin") 91: end 92: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.