Files
perl-String-Diff/perl-String-Diff.spec

107 lines
3.7 KiB
RPMSpec
Raw Normal View History

#
# spec file for package perl-String-Diff
#
# 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/
#
Name: perl-String-Diff
Version: 0.07
Release: 0
%define cpan_name String-Diff
Summary: Simple diff to String
License: Artistic-1.0 OR GPL-1.0-or-later
Group: Development/Libraries/Perl
URL: https://metacpan.org/release/%{cpan_name}
Source: https://cpan.metacpan.org/authors/id/Y/YA/YAPPO/%{cpan_name}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/yappo/p5-String-Diff/commit/cf34e0b93fe89fb24f91cfaf998b5b563f269eb2.patch
Patch1: cf34e0b93fe89fb24f91cfaf998b5b563f269eb2.patch
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Algorithm::Diff)
BuildRequires: perl(Capture::Tiny)
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)
BuildRequires: perl(YAML)
Requires: perl(Algorithm::Diff)
Requires: perl(Capture::Tiny)
Requires: perl(HTML::Entities)
%{perl_requires}
%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 => '<del>',
remove_close => '</del>',
append_open => '<ins>',
append_close => '</ins>',
});
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 <b>Perl</b>',
'this is <b><BIG>R</BIG>uby</b>',
remove_open => '<del>',
remove_close => '</del>',
append_open => '<ins>',
append_close => '</ins>',
escape => sub { encode_entities($_[0]) },
});
is($diff_old, 'this is &lt;b&gt;<del>Perl</del>&lt;/b&gt;');
is($diff_new, 'this is &lt;b&gt;<ins>&lt;BIG&gt;R&lt;/BIG&gt;uby</ins>&lt;/b&gt;');
%prep
%autosetup -n %{cpan_name}-%{version} -p1
%build
perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}
%check
make test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%defattr(-,root,root,755)
%doc Changes README README.mkdn
%changelog