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 Frey::Action; |
use Frey::Action; |
35 |
my $out; |
my $out; |
36 |
my $pipe; |
my $pipe; |
37 |
|
|
38 |
$self->title( ref($self) . ' | ' . $self->pipe ); |
$self->title( $self->pipe ); |
39 |
|
|
40 |
|
my @parts; |
41 |
|
|
42 |
foreach my $part ( split(/\|/, $self->pipe ) ) { |
foreach my $part ( split(/\|/, $self->pipe ) ) { |
43 |
warn "# part: '$part'"; |
warn "# part: '$part'"; |
44 |
if ( $part =~ m{^([^/]+)/([^\+\?]+)(.*)?$} ) { |
if ( $part =~ m{^([^/]+)/([^\+\?]+)(.*)?$} ) { |
45 |
my ( $class, $method, $args ) = ( $1, $2, $3 ); |
my ( $class, $method, $args ) = ( $1, $2, $3 ); |
|
push @{ $self->status }, { $class => { method => $method, args => $args } }; |
|
46 |
my $params = $pipe; |
my $params = $pipe; |
47 |
$params = {} unless defined $params; |
$params = {} unless defined $params; |
48 |
if ( defined $args ) { |
if ( defined $args ) { |
49 |
$args =~ s{^[\?\+\s]}{}; |
$args =~ s{^[\?\+\s]}{}; |
50 |
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 }; |
|
51 |
map { |
map { |
52 |
my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'"; |
my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'"; |
53 |
$params->{$name} = $value; |
$params->{$name} = $value; |
62 |
my $result = $o->$method; |
my $result = $o->$method; |
63 |
warn "# result ",length( $result ), " bytes ", ref($result); |
warn "# result ",length( $result ), " bytes ", ref($result); |
64 |
|
|
65 |
|
$self->add_status({ $part => { $class => { method => $method, args => $args } } }); |
66 |
|
|
67 |
$self->content_type( $o->content_type ) if $o->can('content_type'); |
$self->content_type( $o->content_type ) if $o->can('content_type'); |
68 |
|
|
69 |
$out = $result; |
$out = $result; |
74 |
} |
} |
75 |
} |
} |
76 |
|
|
|
warn "# pipe ", $self->title; |
|
|
|
|
77 |
return $out; |
return $out; |
78 |
} |
} |
79 |
|
|