#!/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 => '/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<::>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->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 =head1 COREQUISITES none =head1 SYNOPSIS =head2 OPTIONS AND ARGUMENTS B Choose from the following options. =over 15 =item B<[--lib> IB<]> Explicitly specify a library directory. =item B<[--rt> IB<]> Specify the path to your RT installation. =item B<[--module> IB<]> Name of the module you wish to inspect. =item B<[--all]> Instead of specifying a module, inspect all of the RT modules. =item B<[--verbose]> Shows which modules will be inspected. =back =head1 ACKNOWLEDGEMENTS Kanji, L, for the find sub. Built using L by Adam Kennedy L, ELE. =head1 SEE ALSO L =head1 AUTHOR Andy Harrison { domain => "gmail", tld => "com", username => "aharrison" } =cut