--- trunk/lib/Frey/Introspect.pm 2008/12/06 14:34:41 736
+++ trunk/lib/Frey/Introspect.pm 2009/01/06 14:50:30 943
@@ -18,6 +18,12 @@
with 'Frey::Web';
with 'Frey::Storage';
+=head1 DESCRIPTION
+
+Provide introspection on any perl class installed on system
+
+=cut
+
has 'class' => (
is => 'rw',
isa => 'Str',
@@ -108,6 +114,7 @@
my ( $meta, $is_role ) = $self->class_meta;
my $class = $self->class;
+ $self->title( $class );
my $introspect_path = "var/introspect/$class.yaml";
$self->mkbasepath( $introspect_path );
@@ -121,7 +128,9 @@
map {
my $name = $_->meta->name;
$introspect->{superclass}->{$name} = {};
- $self->dropdown( $name, $_->meta )
+
+ qq|$name| .
+ $self->dropdown( qq|?|, $_->meta )
}
#grep { $_ ne 'Moose::Object' }
$meta->superclasses
@@ -141,11 +150,18 @@
$introspect->{roles}->{$name} = {};
$method_from_role->{ $_ }->{$name} = $role_nr foreach $_->get_method_list;
$attribute_from_role->{ $_ }->{$name} = $role_nr foreach $_->get_attribute_list;
- $self->dropdown( $name, $name->meta ) . qq|| . $role_nr++ . qq||;
+
+ qq|$name|
+# . qq|| . $self->dropdown( $role_nr++, $name->meta ) . qq||
+ . $self->dropdown(
+ qq|| . $role_nr++ . qq||,
+ $name->meta
+ )
+ ;
}
$meta->calculate_all_roles
);
- $roles = qq| with roles: $roles| if $roles;
+ $roles = qq|with roles: $roles| if $roles;
}
warn "# method_from_role ",dump( $method_from_role );
@@ -160,7 +176,9 @@
$introspect->{methods}->{$name} = {};
}
qq|
$name | |
- } sort $self->class_methods( $class );
+ } sort {
+ lc($a) cmp lc($b)
+ } $self->class_methods( $class );
my @attributes;
if ( $meta->get_attribute_list ) {
@@ -185,12 +203,13 @@
$getter =~ s/^has_//;
if ( $attr->can($check) && $attr->$check ) {
- if ( $getter eq $check ) {
- $properties .= "$check";
- } else {
- # we need our dump here instead of $attr->$getter->dump because default can return scalar
- $properties .= $self->dropdown( $check, $attr->$getter );
- }
+ $properties .= $check;
+ # we need our dump here instead of $attr->$getter->dump because default can return scalar
+ my $v = $attr->$getter;
+ $properties .= ref($v)
+ ? $self->dropdown( qq|?|, $attr->$getter )
+ : qq| $v
|
+ ;
}
$properties .= ' ';
}
@@ -217,7 +236,7 @@
$introspect->{action}->{$name}->{documentation} = $doc;
}
- qq|$html_name | $type | $properties | |
+ qq|$html_name | $type | $properties | |
} sort $meta->get_attribute_list
}
@@ -264,25 +283,48 @@
qq|$short|
} $self->class_runnable( $class )
);
- $runnable = "
run: $runnable" if $runnable;
-
- $self->store( $introspect_path, $introspect );
-
- $self->title( $class );
+ $runnable = "Runnable: $runnable" if $runnable;
my $has_tests = '';
my @tests = grep { defined $_ } $self->has_tests;
if ( @tests ) {
$has_tests =
- '
test' . ( $#tests > 0 ? 's' : '' ) . ': ' .
+ 'Test' . ( $#tests > 0 ? 's' : '' ) . ': ' .
join("\n", map {
qq|$_|
} @tests );
+ $introspect->{tests} = [ @tests ],
}
+ my $includes = '';
+ if ( my $inc = $self->includes ) {
+ $introspect->{includes} = $inc;
+ foreach my $type ( keys %$inc ) {
+ $includes
+ .= ucfirst($type)
+ . qq|: |
+ . join("\n",
+ map {
+ qq|$_|
+ } @{
+ $inc->{$type}
+ }
+ )
+ ;
+ }
+ }
+
+ $self->store( $introspect_path, $introspect );
+
return join("\n",
qq|$class
|,
- qq|$superclasses\n$roles\n$runnable\n|,
+ qq|
+ $superclasses $roles
+
+ $includes
+
+ $runnable
+ |,
$has_tests,
$pod ? qq|
pod| : '',
$source ? qq|
source| : '',