114 lines
3.8 KiB
RPMSpec
114 lines
3.8 KiB
RPMSpec
#
|
|
# spec file for package perl-Object-Import
|
|
#
|
|
# 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 Object-Import
|
|
Name: perl-Object-Import
|
|
Version: 1.6.0
|
|
Release: 0
|
|
# 1.006 -> normalize -> 1.6.0
|
|
%define cpan_version 1.006
|
|
#Upstream: CHECK(Artistic-1.0 or GPL-1.0-or-later)
|
|
License: Artistic-1.0 OR GPL-3.0-only
|
|
Summary: Import methods of an object as functions to a package
|
|
URL: https://metacpan.org/release/%{cpan_name}
|
|
Source0: https://cpan.metacpan.org/authors/id/C/CO/CORION/%{cpan_name}-%{cpan_version}.tar.gz
|
|
Source1: cpanspec.yml
|
|
Source100: README.md
|
|
BuildArch: noarch
|
|
BuildRequires: perl
|
|
BuildRequires: perl-macros
|
|
BuildRequires: perl(MRO::Compat)
|
|
Requires: perl(MRO::Compat)
|
|
Provides: perl(Object::Import) = %{version}
|
|
%undefine __perllib_provides
|
|
%{perl_requires}
|
|
# MANUAL BEGIN
|
|
BuildRequires: netcfg
|
|
# MANUAL END
|
|
|
|
%description
|
|
This module lets you call methods of a certain object more easily by
|
|
exporting them as functions to a package. The exported functions are not
|
|
called as methods and do not receive an object argument, but instead the
|
|
object is fixed at the time you import them with this module.
|
|
|
|
You use the module with the following syntax:
|
|
|
|
use Object::Import $object, %options;
|
|
|
|
Here, '$object' is the object from which you want to import the methods.
|
|
This can be a perl object (blessed reference), or the name of a package
|
|
that has class methods.
|
|
|
|
As usual, a 'use' statement is executed in compile time, so you should take
|
|
care not to use values that you compute only in run-time, eg.
|
|
|
|
my $object = Foo::Bar->new();
|
|
use Object::Import $object; # WRONG: $object is not yet initialized
|
|
|
|
Instead, you have to create the object before you import, such as
|
|
|
|
use Object::Import Foo::Bar->new();
|
|
|
|
You can also call import in run-time, eg.
|
|
|
|
use Object::Import ();
|
|
my $object = Foo::Bar->new();
|
|
import Object::Import $object;
|
|
|
|
but in that case, you can't call the imported functions without
|
|
parenthesis.
|
|
|
|
If you don't give an explicit list of methods to export, Object::Import
|
|
tries to find out what callable methods the object has and import all of
|
|
them. Some methods are excluded from exporting in this case, namely any
|
|
methods where exporting would overwrite a function existing in the target
|
|
package or would override a builtin function, also any methods with names
|
|
that are special to perl, such as 'DESTROY', and any methods whose name
|
|
starts with an underscore. This automatic search for methods is quite
|
|
fragile because of the way perl OO works, so it can find subroutines that
|
|
shouldn't actually be called as methods, or not find methods that can
|
|
actually be called. In particular, even if you import an object from a
|
|
purely object oriented module, it can find non-method subs imported from
|
|
other (non-OO) modules.
|
|
|
|
If you do give a list of methods to export, Object::Import trusts you know
|
|
what you mean, so it exports all those subs even if it has to replace
|
|
existing subs or break something else.
|
|
|
|
%prep
|
|
%autosetup -n %{cpan_name}-%{cpan_version}
|
|
|
|
%build
|
|
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 README TODO
|
|
%license ARTISTIC GPL
|
|
|
|
%changelog
|