#! /usr/bin/env ruby
=begin
= ref - make list of methods
  Copyright(C) 2001 yuichi TAKAHASHI
  $Id: ref,v 1.1.1.1 2003/01/21 11:50:40 yuichi Exp $
=end
    
if ARGV.size == 0 then
  files = []
  command = File::expand_path( __FILE__ )
  pat = File::dirname( File::dirname( command ) ) + '/*.rb'
  Dir::glob( pat ).each do |file|
    files << file unless file =~ %r!/test_!
  end
  files.sort!
else
  files = ARGV
end

files.each do |file|
  open( file ).each do |line|
    if line =~ /^ *class *(\w*)/ then
      puts "  #{$1}"
      priv = false
    end
    next if priv
    case line
      when /^ *private *(\w*)/ then priv = true
      when /^ *module *(\w*)/ then puts "#{$1}(#{File::basename( file )})"
      when /^ *def *(.*)/ then puts "    #{$1}" unless $1 == 'initialize'
      when /^ *attr_(\w*) *:(.*)/ then
        typ= $1
        $2.gsub('[ ,]','').split(':').each do |attr|
          puts "    #{attr}(#{typ})"
        end
    end
  end
end
