/[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 1034 by dpavlin, Tue Feb 3 21:24:02 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 251  sub as_markup { Line 253  sub as_markup {
253    
254          my $path = $self->class_path( $class );          my $path = $self->class_path( $class );
255    
256          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;
257          return $pod if $path =~ m{\.pod};          return $pod_toc . $pod if $path =~ m{\.pod};
258    
259            warn "# ", $pod_toc ? 'toc' : '', ' ', $pod ? 'pod' : '';
260    
261          my $Document = PPI::Document->new( $path );          my $Document = PPI::Document->new( $path );
262    
# Line 275  sub as_markup { Line 279  sub as_markup {
279  #       $source =~ s{^.*<body[^>]+>}{}s;  #       $source =~ s{^.*<body[^>]+>}{}s;
280  #       $source =~ s{</body.*$}{}s;  #       $source =~ s{</body.*$}{}s;
281    
282          my $runnable = join("\n",          my $runnable = join("</dd><dd>",
283                  map {                  map {
284                          $introspect->{runnable}->{$_} = {};                          $introspect->{runnable}->{$_} = {};
285                          my $short = $_;                          my $short = $_;
# Line 283  sub as_markup { Line 287  sub as_markup {
287                          qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>|                          qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>|
288                  } $self->class_runnable( $class )                  } $self->class_runnable( $class )
289          );          );
290          $runnable = "Runnable: $runnable" if $runnable;          $runnable = "<dt>runnable</dt><dd>$runnable</dd>" if $runnable;
291    
292          my $has_tests = '';          my $has_tests = '';
293          my @tests = grep { defined $_ } $self->has_tests;          my @tests = sort { lc($a) cmp lc($b) } grep { defined $_ } $self->has_tests;
294          if ( @tests ) {          if ( @tests ) {
295                  $has_tests =                  $has_tests
296                  'Test' . ( $#tests > 0 ? 's' : '' ) . ': ' .                              = qq|<dt>test|
297                  join("\n", map {                          . ( $#tests > 0 ? 's' : '' )
298                          qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>|                          . qq|<dt><dd>|
299                  } @tests );                          . join("</dd><dd>", map {
300                                    qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>|
301                            } @tests )
302                            . qq|</dd>|
303                            ;
304                  $introspect->{tests} = [ @tests ],                  $introspect->{tests} = [ @tests ],
305          }          }
306    
# Line 316  sub as_markup { Line 324  sub as_markup {
324    
325          $self->store( $introspect_path, $introspect );          $self->store( $introspect_path, $introspect );
326    
327          return join("\n",          $self->add_css(qq|
328                  qq|<h1>$class</h1>|,                  .frey-introspect-right {
329                  qq|<div class="frey-introspect">                          position: fixed;
330                          $superclasses $roles                          top: 1em;
331                          <br>                          right: 1em;
332                          $includes                          z-index: 10;
333                          <br>                          background: #ffc;
334                          $runnable                          padding: 0.5em;
335                  |,                          width: 20%;
336                  $has_tests,                          font-size: 80%;
337                  $pod    ? qq|<a class="frey-skip" href="#___top" title="Skip to POD"    >pod</a>|    : '',                  }
338                  $source ? qq|<a class="frey-skip" href="#source" title="Skip to source" >source</a>| : '',                  .frey-introspect-right dl dd {
339                  qq|$table\n$pod\n</div>\n|,                          margin-left: 1em;
340                  qq|<h1>Source</h1><a name="source"></a><div class="frey-source">$source</div>|,                  }
341          );  
342                    /* fix pod */
343                    .frey-introspect-right dd ul {
344                            padding-left: 0;
345                    }
346                    .frey-introspect-right dl ul > li {
347                            list-style: none;
348                    }
349            |);
350    
351            my $has_pod = qq|
352                    <dt><a href="#___top" title="Skip to POD">pod</a></dt>
353                    <dd>$pod_toc</dd>
354            | if $pod_toc;
355    
356            my $has_source = qq|
357                    <dt><a href="#source" title="Skip to source">source</a></dt>
358            | if $source;
359    
360            my $right = qq|
361                    <dl>
362                    $runnable
363                    $has_tests
364                    $has_pod
365                    $has_source
366                    </dl>
367            |;
368    
369    
370            return
371                    qq|
372                            <h1>$class</h1>
373                            <div class="frey-introspect">
374                                    $superclasses $roles
375                                    <br>$includes
376                            </div>
377                            <div class="frey-introspect-right">
378                                    $right
379                            </div>
380                            $table
381                            $pod
382                            </div>
383    
384                            <h1>Source</h1><a name="source"></a>
385                            <div class="frey-source">$source</div>
386                    |
387                    ;
388  }  }
389    
390  =head1 SEE ALSO  =head1 SEE ALSO

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

  ViewVC Help
Powered by ViewVC 1.1.26