From: Matt S Trout Date: Thu, 1 Jul 2010 04:46:39 +0000 (+0100) Subject: finish converting from MatchWithoutFilter to TransformBuilder X-Git-Tag: release_0.009004~45 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=97192b02d221241de847e9fe853ec6867ee90fd0 finish converting from MatchWithoutFilter to TransformBuilder --- diff --git a/lib/HTML/Zoom.pm b/lib/HTML/Zoom.pm index abf6be7..88c488f 100644 --- a/lib/HTML/Zoom.pm +++ b/lib/HTML/Zoom.pm @@ -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 +Returns an intermediary object of the class L on which methods of your L 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 index a645586..0000000 --- a/lib/HTML/Zoom/MatchWithoutFilter.pm +++ /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; diff --git a/lib/HTML/Zoom/StreamBase.pm b/lib/HTML/Zoom/StreamBase.pm index a733656..f81089f 100644 --- a/lib/HTML/Zoom/StreamBase.pm +++ b/lib/HTML/Zoom/StreamBase.pm @@ -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 {