finish converting from MatchWithoutFilter to TransformBuilder
Matt S Trout [Thu, 1 Jul 2010 04:46:39 +0000 (05:46 +0100)]
lib/HTML/Zoom.pm
lib/HTML/Zoom/MatchWithoutFilter.pm [deleted file]
lib/HTML/Zoom/StreamBase.pm

index abf6be7..88c488f 100644 (file)
@@ -678,7 +678,7 @@ In normal usage, you probably don't need to call this yourself.
 
   my $z2 = $z1->select('div')->replace_content('I AM A DIV!');
 
-Returns an intermediary object of the class L<HTML::Zoom::MatchWithoutFilter>
+Returns an intermediary object of the class L<HTML::Zoom::TransformBuilder>
 on which methods of your L<HTML::Zoom::FilterBuilder> object can be called.
 
 In normal usage you should generally always put the pair of method calls
diff --git a/lib/HTML/Zoom/MatchWithoutFilter.pm b/lib/HTML/Zoom/MatchWithoutFilter.pm
deleted file mode 100644 (file)
index a645586..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package HTML::Zoom::MatchWithoutFilter;
-
-use strict;
-use warnings FATAL => 'all';
-
-sub construct {
-  bless({
-    zoom => $_[1], match => $_[2], fb => $_[3],
-  }, $_[0]);
-}
-
-sub DESTROY {}
-
-sub AUTOLOAD {
-  my $meth = our $AUTOLOAD;
-  $meth =~ s/.*:://;
-  my $self = shift;
-  if (my $cr = $self->{fb}->can($meth)) {
-    return $self->{zoom}->with_filter(
-      $self->{match}, $self->{fb}->$cr(@_)
-    );
-  }
-  die "Filter builder ${\$self->{fb}} does not provide action ${meth}";
-}
-
-1;
index a733656..f81089f 100644 (file)
@@ -2,7 +2,7 @@ package HTML::Zoom::StreamBase;
 
 use strict;
 use warnings FATAL => 'all';
-use HTML::Zoom::MatchWithoutFilter;
+use HTML::Zoom::TransformBuilder;
 
 sub _zconfig { shift->{_zconfig} }
 
@@ -53,18 +53,19 @@ sub with_filter {
   $self->_zconfig->stream_utils->wrap_with_filter($self, $match, $filter);
 }
 
-sub select {
-  my ($self, $selector) = @_;
-  my $match = $self->_parse_selector($selector);
-  return HTML::Zoom::MatchWithoutFilter->construct(
-    $self, $match, $self->_zconfig->filter_builder,
-  );
+sub with_transform {
+  my ($self, $transform) = @_;
+  $transform->apply_to_stream($self);
 }
 
-sub _parse_selector {
+sub select {
   my ($self, $selector) = @_;
-  return $selector if ref($selector); # already a match sub
-  $self->_zconfig->selector_parser->parse_selector($selector);
+  return HTML::Zoom::TransformBuilder->new({
+    zconfig => $self->_zconfig,
+    selector => $selector,
+    filters => [],
+    proto => $self,
+  });
 }
 
 sub apply {