Sha256: 723fe30eaee83e8df604ab51f940d40278d4bf508054415a309074b1e0772fc5
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
#!/usr/bin/env ruby require 'coypond' def print_help puts "Usage:" puts " coypond search_term [options] file1 [file2 [file3 [...]]]" puts "" puts "Options:" puts " -m search method names" puts " -c search class names" puts " -M search Module names" puts " -a search all available type names (default: true unless another search option was given)" end if $*.first == "-h" || $*.first == "--help" print_help exit(0) end options = {:search_term => $*.shift} while !$*.empty? and $*.first.start_with?("-") option = $*.shift case option when "-r" options[:regexp] = true when "-i" options[:ignore_case] = true when "-m" options[:method] = true when "-c" options[:class] = true when "-M" options[:module] = true when "-g" options[:gem] = $*.shift when "-a" options[:all] = true end end options[:all] ||= (options.keys & [:class, :method, :module]).empty? def expand(file, pattern=["**"]) if File.directory?(file) return Dir.glob(File.join(file, *pattern, '*.rb') ) else return file end end files = [] if options[:gem] ENV["GEM_PATH"].split(":").each do |path| files += expand(path, ["gems", "#{options[:gem]}*", "**"]) end else files = $*.map {|file| expand(file)}.flatten end coypond = Coypond::CoypondRunner.new(files) coypond.search(options) do |file_name, res| unless res.empty? puts "#{file_name}:" res.each do |dec, location, context| puts " #{location.join(",")}: #{context.strip}" end puts "" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
coypond-0.2.0 | bin/coypond |