103 lines
3.2 KiB
RPMSpec
103 lines
3.2 KiB
RPMSpec
#
|
|
# spec file for package perl-Data-Stag
|
|
#
|
|
# 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 Data-Stag
|
|
Name: perl-Data-Stag
|
|
Version: 0.140.0
|
|
Release: 0
|
|
# 0.14 -> normalize -> 0.140.0
|
|
%define cpan_version 0.14
|
|
#Upstream: This module is free software. You may distribute this module under the same terms as perl itself
|
|
License: Artistic-1.0 OR GPL-1.0-or-later
|
|
Summary: Structured Tags
|
|
URL: https://metacpan.org/release/%{cpan_name}
|
|
Source0: https://cpan.metacpan.org/authors/id/C/CM/CMUNGALL/%{cpan_name}-%{cpan_version}.tar.gz
|
|
Source1: cpanspec.yml
|
|
Source100: README.md
|
|
BuildRequires: perl
|
|
BuildRequires: perl-macros
|
|
BuildRequires: perl(IO::String)
|
|
Requires: perl(IO::String)
|
|
%{perl_requires}
|
|
|
|
%description
|
|
This module is for manipulating data as hierarchical tag/value pairs
|
|
(Structured TAGs or Simple Tree AGgreggates). These datastructures can be
|
|
represented as nested arrays, which have the advantage of being native to
|
|
perl. A simple example is shown below:
|
|
|
|
[ person=> [ [ family_name => $family_name ],
|
|
[ given_name => $given_name ],
|
|
[ phone_no => $phone_no ] ] ],
|
|
|
|
Data::Stag uses a subset of XML for import and export. This means the
|
|
module can also be used as a general XML parser/writer (with certain
|
|
caveats).
|
|
|
|
The above set of structured tags can be represented in XML as
|
|
|
|
<person>
|
|
<family_name>...</family_name>
|
|
<given_name>...</given_name>
|
|
<phone_no>...</phone_no>
|
|
</person>
|
|
|
|
This datastructure can be examined, manipulated and exported using Stag
|
|
functions or methods:
|
|
|
|
$document = Data::Stag->parse($file);
|
|
@persons = $document->find('person');
|
|
foreach my $person (@person) {
|
|
$person->set('full_name',
|
|
$person->sget('given_name') . ' ' .
|
|
$person->sget('family_name'));
|
|
}
|
|
|
|
Advanced querying is performed by passing functions, for example:
|
|
|
|
# get all people in dataset with name starting 'A'
|
|
@persons =
|
|
$document->where('person',
|
|
sub {shift->sget('family_name') =~ /^A/});
|
|
|
|
One of the things that marks this module out against other XML modules is
|
|
this emphasis on a *functional* approach as an obect-oriented or procedural
|
|
approach.
|
|
|
|
For full information on the stag project, see http://stag.sourceforge.net
|
|
|
|
%prep
|
|
%autosetup -n %{cpan_name}-%{cpan_version}
|
|
|
|
%build
|
|
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
|
|
%make_build
|
|
|
|
%check
|
|
make test
|
|
|
|
%install
|
|
%perl_make_install
|
|
%perl_process_packlist
|
|
%perl_gen_filelist
|
|
|
|
%files -f %{name}.files
|
|
%doc Changes README
|
|
|
|
%changelog
|