/[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 519 by dpavlin, Tue Nov 25 17:15:18 2008 UTC revision 953 by dpavlin, Tue Jan 6 23:44:59 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 27  has pipe => ( Line 28  has pipe => (
28          default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::View::Dumper/as_markup',          default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::View::Dumper/as_markup',
29  );  );
30    
31    sub render_pipe { 'radio' };
32    
33  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
34    
35  sub as_markup {  sub as_markup {
# Line 51  sub as_markup { Line 54  sub as_markup {
54                                  map {                                  map {
55                                          my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'";                                          my ( $name, $value ) = ( $1, $2 ) if m{^([^=]+)=(.+)$} || confess "can't parse '$_'";
56                                          $params->{$name} = $value;                                          $params->{$name} = $value;
57                                  } split(/\s*\+\s/, $args)                                  } split(/[;&]/, $args)
58                          }                          }
59    
60                          my ( $html, $default ) = Frey::Action->new( class => $class, params => $params )->params_form;                          my ( $html, $default ) = Frey::Action->new( class => $class, params => $params )->params_form;
# Line 59  sub as_markup { Line 62  sub as_markup {
62    
63                          warn "# pipe $part" if $self->debug;                          warn "# pipe $part" if $self->debug;
64                          my $o = $self->new_frey_class( $class, $default );                          my $o = $self->new_frey_class( $class, $default );
65    
66                            # XXX copy depends from parts of pipe
67                            if ( $o->can('depends') ) {
68                                    $o->depends;
69                                    my $current_head;
70                                    $current_head->{$_}++ foreach $self->head;
71                                    foreach ( $o->head ) {
72                                            next if $current_head->{$_}++;
73                                            $self->add_head( $_ );
74                                    }
75                            }
76    
77                          my $result = $o->$method;                          my $result = $o->$method;
78                          warn "# result ",length( $result ), " bytes ", ref($result);                          warn "# result ",length( $result ), " bytes ", ref($result);
79    
80                          $self->add_status({ $part => { $class => { method => $method, args => $args } } });                          my $current_status;
81                            $current_status->{$_}++ foreach $self->status;
82                            foreach ( $o->status ) {
83                                    next if $current_status->{$_}++;
84                                    $self->add_status( $_ );
85                                    warn "# pipe add_status: $_";
86                            }
87    
88                          $self->content_type( $o->content_type ) if $o->can('content_type');                          $self->content_type( $o->content_type ) if $o->can('content_type');
89    
90                          $out = $result;                          $out = $result;
91                          $method =~ s{^as_}{};                          $method =~ s{^as_}{};
92                          $pipe = { $method => $result };                          $pipe = { $method => $result };
93                            push @parts, { $class . '->' . $method => $result };
94                  } else {                  } else {
95                          die "don't know what to do with '$part' from ",$self->pipe;                          die "don't know what to do with '$part' from ",$self->pipe;
96                  }                  }
97          }          }
98    
99            $pipe = $self->pipe;
100    
101            $out = $self->error(
102                    qq|<a href="$pipe" title="copy pipe"><tt>$pipe</tt></a> = $out not scalar\n|
103                    . $self->html_dump($out)
104            ) if ref $out;
105    
106          return $out;          return $out;
107  }  }
108    

Legend:
Removed from v.519  
changed lines
  Added in v.953

  ViewVC Help
Powered by ViewVC 1.1.26