Sha256: 84348312283f06edf296149b089a72d0a9f2f941d1287de48bcfa26f2d860a7b
Contents?: true
Size: 752 Bytes
Versions: 6
Compression:
Stored size: 752 Bytes
Contents
#!/usr/bin/env ruby # see instructions in the readme for use require 'optparse' require 'shellwords' argv = Shellwords.split(ENV['COMP_LINE']).drop 1 options = {} begin OptionParser.new do |opts| opts.on("-n", "--name [METHOD]", "Test method") do |m| options[:method] = m end end.parse!(argv) rescue retry # ignore options passed to Ruby end file = argv.find { |f| File.file?(f) && !File.directory?(f) } exit unless options.key?(:method) && file require 'ripper' methods = [] K = Class.new(Ripper) { define_method(:on_def) { |n,_,_| methods << n } } begin K.parse File.read(file), file, 1 methods = methods.grep(/^#{options[:method]}/) if options[:method] puts methods.join("\n") rescue # give up on parse errors end
Version data entries
6 entries across 6 versions & 1 rubygems