--- trunk/lib/Frey/Introspect.pm 2008/11/28 18:31:28 599
+++ trunk/lib/Frey/Introspect.pm 2008/12/01 23:28:27 662
@@ -11,10 +11,13 @@
use PPI;
use PPI::HTML;
+use Frey::Pod;
+
use lib 'lib';
extends 'Frey::PPI';
with 'Frey::Web';
+with 'Frey::Storage';
has 'class' => (
is => 'rw',
@@ -107,6 +110,10 @@
my $class = $self->class;
+ my $introspect_path = "var/introspect/$class.yaml";
+ $self->mkbasepath( $introspect_path );
+ my $introspect = $self->load( $introspect_path );
+
my ( $superclasses, $roles ) = ( 'Role', '' );
if ( ! $is_role ) {
if ( $meta->superclasses ) {
@@ -114,6 +121,7 @@
join(', ',
map {
my $name = $_->meta->name;
+ $introspect->{superclass}->{$name}++;
$self->dropdown( $name, $_->meta )
}
#grep { $_ ne 'Moose::Object' }
@@ -131,6 +139,7 @@
grep { ! m/\Q$class\E/ } # skip me
map {
my $name = $_->name;
+ $introspect->{role}->{$name}++;
$role_method->{ $_ }->{$name} = $role_nr foreach $_->get_method_list;
$role_attribute->{ $_ }->{$name} = $role_nr foreach $_->get_attribute_list;
$self->dropdown( $name, $name->meta ) . qq|| . $role_nr++ . qq||;
@@ -144,6 +153,7 @@
my @methods;
@methods = map {
my $name = $_;
+ $introspect->{method}->{$name}++;
if ( $role_method->{$name} ) {
my ( $role_name, $nr ) = each %{ $role_method->{$name} };
$name .= qq|$nr|;
@@ -155,6 +165,7 @@
if ( $meta->get_attribute_list ) {
@attributes = map {
my $name = $_;
+ $introspect->{attribute}->{$name}++;
my $html_name = $name;
my $attr = $meta->get_attribute($name);
confess "$class attribute $name isn't blessed ",dump( $attr ) unless blessed $attr;
@@ -202,7 +213,7 @@
}
$table .= qq||;
- my $pod = Frey::Pod->new( class => $class )->as_markup;
+ my $pod = Frey::Pod->new( class => $class, request_url => $self->request_url )->as_markup;
$pod = $pod->{body} if ref($pod);
my $path = $self->class_path( $class );
@@ -229,15 +240,21 @@
my $runnable = join("\n",
map {
- qq|$_|
+ $introspect->{runnable}->{$_}++;
+ my $short = $_;
+ $short =~ s{_as_(?:markup|data|sponge)$}{};
+ qq|$short|
} $self->class_runnable( $class )
);
$runnable = " runnable: $runnable" if $runnable;
+ $self->store( $introspect_path, $introspect );
+
$self->title( $class );
my $has_tests = '';
- if ( my @tests = $self->has_tests ) {
+ my @tests = grep { defined $_ } $self->has_tests;
+ if ( @tests ) {
$has_tests =
'
test' . ( $#tests > 0 ? 's' : '' ) . ': ' .
join("\n", map {