Files
perl-WWW-Shorten-Simple/perl-WWW-Shorten-Simple.spec
2025-08-12 18:18:31 +02:00

90 lines
2.9 KiB
RPMSpec

#
# spec file for package perl-WWW-Shorten-Simple
#
# 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 WWW-Shorten-Simple
Name: perl-WWW-Shorten-Simple
Version: 0.20.0
Release: 0
# 0.02 -> normalize -> 0.20.0
%define cpan_version 0.02
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Factory wrapper around WWW::Shorten to avoid imports
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/%{cpan_name}-%{cpan_version}.tar.gz
Source1: cpanspec.yml
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Module::Build)
BuildRequires: perl(Module::Build::Tiny) >= 0.034
BuildRequires: perl(WWW::Shorten)
Requires: perl(WWW::Shorten)
Provides: perl(WWW::Shorten::Simple) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
WWW::Shorten::Simple is a wrapper (factory) around WWW::Shorten so that you
can create an object representing each URL shortening service, instead of
_import_ing 'makeashorterlink' function into your namespace.
This allows you to call multiple URL shortening services in one package,
for instance to call WWW::Shorten::RevCanonical to extract rev="canonical",
fallback to bit.ly if username and API key are present, and then finally to
TinyURL.
use WWW::Shorten::Simple;
my @shorteners = (
WWW::Shorten::Simple->new('RevCanonical'),
WWW::Shorten::Simple->new('Bitly', $bitly_username, $bitly_api_key),
WWW::Shorten::Simple->new('TinyURL'),
);
my $short_url;
for my $shortener (@shorteners) {
$short_url = eval { $shortener->shorten($long_url) } # eval to ignore errors
and last;
}
This wrapper works with most WWW::Shorten implementation that implements
the default 'makeashorterlink' and 'makealongerlink' functions. The options
should be able to be passed as an optional parameters to 'makeashorterlink'
function.
%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 README
%license LICENSE
%changelog