GitHub地址:https://github.com/adamsanderson/qwandry
qwandry 能快速定位到我們需要找到 庫文件, 項目 的工具。
Ruby中實現快速定位的方法有好多種,我知道的有三個:
cd `bundle show active_record`
通過tag方法(tag 定位更精確,可以定位到方法級別)
或者通過 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
指定編輯器打開
EDITOR=subl qw activerecord 3.2.14
如何自定義?
然后copy如下內容到文件中
register 'projects' do
add 'your project path'
end
default :ruby, :gem, :projects
解釋
register 方法是 將指定的目錄打包
add 將目錄加入到搜索中
default 是設置默認的搜索范圍
實現的基本原理
通過配置 config 將很多目錄打包成 Package, 然后將 Package 打包成 Repository(倉庫)
初始化一個Launcher(有Editor等)
根據輸入的名稱找到對應的Repository中的package(實際上是一個目錄地址)
執行系統命令: editor(vim) path