Files
perl-Env-Path/perl-Env-Path.spec
2025-08-12 18:13:54 +02:00

110 lines
3.6 KiB
RPMSpec

#
# spec file for package perl-Env-Path
#
# 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 Env-Path
Name: perl-Env-Path
Version: 0.190.0
Release: 0
# 0.19 -> normalize -> 0.190.0
%define cpan_version 0.19
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Advanced operations on path variables
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/D/DS/DSB/%{cpan_name}-%{cpan_version}.tar.gz
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
Provides: perl(Env::Path) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
Env::Path presents an object-oriented interface to _path variables_,
defined as that subclass of _environment variables_ which name an ordered
list of filesystem elements separated by a platform-standard _separator_
(typically ':' on UNIX and ';' on Windows).
Of course, core Perl constructs such
$ENV{PATH} .= ":/usr/local/bin";
will suffice for most uses. Env::Path is for the others; cases where you
need to insert or remove interior path entries, strip redundancies, operate
on a pathvar without having to know whether the current platform uses ":"
or ";", operate on a pathvar which may have a different name on different
platforms, etc.
The OO interface is slightly unusual in that the environment variable is
itself the object and the constructor is Env::Path->AUTOLOAD(); thus
Env::Path->MANPATH;
will bless $ENV{MANPATH} into its package while leaving it otherwise
unmodified (with the exception of possible autovivification). Unlike most
objects, this is a scalar and thus can have only one attribute; its value.
In other words, Env::Path simply defines a set of methods a path variable
may call on itself without changing the variable's value or other
semantics.
Also, while the object reference may be assigned and used in the normal
style
my $path = Env::Path->CLASSPATH;
$path->Append('/opt/foo/classes.jar');
a shorthand is also available:
Env::Path->CLASSPATH;
CLASSPATH->Append('/opt/foo/classes.jar');
I.e. the name of the path variable may be used as a proxy for its object
reference. This may be done at 'use' time too:
use Env::Path qw(PATH CLASSPATH); # or qw(:all) to bless all EV's
CLASSPATH->Append('/opt/foo/classes.jar');
The design is intended to make use of this module as lightweight as
possible. Rather than creating a new object to manage an environment
variable, the environment variable is provided a set of methods for
self-modification but is otherwise left undisturbed and can be used in all
normal ways.
%prep
%autosetup -n %{cpan_name}-%{cpan_version}
find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644
%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 envpath examples README
%changelog