/[Frey]/trunk/lib/Frey/Pipe.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/Pipe.pm

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

revision 467 by dpavlin, Wed Nov 19 19:28:09 2008 UTC revision 933 by dpavlin, Tue Jan 6 00:22:04 2009 UTC
# Line 1  Line 1 
1  package Frey::Pipe;  package Frey::Pipe;
2  use Moose;  use Moose;
3  extends 'Frey::ClassLoader';  extends 'Frey::Class::Loader';
4  with 'Frey::Web';  with 'Frey::Web';
5    
6    use lib 'lib';
7  use Frey::Action;  use Frey::Action;
8    
9  =head1 DESCRIPTION  =head1 DESCRIPTION
# Line 35  sub as_markup { Line 36  sub as_markup {
36          my $out;          my $out;
37          my $pipe;          my $pipe;
38    
39          $self->title( ref($self) . ' | ' . $self->pipe );          $self->title( $self->pipe );
40    
41            my @parts;
42    
43          foreach my $part ( split(/\|/, $self->pipe ) ) {          foreach my $part ( split(/\|/, $self->pipe ) ) {
44                  warn "# part: '$part'";                  warn "# part: '$part'";
45                  if ( $part =~ m{^([^/]+)/([^\+\?]+)(.*)?$} ) {                  if ( $part =~ m{^([^/]+)/([^\+\?]+)(.*)?$} ) {
46                          my ( $class, $method, $args ) = ( $1, $2, $3 );                          my ( $class, $method, $args ) = ( $1, $2, $3 );
                         push @{ $self->status }, { $class => { method => $method, args => $args } };  
47                          my $params = $pipe;                          my $params = $pipe;
48                          $params = {} unless defined $params;                          $params = {} unless defined $params;
49                          if ( defined $args ) {                          if ( defined $args ) {
50                                  $args =~ s{^[\?\+\s]}{};                                  $args =~ s{^[\?\+\s]}{};
51                                  warn "# class $class method $method args '$args'", $pipe ? " pipe args " . join(',',keys %$pipe) : '' if $self->debug;                                  warn "# class $class method $method args '$args'", $pipe ? " pipe args " . join(',',keys %$pipe) : '' if $self->debug;
                                 push @{ $self->status }, { $class =>$args };  
52                                  map {                                  map {
53                                          my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'";                                          my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'";
54                                          $params->{$name} = $value;                                          $params->{$name} = $value;
# Line 59  sub as_markup { Line 60  sub as_markup {
60    
61                          warn "# pipe $part" if $self->debug;                          warn "# pipe $part" if $self->debug;
62                          my $o = $self->new_frey_class( $class, $default );                          my $o = $self->new_frey_class( $class, $default );
63    
64                            # XXX copy depends from parts of pipe
65                            if ( $o->can('depends') ) {
66                                    $o->depends;
67                                    my $current_head;
68                                    $current_head->{$_}++ foreach $self->head;
69                                    foreach ( $o->head ) {
70                                            next if $current_head->{$_}++;
71                                            $self->add_head( $_ );
72                                    }
73                            }
74    
75                          my $result = $o->$method;                          my $result = $o->$method;
76                          warn "# result ",length( $result ), " bytes ", ref($result);                          warn "# result ",length( $result ), " bytes ", ref($result);
77    
78                            my $current_status;
79                            $current_status->{$_}++ foreach $self->status;
80                            foreach ( $o->status ) {
81                                    next if $current_status->{$_}++;
82                                    $self->add_status( $_ );
83                                    warn "# pipe add_status: $_";
84                            }
85    
86                          $self->content_type( $o->content_type ) if $o->can('content_type');                          $self->content_type( $o->content_type ) if $o->can('content_type');
87    
88                          $out = $result;                          $out = $result;
# Line 72  sub as_markup { Line 93  sub as_markup {
93                  }                  }
94          }          }
95    
96          warn "# pipe ", $self->title;          $out = $self->error("$out not scalar" . $self->html_dump($out) ) if ref $out;
97    
98          return $out;          return $out;
99  }  }

Legend:
Removed from v.467  
changed lines
  Added in v.933

  ViewVC Help
Powered by ViewVC 1.1.26