/[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 420 by dpavlin, Tue Nov 18 17:11:08 2008 UTC revision 455 by dpavlin, Wed Nov 19 15:28:23 2008 UTC
# Line 11  Shell pipes for structured data Line 11  Shell pipes for structured data
11    
12  =head1 EXAMPLE  =head1 EXAMPLE
13    
14   Frey::Feed/data + uri=http://blog.rot13.org/index.xml | Frey::Dumper/markup   Frey::Feed/as_data + uri=http://blog.rot13.org/index.xml | Frey::Dumper/as_markup
15    
16  this will produce following code:  this will produce following code:
17    
18          Frey::Dumper->new( data =>          Frey::Dumper->new( data =>
19                  Frey::Feed->new( uri => 'http://blog.rot13.org/index.xml' )->data                  Frey::Feed->new( uri => 'http://blog.rot13.org/index.xml' )->as_data
20          )->markup          )->as_markup
21    
22  =cut  =cut
23    
24  has pipe => (  has pipe => (
25          is => 'rw',          is => 'rw',
26          required => 1,          required => 1,
27          default => 'Frey::Feed/data+uri=http://blog.rot13.org/index.xml|Frey::Dumper/markup',          default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::Dumper/as_markup',
28  );  );
29    
30  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
31    
32  sub markup {  sub as_markup {
33          my ($self) = @_;          my ($self) = @_;
34    
35          my $out;          my $out;
# Line 57  sub markup { Line 57  sub markup {
57                          my ( $html, $default ) = Frey::Action->new( class => $class, params => $params )->params_form;                          my ( $html, $default ) = Frey::Action->new( class => $class, params => $params )->params_form;
58                          warn "$class need more params than ",dump( $default ) if $html && $self->debug; # FIXME replace with query                          warn "$class need more params than ",dump( $default ) if $html && $self->debug; # FIXME replace with query
59    
60                          my $code = '$result = ' . $class . '->new' . dump( %$default ) . '->' . $method . '();';                          warn "# pipe $part" if $self->debug;
61                          warn "# pipe $part -> $code" if $self->debug;                          my $o = $class->new( %$default );
62                          my $result;                          my $result = $o->$method;
63                          eval $code;                          warn "# result ",length( $result ), " bytes ", ref($result);
64                          die $@ if $@;  
65                          warn "# result ",ref( $result );                          $self->content_type( $o->content_type ) if $o->can('content_type');
66  #                       $out .= qq{<span class="frey-popdown">$part<code>} . dump( $result ) . '</code><span><hr>';  
67                          $out = $result;                          $out = $result;
68                            $method =~ s{^as_}{};
69                          $pipe = { $method => $result };                          $pipe = { $method => $result };
70                  } else {                  } else {
71                          die "don't know what to do with '$part' from ",$self->pipe;                          die "don't know what to do with '$part' from ",$self->pipe;
72                  }                  }
73          }          }
74    
75          warn "# pipe ", $self->title, dump( $self->status );          warn "# pipe ", $self->title;
76    
77          return $out;          return $out;
78  }  }

Legend:
Removed from v.420  
changed lines
  Added in v.455

  ViewVC Help
Powered by ViewVC 1.1.26