Files
perl-Class-Refresh/perl-Class-Refresh.spec
2025-08-12 18:12:28 +02:00

113 lines
4.1 KiB
RPMSpec

#
# spec file for package perl-Class-Refresh
#
# 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 Class-Refresh
Name: perl-Class-Refresh
Version: 0.70.0
Release: 0
# 0.07 -> normalize -> 0.70.0
%define cpan_version 0.07
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Refresh your classes during runtime
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/D/DO/DOY/%{cpan_name}-%{cpan_version}.tar.gz
Source1: cpanspec.yml
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Class::Load)
BuildRequires: perl(Class::Unload)
BuildRequires: perl(Devel::OverrideGlobalRequire)
BuildRequires: perl(Test::Fatal)
BuildRequires: perl(Test::More) >= 0.88
BuildRequires: perl(Test::Requires)
BuildRequires: perl(Try::Tiny)
Requires: perl(Class::Load)
Requires: perl(Class::Unload)
Requires: perl(Devel::OverrideGlobalRequire)
Requires: perl(Try::Tiny)
Provides: perl(Class::Refresh) = %{version}
%undefine __perllib_provides
%{perl_requires}
# MANUAL BEGIN
# dependency for tests
BuildRequires: perl(Moose)
# MANUAL END
%description
During development, it is fairly common to cycle between writing code and
testing that code. Generally the testing happens within the test suite, but
frequently it is more convenient to test things by hand when tracking down
a bug, or when doing some exploratory coding. In many situations, however,
this becomes inconvenient - for instance, in a REPL, or in a stateful web
application, restarting from the beginning after every code change can get
pretty tedious. This module allows you to reload your application classes
on the fly, so that the code/test cycle becomes a lot easier.
This module takes a hash of import arguments, which can include:
* track_require
use Class::Refresh track_require => 1;
If set, a 'require()' hook will be installed to track modules which are
loaded. This will make the list of modules to reload when 'refresh' is
called more accurate, but may cause issues with other modules which hook
into 'require' (since the hook is global).
This module has several limitations, due to reloading modules in this way
being an inherently fragile operation. Therefore, this module is
recommended for use only in development environments - it should not be
used for reloading things in production.
It makes several assumptions about how code is structured that simplify the
logic involved quite a bit, and make it more reliable when those
assumptions hold, but do make it inappropriate for use in certain cases.
For instance, this module is named 'Class::Refresh' for a reason: it is
only intended for refreshing classes, where each file contains a single
namespace, and each namespace corresponds to a single file, and all
function calls happen through method dispatch. Unlike Module::Refresh,
which makes an effort to track the files where subs were defined, this
module assumes that refreshing a class means wiping out everything in the
class's namespace, and reloading the file corresponding to that class. If
your code includes multiple files that all load things into a common
namespace, or defines multiple classes in a single file, this will likely
not work.
%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
%license LICENSE
%changelog