101 lines
3.0 KiB
RPMSpec
101 lines
3.0 KiB
RPMSpec
#
|
|
# spec file for package perl-Template-Plugin-VMethods
|
|
#
|
|
# 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 Template-Plugin-VMethods
|
|
Name: perl-Template-Plugin-VMethods
|
|
Version: 0.30.0
|
|
Release: 0
|
|
# 0.03 -> normalize -> 0.30.0
|
|
%define cpan_version 0.03
|
|
License: Artistic-1.0 OR GPL-1.0-or-later
|
|
Summary: Install vmethods
|
|
URL: https://metacpan.org/release/%{cpan_name}
|
|
Source0: https://cpan.metacpan.org/authors/id/M/MA/MARKF/%{cpan_name}-%{cpan_version}.tar.gz
|
|
Source100: README.md
|
|
BuildArch: noarch
|
|
BuildRequires: perl
|
|
BuildRequires: perl-macros
|
|
BuildRequires: perl(Module::Build)
|
|
BuildRequires: perl(Template) >= 2.06
|
|
Requires: perl(Template) >= 2.06
|
|
Provides: perl(Template::Plugin::VMethods) = %{version}
|
|
Provides: perl(Template::Plugin::VMethods::VMethodContainer)
|
|
%undefine __perllib_provides
|
|
%{perl_requires}
|
|
|
|
%description
|
|
Simple base class to allow your module to install and remove virtual
|
|
methods into the Template Toolkit.
|
|
|
|
All you need to do in your package is declare one or more of the variables
|
|
@LIST_OPS, @SCALAR_OPS or @HASH_OPS to indicate what virtual methods you
|
|
want to export.
|
|
|
|
These can either be the names of functions in your package, or
|
|
name/subroutine reference pairs.
|
|
|
|
For example, using named functions:
|
|
|
|
package Template::Plugin::HexVMethod;
|
|
use base qw(Template::Plugin::VMethods);
|
|
@SCALAR_OPS = ( "hex" );
|
|
sub hex { sprintf "%x", $_[0] };
|
|
1;
|
|
|
|
For example, using the name and subroutine ref pairs:
|
|
|
|
package Template::Plugin::DoubleVMethod;
|
|
use base qw(Template::Plugin::VMethods);
|
|
@SCALAR_OPS = ( double => \&double_string);
|
|
@LIST_OPS = ( double => \&double_list);
|
|
sub double_string { $_[0]x2 }
|
|
sub double_list { [ (@{ $_[0] }) x 2] }
|
|
1;
|
|
|
|
For example, mixing the two freely:
|
|
|
|
package CaesarVMethod;
|
|
use base qw(Template::Plugin::VMethods);
|
|
@SCALAR_OPS = ( "caesar",
|
|
"rot13" => sub { caesar($_[0],"13") } );
|
|
sub caesar
|
|
{
|
|
$string = shift;
|
|
$string =~ tr/A-Za-z/B-ZAb-za/ for 1..$_[0];
|
|
return $string;
|
|
}
|
|
|
|
%prep
|
|
%autosetup -n %{cpan_name}-%{cpan_version}
|
|
|
|
%build
|
|
perl Build.PL --installdirs=vendor
|
|
./Build build --flags=%{?_smp_mflags}
|
|
|
|
%check
|
|
./Build test
|
|
|
|
%install
|
|
./Build install --destdir=%{buildroot} --create_packlist=0
|
|
%perl_gen_filelist
|
|
|
|
%files -f %{name}.files
|
|
%doc CHANGES
|
|
|
|
%changelog
|