2011-04-14 07:56:01 +00:00
|
|
|
#
|
2024-07-11 11:49:39 +00:00
|
|
|
# spec file for package perl-Class-Constructor
|
2011-04-14 07:56:01 +00:00
|
|
|
#
|
2024-07-11 11:49:39 +00:00
|
|
|
# Copyright (c) 2024 SUSE LLC
|
2011-04-14 07:56:01 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2024-07-11 11:49:39 +00:00
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
2011-04-14 07:56:01 +00:00
|
|
|
#
|
|
|
|
|
2024-07-11 11:49:39 +00:00
|
|
|
|
|
|
|
%define cpan_name Class-Constructor
|
2011-04-14 07:56:01 +00:00
|
|
|
Name: perl-Class-Constructor
|
|
|
|
Version: 1.1.4
|
2024-07-11 11:49:39 +00:00
|
|
|
Release: 0
|
|
|
|
License: Artistic-1.0 OR GPL-1.0-or-later
|
2011-04-14 07:56:01 +00:00
|
|
|
Summary: Simplify the creation of object constructors
|
2024-07-11 11:49:39 +00:00
|
|
|
URL: https://metacpan.org/release/%{cpan_name}
|
|
|
|
Source0: https://cpan.metacpan.org/authors/id/M/MG/MGRAHAM/%{cpan_name}-%{version}.tar.gz
|
|
|
|
Source1: cpanspec.yml
|
2025-08-12 18:12:22 +02:00
|
|
|
Source100: README.md
|
2011-04-14 07:56:01 +00:00
|
|
|
BuildArch: noarch
|
|
|
|
BuildRequires: perl
|
|
|
|
BuildRequires: perl-macros
|
|
|
|
BuildRequires: perl(Class::Accessor)
|
|
|
|
Requires: perl(Class::Accessor)
|
|
|
|
%{perl_requires}
|
|
|
|
|
|
|
|
%description
|
|
|
|
Simplifies the creation of object constructors.
|
|
|
|
|
|
|
|
Instead of writing:
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref $proto || $proto;
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
my %args = @_;
|
|
|
|
foreach my $attr ('first_attribute', 'second_attribute') {
|
|
|
|
$self->$attr($args{$attr});
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->_init();
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
You can just write:
|
|
|
|
|
|
|
|
CLASS->mk_constructor(
|
|
|
|
Auto_Init => [ 'first_attribute', 'second_attribute' ],
|
|
|
|
);
|
|
|
|
|
|
|
|
There are other features as well:
|
|
|
|
|
|
|
|
* Automatically call other initialization methods.
|
|
|
|
|
2024-07-11 11:49:39 +00:00
|
|
|
Using the 'Init_Methods' method of 'mk_constructor', you can have your
|
|
|
|
constructor method automatically call one or more initialization methods.
|
2011-04-14 07:56:01 +00:00
|
|
|
|
|
|
|
* Automatic Construction of objects of Subclasses
|
|
|
|
|
2024-07-11 11:49:39 +00:00
|
|
|
Your constructor can bless objects into one of its subclasses.
|
2011-04-14 07:56:01 +00:00
|
|
|
|
2024-07-11 11:49:39 +00:00
|
|
|
For instance, the 'Fruit' class could bless objects into the 'Fruit::Apple'
|
|
|
|
or 'Fruit::Orange' classes depending on a parameter passed to the
|
|
|
|
constructor.
|
2011-04-14 07:56:01 +00:00
|
|
|
|
2024-07-11 11:49:39 +00:00
|
|
|
See Subclass_Param for details.
|
2011-04-14 07:56:01 +00:00
|
|
|
|
|
|
|
%prep
|
2024-07-11 11:49:39 +00:00
|
|
|
%autosetup -n %{cpan_name}-%{version}
|
|
|
|
|
|
|
|
find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644
|
2011-04-14 07:56:01 +00:00
|
|
|
|
|
|
|
%build
|
2024-07-11 11:49:39 +00:00
|
|
|
perl Makefile.PL INSTALLDIRS=vendor
|
|
|
|
%make_build
|
2011-04-14 07:56:01 +00:00
|
|
|
|
|
|
|
%check
|
2024-07-11 11:49:39 +00:00
|
|
|
make test
|
2011-04-14 07:56:01 +00:00
|
|
|
|
|
|
|
%install
|
|
|
|
%perl_make_install
|
|
|
|
%perl_process_packlist
|
|
|
|
%perl_gen_filelist
|
|
|
|
|
|
|
|
%files -f %{name}.files
|
2011-04-15 07:27:42 +00:00
|
|
|
%doc Changes README
|
2011-04-14 07:56:01 +00:00
|
|
|
|
|
|
|
%changelog
|