# Detect the distribution in use
%global __despace head -n 1 | tr -d '[:space:]' | sed -e 's/[(].*[)]//g'
%global __lower4 cut -c 1-4 | tr '[:upper:]' '[:lower:]'
%global __distfile %([ -f /etc/SuSE-release ] && echo /etc/SuSE-release || echo /etc/redhat-release)
%global __distinit %(sed -e 's/ release .*//' -e 's/\\([A-Za-z]\\)[^ ]*/\\1/g' %{__distfile} | %{__despace} | %{__lower4})
%global __distvers %(sed -e 's/.* release \\([^. ]*\\).*/\\1/' %{__distfile} | %{__despace})
# Identify Alma, CentOS, CentOS Stream and Rocky Linux as rhel
%if "%{__distinit}" == "a" || "%{__distinit}" == "c" || "%{__distinit}" == "cl" || "%{__distinit}" == "cs" || "%{__distinit}" == "rl"
%global __distinit rhel
%endif
# Dist tag for Fedora is still "fc"
%if "%{__distinit}" == "f"
%global __distinit fc
%endif

# TODO: BR: perl(Test::Pod::No404s) for author tests when available

# Data::Alias might be broken on new Perl releases but seems stable for now
%global have_data_alias 1

Name:		perl-Data-Visitor
Version:	0.32
Release:	1.%{__distinit}%{__distvers}
Summary:	Visitor style traversal of Perl data structures
License:	GPL-1.0-or-later OR Artistic-1.0-Perl
URL:		https://metacpan.org/release/Data-Visitor
Source0:	https://cpan.metacpan.org/modules/by-module/Data/Data-Visitor-%{version}.tar.gz
BuildArch:	noarch
# Build
BuildRequires:	coreutils
BuildRequires:	findutils
BuildRequires:	make
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
BuildRequires:	perl(ExtUtils::MakeMaker)
# Module
BuildRequires:	perl(Carp)
BuildRequires:	perl(constant)
BuildRequires:	perl(Moose) >= 0.89
BuildRequires:	perl(namespace::clean) >= 0.19
BuildRequires:	perl(overload)
BuildRequires:	perl(Scalar::Util)
BuildRequires:	perl(strict)
BuildRequires:	perl(Symbol)
BuildRequires:	perl(Tie::ToObject) >= 0.01
BuildRequires:	perl(warnings)
# Optional Module Requirements
%if %{have_data_alias}
BuildRequires:	perl(Data::Alias)
%endif
# Test Suite
BuildRequires:	perl(File::Spec)
BuildRequires:	perl(Test::More) >= 0.88
BuildRequires:	perl(Test::Needs)
BuildRequires:	perl(Tie::RefHash)
# Optional Tests
BuildRequires:	perl(CPAN::Meta) > 2.120900
BuildRequires:	perl(CPAN::Meta::Prereqs)
# Author Tests
BuildRequires:	perl(blib)
BuildRequires:	perl(IO::Handle)
BuildRequires:	perl(IPC::Open3)
BuildRequires:	perl(Pod::Coverage::TrustPod)
BuildRequires:	perl(Test::EOL)
BuildRequires:	perl(Test::Kwalitee) >= 1.21
BuildRequires:	perl(Test::MinimumVersion)
BuildRequires:	perl(Test::Mojibake)
BuildRequires:	perl(Test::Pod) >= 1.41
BuildRequires:	perl(Test::Pod::Coverage) >= 1.08
BuildRequires:	perl(Test::Portability::Files)
# Release Tests
BuildRequires:	perl(Encode)
BuildRequires:	perl(Test::CPAN::Changes)
BuildRequires:	perl(Test::CPAN::Meta)
BuildRequires:	perl(Test::More) >= 0.96
# Dependencies
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif
%if %{have_data_alias}
Requires:	perl(Data::Alias)
%endif

%description
This module is a simple visitor implementation for Perl values.

%prep
%setup -q -n Data-Visitor-%{version}

%build
perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}

%install
make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name .packlist -delete
%{_fixperms} -c %{buildroot}

%check
make test
make test TEST_FILES="$(echo $(find xt/ -name '*.t'))"

%files
%license LICENCE
%doc Changes CONTRIBUTING README
%{perl_vendorlib}/Data/
%{_mandir}/man3/Data::Visitor.3*
%{_mandir}/man3/Data::Visitor::Callback.3*

