--- trunk/lib/Frey/Pipe.pm 2008/11/19 15:28:23 455 +++ trunk/lib/Frey/Pipe.pm 2008/11/25 17:15:18 519 @@ -1,6 +1,6 @@ package Frey::Pipe; use Moose; -extends 'Frey'; +extends 'Frey::ClassLoader'; with 'Frey::Web'; use Frey::Action; @@ -11,11 +11,11 @@ =head1 EXAMPLE - Frey::Feed/as_data + uri=http://blog.rot13.org/index.xml | Frey::Dumper/as_markup + Frey::Feed/as_data + uri=http://blog.rot13.org/index.xml | Frey::View::Dumper/as_markup this will produce following code: - Frey::Dumper->new( data => + Frey::View::Dumper->new( data => Frey::Feed->new( uri => 'http://blog.rot13.org/index.xml' )->as_data )->as_markup @@ -24,7 +24,7 @@ has pipe => ( is => 'rw', required => 1, - default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::Dumper/as_markup', + default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::View::Dumper/as_markup', ); use Data::Dump qw/dump/; @@ -35,19 +35,19 @@ my $out; my $pipe; - $self->title( ref($self) . ' | ' . $self->pipe ); + $self->title( $self->pipe ); + + my @parts; foreach my $part ( split(/\|/, $self->pipe ) ) { warn "# part: '$part'"; if ( $part =~ m{^([^/]+)/([^\+\?]+)(.*)?$} ) { my ( $class, $method, $args ) = ( $1, $2, $3 ); - push @{ $self->status }, { $class => { method => $method, args => $args } }; my $params = $pipe; $params = {} unless defined $params; if ( defined $args ) { $args =~ s{^[\?\+\s]}{}; warn "# class $class method $method args '$args'", $pipe ? " pipe args " . join(',',keys %$pipe) : '' if $self->debug; - push @{ $self->status }, { $class =>$args }; map { my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'"; $params->{$name} = $value; @@ -58,10 +58,12 @@ warn "$class need more params than ",dump( $default ) if $html && $self->debug; # FIXME replace with query warn "# pipe $part" if $self->debug; - my $o = $class->new( %$default ); + my $o = $self->new_frey_class( $class, $default ); my $result = $o->$method; warn "# result ",length( $result ), " bytes ", ref($result); + $self->add_status({ $part => { $class => { method => $method, args => $args } } }); + $self->content_type( $o->content_type ) if $o->can('content_type'); $out = $result; @@ -72,8 +74,6 @@ } } - warn "# pipe ", $self->title; - return $out; }