8
0
Files
perl-Perl-Tidy/perl-Perl-Tidy.spec

220 lines
8.5 KiB
RPMSpec
Raw Normal View History

#
# spec file for package perl-Perl-Tidy
#
# 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-Perl-Tidy
Version: 20150815
Release: 0
%define cpan_name Perl-Tidy
Summary: Parses and beautifies perl source
License: This package is free software and you can redistribute it and/or modify it under the terms of the "GNU General Public License". Please refer to the file "COPYING" for details.
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/Perl-Tidy/
Source0: http://www.cpan.org/authors/id/S/SH/SHANCOCK/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
%{perl_requires}
%description
This module makes the functionality of the perltidy utility available to
perl scripts. Any or all of the input parameters may be omitted, in which
case the @ARGV array will be used to provide input parameters as described
in the perltidy(1) man page.
For example, the perltidy script is basically just this:
use Perl::Tidy;
Perl::Tidy::perltidy();
The call to *perltidy* returns a scalar *$error_flag* which is TRUE if an
error caused premature termination, and FALSE if the process ran to normal
completion. Additional discuss of errors is contained below in the the
ERROR HANDLING manpage section.
The module accepts input and output streams by a variety of methods. The
following list of parameters may be any of the following: a filename, an
ARRAY reference, a SCALAR reference, or an object with either a *getline*
or *print* method, as appropriate.
source - the source of the script to be formatted
destination - the destination of the formatted output
stderr - standard error output
perltidyrc - the .perltidyrc file
logfile - the .LOG file stream, if any
errorfile - the .ERR file stream, if any
dump_options - ref to a hash to receive parameters (see below),
dump_options_type - controls contents of dump_options
dump_getopt_flags - ref to a hash to receive Getopt flags
dump_options_category - ref to a hash giving category of options
dump_abbreviations - ref to a hash giving all abbreviations
The following chart illustrates the logic used to decide how to treat a
parameter.
ref($param) $param is assumed to be:
----------- ---------------------
undef a filename
SCALAR ref to string
ARRAY ref to array
(other) object with getline (if source) or print method
If the parameter is an object, and the object has a *close* method, that
close method will be called at the end of the stream.
* source
If the *source* parameter is given, it defines the source of the input
stream. If an input stream is defined with the *source* parameter then no
other source filenames may be specified in the @ARGV array or *argv*
parameter.
* destination
If the *destination* parameter is given, it will be used to define the
file or memory location to receive output of perltidy.
* stderr
The *stderr* parameter allows the calling program to redirect the stream
that would otherwise go to the standard error output device to any of the
stream types listed above. This stream contains important warnings and
errors related to the parameters passed to perltidy.
* perltidyrc
If the *perltidyrc* file is given, it will be used instead of any
_.perltidyrc_ configuration file that would otherwise be used.
* errorfile
The *errorfile* parameter allows the calling program to capture the
stream that would otherwise go to either a .ERR file. This stream
contains warnings or errors related to the contents of one source file or
stream.
The reason that this is different from the stderr stream is that when
perltidy is called to process multiple files there will be up to one .ERR
file created for each file and it would be very confusing if they were
combined.
However if perltidy is called to process just a single perl script then
it may be more convenient to combine the *errorfile* stream with the
*stderr* stream. This can be done by setting the *-se* parameter, in
which case this parameter is ignored.
* logfile
The *logfile* parameter allows the calling program to capture the log
stream. This stream is only created if requested with a *-g* parameter.
It contains detailed diagnostic information about a script which may be
useful for debugging.
* argv
If the *argv* parameter is given, it will be used instead of the *@ARGV*
array. The *argv* parameter may be a string, a reference to a string, or
a reference to an array. If it is a string or reference to a string, it
will be parsed into an array of items just as if it were a command line
string.
* dump_options
If the *dump_options* parameter is given, it must be the reference to a
hash. In this case, the parameters contained in any perltidyrc
configuration file will be placed in this hash and perltidy will return
immediately. This is equivalent to running perltidy with --dump-options,
except that the perameters are returned in a hash rather than dumped to
standard output. Also, by default only the parameters in the perltidyrc
file are returned, but this can be changed (see the next parameter). This
parameter provides a convenient method for external programs to read a
perltidyrc file. An example program using this feature,
_perltidyrc_dump.pl_, is included in the distribution.
Any combination of the *dump_* parameters may be used together.
* dump_options_type
This parameter is a string which can be used to control the parameters
placed in the hash reference supplied by *dump_options*. The possible
values are 'perltidyrc' (default) and 'full'. The 'full' parameter causes
both the default options plus any options found in a perltidyrc file to
be returned.
* dump_getopt_flags
If the *dump_getopt_flags* parameter is given, it must be the reference
to a hash. This hash will receive all of the parameters that perltidy
understands and flags that are passed to Getopt::Long. This parameter may
be used alone or with the *dump_options* flag. Perltidy will exit
immediately after filling this hash. See the demo program
_perltidyrc_dump.pl_ for example usage.
* dump_options_category
If the *dump_options_category* parameter is given, it must be the
reference to a hash. This hash will receive a hash with keys equal to all
long parameter names and values equal to the title of the corresponding
section of the perltidy manual. See the demo program _perltidyrc_dump.pl_
for example usage.
* dump_abbreviations
If the *dump_abbreviations* parameter is given, it must be the reference
to a hash. This hash will receive all abbreviations used by Perl::Tidy.
See the demo program _perltidyrc_dump.pl_ for example usage.
* prefilter
A code reference that will be applied to the source before tidying. It is
expected to take the full content as a string in its input, and output
the transformed content.
* postfilter
A code reference that will be applied to the tidied result before
outputting. It is expected to take the full content as a string in its
input, and output the transformed content.
Note: A convenient way to check the function of your custom prefilter and
postfilter code is to use the --notidy option, first with just the
prefilter and then with both the prefilter and postfilter. See also the
file *filter_example.pl* in the perltidy distribution.
%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 BUGS CHANGES COPYING docs examples Makefile.npm pm2pl README TODO
%changelog