<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/local/bin/perl
#
# rt-class-map.pl
#
# Created: 09/28/05 17:54:15 EDT by Andy Harrison
#
#
# Inspect RT's libraries and show a the details of their classes.
#
#
# Usage:
#        rt-class-map.pl [--lib /path/to/libs] [--rt /path/to/rthome]
#                        [--module RT::Module] [--all]
#                        [--verbose]
#
# $Id: rt-class-map.pl,v 1.3 2005/09/29 17:13:34 ajharrison Exp $

use strict;
use warnings;

$|++;

local $main::VERSION =
    '$Id: rt-class-map.pl,v 1.3 2005/09/29 17:13:34 ajharrison Exp $';

# 
# Unless specified on the commandline, this will 
# be the default RT Home directory.
#
use constant RTHOME =&gt; '/usr/local/rt3';
use vars     qw/$rt/;

use File::Find;
use Data::Dumper;
use Getopt::Long;
use Class::Inspector;

my %opts;
GetOptions( \%opts, 'all'
                  , 'module=s@'
                  , 'rt=s'
                  , 'lib=s@'
                  , 'verbose'
          );

#
# Where do dwell the RT libs
#
sub libpath {
    # 
    # If not specified in the arguments, 
    # use the constant declared for rthome
    # 
    $rt = $opts{rt} ? $opts{rt}
                    : RTHOME;

    # 
    # Make sure to look in the main lib dir AND
    # the local lib dir.
    # 
    my @default_lib_path;
    push @default_lib_path, RTHOME . $_ for qw(/lib /local/lib);

    # 
    # Otherwise if the --lib argument is found,
    # we'll just use those for libs
    # 
    return $opts{lib} ? $opts{lib}
                      : @default_lib_path;
}

use lib libpath();
use RT;

#
# This makes a list of modules to inspect
#
my   @rt_libs;
push @rt_libs, @{$opts{module}} if $opts{module}; 

if ( $opts{all} ) {

    # 
    # If -all is specified on the cli, any other --module 
    # arguments are ignored and this goes into the RT 
    # directory and looks for *.pm files excluding 
    # Overlay files.
    # 
    # TODO: make this use the command line --lib arguments
    #
    find sub {
        if ( -e and $File::Find::name =~ s/[.]pm$//) {
            my $mod = substr $File::Find::name, length($File::Find::topdir)+1;
            $mod =~ s&lt;/&gt;&lt;::&gt;g;
            push @rt_libs, $mod if $mod !~ m/Overlay/;
        }
    }, $rt . "/lib";
}

# 
# This takes the list of modules and feeds them
# to the show() sub.
#

if ( $opts{verbose} ) {
    $Data::Dumper::Varname = "rt_libs_";
    print Dumper( @rt_libs );
}

my @fast = map { [ $_, show($_) ]; } @rt_libs;

print Dumper( @fast );

sub show {
    my $class = shift;
    return Class::Inspector-&gt;methods( $class, 'public', 'full' );
}

__END__

=head1 NAME

rt-class-map.pl - Inspect RT's libraries and show a the details of their classes.

=head1 SCRIPT CATEGORIES

Misc

=head1 README

I created this script because it sometimes gets confusing when trying to figure out which methods are available to different types of RT objects.

=head1 OSNAMES

any

=head1 PREREQUISITES

C&lt;Class::Inspector&gt;

=head1 COREQUISITES

none

=head1 SYNOPSIS

=head2 OPTIONS AND ARGUMENTS

B&lt;rt-class-map.pl&gt;

Choose from the following options.

=over 15

=item B&lt;[--lib&gt; I&lt;/path/to/libs&gt;B&lt;]&gt;

Explicitly specify a library directory.

=item B&lt;[--rt&gt; I&lt;/path/to/rthome&gt;B&lt;]&gt;

Specify the path to your RT installation.

=item B&lt;[--module&gt; I&lt;RT::Module&gt;B&lt;]&gt;

Name of the module you wish to inspect.

=item B&lt;[--all]&gt;

Instead of specifying a module, inspect all of the RT modules.

=item B&lt;[--verbose]&gt;

Shows which modules will be inspected.

=back

=head1 ACKNOWLEDGEMENTS

Kanji, L&lt;http://perlmonks.org/?node=Kanji&gt;, for the find sub.

Built using L&lt;Class::Inspector|http://search.cpan.org/~adamk/Class-Inspector-1.13/&gt; by Adam Kennedy L&lt;http://ali.as/&gt;, E&lt;lt&gt;L&lt;cpan@ali.as|mailto:cpan@ali.as&gt;E&lt;gt&gt;.

=head1 SEE ALSO

L&lt;Class::Inspector|http://search.cpan.org/~adamk/Class-Inspector-1.13/&gt; 

=head1 AUTHOR

Andy Harrison

 { 
   domain   =&gt; "gmail", 
   tld      =&gt; "com", 
   username =&gt; "aharrison" 
 }

=cut

</pre></body></html>