1 首先在ruby根路径下面的bin目录建立2个文件: yanzilee9292和yanzilee9292.bat。
yanzilee9292.bat文件:
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
yanzilee9292文件:
#!C:/Ruby192/bin/ruby.exe
#
# This file was generated by RubyGems.
#
# The application 'ruby-debug-ide19' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
puts "yanzilee9292 test"
load ARGV.shift
2 编写一个文件test.rb来测试
puts "testing"
3 用自定义命令运行test.rb
D:\test>yanzilee9292 test.rb
yanzilee9292 test
testing
可以看出, 本质上还是用的ruby命令来运行。 通过ruby语言的灵活的特性, 可以扩展很多类的方法来实现一个自定义的gem, 比如rspec,rdebug...
有兴趣大家可以继续补充哈