%changelog
* Sat Apr 29 2023 Paul Howarth <paul@city-fan.org> - 0.32-1
- Update to 0.32
  - Removed an unnecessary use of Sub::Name (GH#1)

* Wed Mar 22 2023 Paul Howarth <paul@city-fan.org> - 0.31-8
- Use SPDX-format license tag
- Use %%license unconditionally
- Use Data::Alias unconditionally

* Mon Aug  3 2020 Paul Howarth <paul@city-fan.org> - 0.31-1
- Update to 0.31
  - Updated distribution tooling (resolves CPAN RT#133059, a problem with the
    compilation test when the installed perl has whitespace in its path)

* Mon Jun 10 2019 Paul Howarth <paul@city-fan.org> - 0.30-15
- Modernize spec
  - Switch upstream from search.cpan.org to metacpan.org
  - BR: perl-generators unconditionally
  - BR: perl-interpreter rather than perl
  - Don't explicitly clean buildroot in %%install section
  - Drop explicit %%clean section
  - Drop support for building with Test::More < 0.98
  - Drop legacy BuildRoot: and Group: tags

* Thu May 19 2016 Paul Howarth <paul@city-fan.org> - 0.30-7
- Don't pull in Data::Alias in Perl 5.24+ as it's broken there
  (CPAN RT#112289)
- BR: perl-generators where available
- Simplify find command using -delete

* Thu Oct 22 2015 Paul Howarth <paul@city-fan.org> - 0.30-6
- Reinstate unconditional use of Data::Alias

* Tue Jun 30 2015 Paul Howarth <paul@city-fan.org> - 0.30-5
- Don't pull in Data::Alias in Perl 5.22+ as it's broken there
  (CPAN RT#100944)

* Tue Sep 16 2014 Paul Howarth <paul@city-fan.org> - 0.30-4
- Use %%license where possible

* Sun Aug  4 2013 Paul Howarth <paul@city-fan.org> - 0.30-3
- Reinstate unconditional use of Data::Alias

* Wed Jul 24 2013 Paul Howarth <paul@city-fan.org> - 0.30-2
- Don't pull in Data::Alias in Perl 5.18+ as it's broken there
  (CPAN RT#78148, CPAN RT#85690)

* Tue Jun 25 2013 Paul Howarth <paul@city-fan.org> - 0.30-1
- Update to 0.30
  - The class callbacks to be run for an object are now chosen once, at the
    start of visiting that object (needed for consistency in the presence of
    hash order randomization)
- Classify buildreqs by usage
- Explicity require perl(Sub::Name) and perl(Task::Weaken)
- Run the release tests separately
- Add patch to support building with Test::More < 0.82

* Sun Jul 15 2012 Paul Howarth <paul@city-fan.org> - 0.28-3
- BR: perl(File::Temp), perl(Scalar::Util), perl(Sub::Name) and
  perl(Tie::RefHash)
- Drop buildreqs for Perl core modules that are not dual-lived
- Don't need to remove empty directories from the buildroot
- Drop support for old distributions prior to FC-5:
  - Don't need to define %%{perl_vendorlib}
  - Use DESTDIR rather than PERL_INSTALL_ROOT
  - %%defattr redundant since rpm 4.4

* Mon Feb 20 2012 Paul Howarth <paul@city-fan.org> - 0.28-2
- Import from Fedora

* Sun Feb 19 2012 Iain Arnell <iarnell@gmail.com> - 0.28-1
- Update to latest upstream version
- Clean up spec for modern rpmbuild
- Use perl_default_filter and DESTDIR
- Add LICENSE and README to docs

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.27-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Thu Jul 21 2011 Petr Sabata <contyk@redhat.com> - 0.27-5
- Perl mass rebuild

* Tue Jul 19 2011 Petr Sabata <contyk@redhat.com> - 0.27-4
- Perl mass rebuild

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.27-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Thu Dec 16 2010 Marcela Maslanova <mmaslano@redhat.com> - 0.27-2
- Rebuild to fix problems with vendorarch/lib (#661697)

* Tue Jun  1 2010 Marcela Maslanova <mmaslano@redhat.com> - 0.27-1
- Update

* Fri Apr 30 2010 Marcela Maslanova <mmaslano@redhat.com> - 0.26-2
- Mass rebuild with perl-5.12.0

* Mon Jan 04 2010 Iain Arnell <iarnell@gmail.com> - 0.26-1
- Update to latest upstream version
- BR: perl(Moose), not perl(Any::Moose)

* Mon Dec  7 2009 Stepan Kasal <skasal@redhat.com> - 0.25-3
- Rebuild against perl 5.10.1

* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.25-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Thu May 21 2009 Chris Weyl <cweyl@alumni.drew.edu> - 0.25-1
- Auto-update to 0.25 (by cpan-spec-update 0.01)
- Altered br on perl(Any::Moose) (0 => 0.09)
- Altered br on perl(Tie::ToObject) (0 => 0.01)
- Altered br on perl(namespace::clean) (0 => 0.08)

* Tue May 05 2009 Chris Weyl <cweyl@alumni.drew.edu> - 0.24-1
- Update to 0.24

* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.22-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Tue Feb 10 2009 Chris Weyl <cweyl@alumni.drew.edu> - 0.22-1
- Update to 0.22

* Wed Nov 12 2008 Chris Weyl <cweyl@alumni.drew.edu> - 0.21-1
- Update to 0.21

* Sat Sep 06 2008 Chris Weyl <cweyl@alumni.drew.edu> - 0.19-1
- Update to 0.19

* Wed Mar 05 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 0.09-2
- Rebuild for new perl

* Sun Oct 21 2007 Chris Weyl <cweyl@alumni.drew.edu> - 0.09-1
- Update to 0.09
- Update license tag: GPL -> GPL+
- Add t/ to doc
- Back to good old Makefile.PL; Build.PL seems to have gone away

* Thu May 03 2007 Chris Weyl <cweyl@alumni.drew.edu> - 0.05-2
- Bump

* Tue Apr 10 2007 Chris Weyl <cweyl@alumni.drew.edu> - 0.05-1
- Specfile autogenerated by cpanspec 1.70