/[Frey]/trunk/lib/Frey/Introspect.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Introspect.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 943 by dpavlin, Tue Jan 6 14:50:30 2009 UTC revision 1111 by dpavlin, Mon Jun 29 17:01:28 2009 UTC
# Line 60  sub joose { Line 60  sub joose {
60                  $out .= "\t\t\t$_: {\n";                  $out .= "\t\t\t$_: {\n";
61    
62                  my $attr = $meta->get_attribute($_);                  my $attr = $meta->get_attribute($_);
63                  my $is = $attr->_is_metadata;                  my $is = eval { $attr->_is_metadata; };
64                    return if $@;
65    
66                  $out .= "\t\t\t\tis: \"$is\",\n" if defined $is;                  $out .= "\t\t\t\tis: \"$is\",\n" if defined $is;
67                  $out .= "\t\t\t\tlazy: true,\n" if $attr->is_lazy;                  $out .= "\t\t\t\tlazy: true,\n" if $attr->is_lazy;
68                  $out .= "\t\t\t\trequired: true,\n" if $attr->is_required;                  $out .= "\t\t\t\trequired: true,\n" if $attr->is_required;
# Line 109  sub joose { Line 111  sub joose {
111  sub as_markup {  sub as_markup {
112          my ( $self ) = @_;          my ( $self ) = @_;
113    
         $self->add_head( 'static/introspect.css' );  
   
114          my ( $meta, $is_role ) = $self->class_meta;          my ( $meta, $is_role ) = $self->class_meta;
115    
116          my $class = $self->class;          my $class = $self->class;
# Line 251  sub as_markup { Line 251  sub as_markup {
251    
252          my $path = $self->class_path( $class );          my $path = $self->class_path( $class );
253    
254          my $pod = Frey::Pod->new( class => $class, request_url => $self->request_url )->as_markup;          my ( $pod_toc, $pod ) = Frey::Pod->new( class => $class, request_url => $self->request_url )->as_markup;
255          return $pod if $path =~ m{\.pod};          return $pod_toc . $pod if $path =~ m{\.pod};
256    
257            warn "# ", $pod_toc ? 'toc' : '', ' ', $pod ? 'pod' : '';
258    
259          my $Document = PPI::Document->new( $path );          my $Document = PPI::Document->new( $path );
260    
# Line 275  sub as_markup { Line 277  sub as_markup {
277  #       $source =~ s{^.*<body[^>]+>}{}s;  #       $source =~ s{^.*<body[^>]+>}{}s;
278  #       $source =~ s{</body.*$}{}s;  #       $source =~ s{</body.*$}{}s;
279    
280          my $runnable = join("\n",          my $runnable = join("</dd><dd>",
281                  map {                  map {
282                          $introspect->{runnable}->{$_} = {};                          $introspect->{runnable}->{$_} = {};
283                          my $short = $_;                          my $short = $_;
# Line 283  sub as_markup { Line 285  sub as_markup {
285                          qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>|                          qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>|
286                  } $self->class_runnable( $class )                  } $self->class_runnable( $class )
287          );          );
288          $runnable = "Runnable: $runnable" if $runnable;          $runnable = "<dt>runnable</dt><dd>$runnable</dd>" if $runnable;
289    
290          my $has_tests = '';          my $has_tests = '';
291          my @tests = grep { defined $_ } $self->has_tests;          my @tests = sort { lc($a) cmp lc($b) } grep { defined $_ } $self->has_tests;
292          if ( @tests ) {          if ( @tests ) {
293                  $has_tests =                  $has_tests
294                  'Test' . ( $#tests > 0 ? 's' : '' ) . ': ' .                              = qq|<dt>test|
295                  join("\n", map {                          . ( $#tests > 0 ? 's' : '' )
296                          qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>|                          . qq|<dt><dd>|
297                  } @tests );                          . join("</dd><dd>", map {
298                                    qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>|
299                            } @tests )
300                            . qq|</dd>|
301                            ;
302                  $introspect->{tests} = [ @tests ],                  $introspect->{tests} = [ @tests ],
303          }          }
304    
# Line 316  sub as_markup { Line 322  sub as_markup {
322    
323          $self->store( $introspect_path, $introspect );          $self->store( $introspect_path, $introspect );
324    
325          return join("\n",          $self->add_css(qq|
326                  qq|<h1>$class</h1>|,                  .frey-introspect-right {
327                  qq|<div class="frey-introspect">                          position: fixed;
328                          $superclasses $roles                          top: 1em;
329                          <br>                          right: 1em;
330                          $includes                          z-index: 10;
331                          <br>                          background: #ffc;
332                          $runnable                          padding: 0.5em;
333                  |,                          width: 20%;
334                  $has_tests,                          font-size: 80%;
335                  $pod    ? qq|<a class="frey-skip" href="#___top" title="Skip to POD"    >pod</a>|    : '',                  }
336                  $source ? qq|<a class="frey-skip" href="#source" title="Skip to source" >source</a>| : '',                  .frey-introspect-right dl dd {
337                  qq|$table\n$pod\n</div>\n|,                          margin-left: 1em;
338                  qq|<h1>Source</h1><a name="source"></a><div class="frey-source">$source</div>|,                  }
339          );  
340                    /* fix pod */
341                    .frey-introspect-right dd ul {
342                            padding-left: 0;
343                    }
344                    .frey-introspect-right dl ul > li {
345                            list-style: none;
346                    }
347            |);
348    
349            my $has_pod = qq|
350                    <dt><a href="#___top" title="Skip to POD">pod</a></dt>
351                    <dd>$pod_toc</dd>
352            | if $pod_toc;
353    
354            my $has_source = qq|
355                    <dt><a href="#source" title="Skip to source">source</a></dt>
356            | if $source;
357    
358            my $right = qq|
359                    <dl>
360                    $runnable
361                    $has_tests
362                    $has_pod
363                    $has_source
364                    </dl>
365            |;
366    
367    
368            return
369                    qq|
370                            <h1>$class</h1>
371                            <div class="frey-introspect">
372                                    $superclasses $roles
373                                    <br>$includes
374                            </div>
375                            <div class="frey-introspect-right">
376                                    $right
377                            </div>
378                            $table
379                            $pod
380                            </div>
381    
382                            <h1>Source</h1><a name="source"></a>
383                            <div class="frey-source">$source</div>
384                    |
385                    ;
386  }  }
387    
388  =head1 SEE ALSO  =head1 SEE ALSO

Legend:
Removed from v.943  
changed lines
  Added in v.1111

  ViewVC Help
Powered by ViewVC 1.1.26