bin/coypond in coypond-0.1.1 vs bin/coypond in coypond-0.2.0

- old
+ new

@@ -29,20 +29,37 @@ 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? -coypond = Coypond::CoypondRunner.new($*) -results = coypond.search(options) +def expand(file, pattern=["**"]) + if File.directory?(file) + return Dir.glob(File.join(file, *pattern, '*.rb') ) + else + return file + end +end -results.each do |file_name, res| +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 \ No newline at end of file