Files
perl-Catalyst-Controller-Ac…/perl-Catalyst-Controller-ActionRole.spec
2025-08-12 18:12:06 +02:00

148 lines
5.0 KiB
RPMSpec

#
# spec file for package perl-Catalyst-Controller-ActionRole
#
# 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 Catalyst-Controller-ActionRole
Name: perl-Catalyst-Controller-ActionRole
Version: 0.170.0
Release: 0
# 0.17 -> normalize -> 0.170.0
%define cpan_version 0.17
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: (DEPRECATED) Apply roles to action instances
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/E/ET/ETHER/%{cpan_name}-%{cpan_version}.tar.gz
Source1: cpanspec.yml
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Catalyst)
BuildRequires: perl(Catalyst::Action)
BuildRequires: perl(Catalyst::Action::REST) >= 0.740.0
BuildRequires: perl(Catalyst::Controller)
BuildRequires: perl(Catalyst::Runtime) >= 5.800.250
BuildRequires: perl(Catalyst::Test)
BuildRequires: perl(Catalyst::Utils)
BuildRequires: perl(Class::Load)
BuildRequires: perl(Module::Build)
BuildRequires: perl(Module::Build::Tiny) >= 0.039
BuildRequires: perl(Moose)
BuildRequires: perl(Moose::Meta::Class)
BuildRequires: perl(Moose::Role)
BuildRequires: perl(MooseX::Types::Moose)
BuildRequires: perl(String::RewritePrefix) >= 0.004
BuildRequires: perl(namespace::autoclean)
BuildRequires: perl(namespace::clean)
BuildRequires: perl(parent)
Requires: perl(Catalyst::Controller)
Requires: perl(Catalyst::Runtime) >= 5.800.250
Requires: perl(Catalyst::Utils)
Requires: perl(Class::Load)
Requires: perl(Moose)
Requires: perl(Moose::Meta::Class)
Requires: perl(MooseX::Types::Moose)
Requires: perl(String::RewritePrefix) >= 0.004
Requires: perl(namespace::autoclean)
Provides: perl(Catalyst::Controller::ActionRole) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
This module allows one to apply Moose::Roles to the 'Catalyst::Action's for
different controller methods.
For that a 'Does' attribute is provided. That attribute takes an argument,
that determines the role, which is going to be applied. If that argument is
prefixed with '+', it is assumed to be the full name of the role. If it's
prefixed with '~', the name of your application followed by
'::ActionRole::' is prepended. If it isn't prefixed with '+' or '~', the
role name will be searched for in '@INC' according to the rules for role
prefix searching.
It's possible to apply roles to *all* actions of a controller without
specifying the 'Does' keyword in every action definition:
package MyApp::Controller::Bar
use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller::ActionRole' }
__PACKAGE__->config(
action_roles => ['Foo', '~Bar'],
);
# Has Catalyst::ActionRole::Foo and MyApp::ActionRole::Bar applied.
#
# If MyApp::ActionRole::Foo exists and is loadable, it will take
# precedence over Catalyst::ActionRole::Foo.
#
# If MyApp::ActionRole::Bar exists and is loadable, it will be loaded,
# but even if it doesn't exist Catalyst::ActionRole::Bar will not be loaded.
sub moo : Local { ... }
Additionally, roles can be applied to selected actions without specifying
'Does' using Catalyst::Controller/action and configured with
Catalyst::Controller/action_args:
package MyApp::Controller::Baz;
use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller::ActionRole' }
__PACKAGE__->config(
action_roles => [qw( Foo )],
action => {
some_action => { Does => [qw( ~Bar )] },
another_action => { Does => [qw( +MyActionRole::Baz )] },
},
action_args => {
another_action => { customarg => 'arg1' },
}
);
# has Catalyst::ActionRole::Foo and MyApp::ActionRole::Bar applied
sub some_action : Local { ... }
# has Catalyst::ActionRole::Foo and MyActionRole::Baz applied
# and associated action class would get additional arguments passed
sub another_action : Local { ... }
%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 CONTRIBUTING README
%license LICENSE
%changelog