Files
perl-WWW-Mechanize-TreeBuilder/perl-WWW-Mechanize-TreeBuilder.spec

83 lines
2.8 KiB
RPMSpec
Raw Permalink Normal View History

#
# spec file for package perl-WWW-Mechanize-TreeBuilder
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
%define cpan_name WWW-Mechanize-TreeBuilder
Name: perl-WWW-Mechanize-TreeBuilder
Version: 1.200.0
Release: 0
# 1.20000 -> normalize -> 1.200.0
%define cpan_version 1.20000
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Combine WWW::Mechanize and HTML::TreeBuilder in nice ways
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/A/AS/ASH/%{cpan_name}-%{cpan_version}.tar.gz
2025-08-12 18:18:30 +02:00
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(ExtUtils::MakeMaker) >= 6.59
BuildRequires: perl(HTML::TreeBuilder)
BuildRequires: perl(Moose) >= 2.1200
BuildRequires: perl(MooseX::Role::Parameterized)
BuildRequires: perl(Test::WWW::Mechanize)
Requires: perl(HTML::TreeBuilder)
Requires: perl(Moose) >= 2.1200
Requires: perl(MooseX::Role::Parameterized)
Provides: perl(WWW::Mechanize::TreeBuilder) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
This module combines WWW::Mechanize and HTML::TreeBuilder. 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 available on HTML::Element (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
%autosetup -n %{cpan_name}-%{cpan_version}
%build
PERL_USE_UNSAFE_INC=1 perl Makefile.PL INSTALLDIRS=vendor
%make_build
%check
make test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%doc Changes
%changelog