#
# spec file for package perl-String-Diff
#
# Copyright (c) 2025 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 String-Diff
Name: perl-String-Diff
Version: 0.110.0
Release: 0
# 0.11 -> normalize -> 0.110.0
%define cpan_version 0.11
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Simple diff to String
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/S/SC/SCHWIGON/%{cpan_name}-%{cpan_version}.tar.gz
Source1: cpanspec.yml
Source100: README.md
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Algorithm::Diff)
BuildRequires: perl(Test::Base)
BuildRequires: perl(YAML)
Requires: perl(Algorithm::Diff)
Requires: perl(YAML)
Provides: perl(String::Diff) = %{version}
%undefine __perllib_provides
%{perl_requires}
# MANUAL BEGIN
BuildRequires: perl(HTML::Entities)
BuildRequires: perl(Module::Install::GithubMeta)
BuildRequires: perl(Module::Install::ReadmeFromPod)
BuildRequires: perl(Module::Install::ReadmeMarkdownFromPod)
BuildRequires: perl(Module::Install::Repository)
BuildRequires: perl(Test::Base)
Requires: perl(Capture::Tiny)
Requires: perl(HTML::Entities)
# MANUAL END
%description
String::Diff is the difference of a consecutive string is made. after
general diff is done, the difference in the line is searchable.
the mark of the addition and the deletion can be freely changed. the color
is colored to the terminal with ANSI, using the HTML display it.
after the line is divided, diff is taken when 'linebreak' option is
specified.
my($old_string, $new_string) = String::Diff::diff_fully('this is Perl', 'this is Ruby', linebreak => 1);
my($old_string, $new_string) = String::Diff::diff('this is Perl', 'this is Ruby', linebreak => 1);
my $string = String::Diff::diff_merge('this is Perl', 'this is Ruby', linebreak => 1);
my $string = String::Diff::diff_regexp('this is Perl', 'this is Ruby', linebreak => 1);
In diff and diff_merge methods the mark of the difference can be changed.
my $diff = String::Diff::diff('this is Perl', 'this is Ruby',
remove_open => '',
remove_close => '',
append_open => '',
append_close => '',
);
You can escape callback set to diff function and diff_merge function.
use HTML::Entities
my($diff_old, $diff_new) = String::Diff::diff(
'this is Perl',
'this is Ruby',
remove_open => '',
remove_close => '',
append_open => '',
append_close => '',
escape => sub { encode_entities($_[0]) },
});
is($diff_old, 'this is <b>Perl</b>');
is($diff_new, 'this is <b><BIG>R</BIG>uby</b>');
%prep
%autosetup -n %{cpan_name}-%{cpan_version} -p1
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 README README.md
%license LICENSE
%changelog