GitHub地址:https://github.com/adamsanderson/qwandry
qwandry 能快速定位到我們需要找到 庫(kù)文件, 項(xiàng)目 的工具。
Ruby中實(shí)現(xiàn)快速定位的方法有好多種,我知道的有三個(gè):
cd `bundle show active_record`
通過(guò)tag方法(tag 定位更精確,可以定位到方法級(jí)別)
或者通過(guò) qwandry
安裝
使用
qw matrix # opens ruby's matrix class in your editor
qw rails # will ask you which version of rails you want to open
qw activerec 3.1 # will find the gem activerecord 3.1 and open it
You can also use Qwandry with other common languages:
qw -r python numpy # opens python's numpy library
qw -r perl URI # open perl's URI library
qw -r node express # open express if it is installed for node
指定編輯器打開(kāi)
EDITOR=subl qw activerecord 3.2.14
如何自定義?
然后copy如下內(nèi)容到文件中
register 'projects' do
add 'your project path'
end
default :ruby, :gem, :projects
解釋
register 方法是 將指定的目錄打包
add 將目錄加入到搜索中
default 是設(shè)置默認(rèn)的搜索范圍
實(shí)現(xiàn)的基本原理
通過(guò)配置 config 將很多目錄打包成 Package, 然后將 Package 打包成 Repository(倉(cāng)庫(kù))
初始化一個(gè)Launcher(有Editor等)
根據(jù)輸入的名稱找到對(duì)應(yīng)的Repository中的package(實(shí)際上是一個(gè)目錄地址)
執(zhí)行系統(tǒng)命令: editor(vim) path