标签:back 名称 解释 内容 pop class arc hit ant
https://github.com/adamsanderson/qwandry
qwandry 能高速定位到我们须要找到 库文件, 项目 的工具。
Ruby中实现高速定位的方法有好多种。我知道的有三个:
cd `bundle show activerecord`
gem install 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
touch ~/.qwandry/init.rb
register ‘projects‘ do add ‘your project path‘ end default :ruby, :gem, :projects
qwandry中比較重要的几个类
是一个基类,职责是存储全部的能够搜索的库文件夹和名称. 继承与它的子类必须实现 scan 方法。
它有两个子类: LibraryRepository 和 FlatRepository
是一个用于配置搜索库的文件夹的类,能够动态的加入新的搜索路径。 实现的方法比較track, 用的是万恶得 eval 方法。
是用于打开指定文件夹的关键类。它有两个关键方法: find 和 launch
find方法的实现
# Searches all of the loaded repositories for `name` def find(*pattern) # Create a glob pattern from the user‘s input, for instance # ["rails","2.3"] => "rails*2.3*" pattern = pattern.join(‘*‘) pattern << ‘*‘ unless pattern =~ /\*$/ packages = [] repositories = Qwandry::Configuration.repositories repositories.each do |repo| packages.concat(repo.scan(pattern)) end differentiate packages packages end
launch 方法的实现
# Launches a Package or path represented by a String. Unless `editor` will # check against the environment by default. def launch(package, editor=nil) editor ||= @editor || ENV[‘QWANDRY_EDITOR‘] || ENV[‘VISUAL‘] || ENV[‘EDITOR‘] if (!editor) || (editor =~ /^\s*$/) # if the editor is not set, or is blank, exit with a message: puts "Please set QWANDRY_EDITOR, VISUAL or EDITOR, or pass in an editor to use" exit 1 end paths = package.is_a?(String) ? [package] : package.paths # Editors may have options, ‘mate -w‘ for instance editor_and_options = editor.strip.split(/\s+/) Dir.chdir(File.dirname paths.first) do # Launch the editor with its options and any paths that we have been passed system(*(editor_and_options + paths)) end end
system(*(editor_and_options + paths))
标签:back 名称 解释 内容 pop class arc hit ant
原文地址:http://www.cnblogs.com/slgkaifa/p/6991069.html