#
# spec file for package perl-String-Diff
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://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+
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
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Algorithm::Diff)
BuildRequires: perl(HTML::Entities)
BuildRequires: perl(Module::Install::ReadmeFromPod)
BuildRequires: perl(Module::Install::ReadmeMarkdownFromPod)
BuildRequires: perl(Test::Base)
BuildRequires: perl(YAML)
Requires: perl(Algorithm::Diff)
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 => '',
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
%setup -q -n %{cpan_name}-%{version}
%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