File perl-WWW-Mechanize-TreeBuilder.spec of Package perl-WWW-Mechanize-TreeBuilder

#
# spec file for package perl-WWW-Mechanize-TreeBuilder
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           perl-WWW-Mechanize-TreeBuilder
Version:        1.10003
Release:        0
%define cpan_name WWW-Mechanize-TreeBuilder
Summary:        Little glue
License:        GPL-1.0+ or Artistic-1.0
Group:          Development/Libraries/Perl
Url:            http://search.cpan.org/dist/WWW-Mechanize-TreeBuilder/
Source:         http://www.cpan.org/authors/id/A/AS/ASH/WWW-Mechanize-TreeBuilder-%{version}.tar.gz
BuildRequires:  perl
BuildRequires:  perl-macros
BuildRequires:  perl(HTML::TreeBuilder)
BuildRequires:  perl(Moose) >= 0.65
BuildRequires:  perl(MooseX::Role::Parameterized)
BuildRequires:  perl(Scalar::Util)
BuildRequires:  perl(Test::WWW::Mechanize)
Requires:       perl(HTML::TreeBuilder)
Requires:       perl(Moose) >= 0.65
Requires:       perl(MooseX::Role::Parameterized)
Requires:       perl(Scalar::Util)
Requires:       perl(Test::WWW::Mechanize)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%{perl_requires}

%description
This module combines the WWW::Mechanize manpage and the HTML::TreeBuilder
manpage. Why? Because I've seen too much code like the following:

 like($mech->content, qr{<p>some text</p>}, "Found the right tag");

Which is just all flavours of wrong - its akin to processing XML with
regexps. Instead, do it like the following:

 ok($mech->look_down(_tag => 'p', sub { $_[0]->as_trimmed_text eq 'some text' })

The anon-sub there is a bit icky, but this means that anyone should happen
to add attributes to the '<p>' tag (such as an id or a class) it will still
work and find the right tag.

All of the methods avaiable on the HTML::Element manpage (that aren't
'private' - i.e. that don't begin with an underscore) such as 'look_down'
or 'find' are automatically delegated to '$mech->tree' through the magic of
Moose.

%prep
%setup -q -n %{cpan_name}-%{version}

%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}

%check
%{__make} test

%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist

%clean
%{__rm} -rf %{buildroot}

%files -f %{name}.files
%defattr(644,root,root,755)
%doc Changes

%changelog
openSUSE Build Service is sponsored by