Hello community,
here is the log from the commit of package perl-Text-RecordParser for
openSUSE:Factory checked in at 2015-04-18 10:39:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Text-RecordParser (Old)
and /work/SRC/openSUSE:Factory/.perl-Text-RecordParser.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Text-RecordParser"
Changes:
--------
---
/work/SRC/openSUSE:Factory/perl-Text-RecordParser/perl-Text-RecordParser.changes
2012-01-17 16:14:24.000000000 +0100
+++
/work/SRC/openSUSE:Factory/.perl-Text-RecordParser.new/perl-Text-RecordParser.changes
2015-04-18 10:39:53.000000000 +0200
@@ -1,0 +2,27 @@
+Tue Apr 14 21:13:25 UTC 2015 - [email protected]
+
+- updated to 1.6.3
+ see /usr/share/doc/packages/perl-Text-RecordParser/Changes
+
+ 1.6.3 August 9 2012
+
+ - Fixed bug in "Build.PL" regarding "podselect," updated Build.PL reqs
+
+ 1.6.2 August 9 2012
+
+ - Made output of "tablify -v" prettier using Text::Autoformat
+
+ 1.6.1 April 30 2013
+
+ - Removed a debug statement
+ - Fixed INSTALL
+
+ 1.6.0 April 30 2013
+
+ - Moved to Git repo at github.com:kyclark/text-recordparser.git
+ - Changes to "tablify"
+ - Allow for comment lines
+ - Added more single-letter argument names
+ - Allow for definition of column names
+
+-------------------------------------------------------------------
Old:
----
Text-RecordParser-v1.5.0.tar.gz
New:
----
Text-RecordParser-v1.6.3.tar.gz
cpanspec.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Text-RecordParser.spec ++++++
--- /var/tmp/diff_new_pack.OdWP57/_old 2015-04-18 10:39:53.000000000 +0200
+++ /var/tmp/diff_new_pack.OdWP57/_new 2015-04-18 10:39:53.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package perl-Text-RecordParser
#
-# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# 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
@@ -15,45 +15,49 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
+
Name: perl-Text-RecordParser
+Version: 1.6.3
+Release: 0
+#Upstream: SUSE-Public-Domain
%define cpan_name Text-RecordParser
-Summary: Read record-oriented files
+Summary: Read Record-Oriented Files
License: GPL-2.0
Group: Development/Libraries/Perl
-Version: 1.5.0
-Release: 0
Url: http://search.cpan.org/dist/Text-RecordParser/
-Source:
http://www.cpan.org/authors/id/K/KC/KCLARK/Text-RecordParser-v%{version}.tar.gz
+Source0:
http://www.cpan.org/authors/id/K/KC/KCLARK/%{cpan_name}-v%{version}.tar.gz
+Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-%{perl_requires}
-BuildRequires: cairo
-BuildRequires: ghostscript-fonts-std
-BuildRequires: graphviz-gnome
-BuildRequires: pango
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Class::Accessor)
-BuildRequires: perl(GraphViz)
BuildRequires: perl(IO::Scalar)
BuildRequires: perl(List::MoreUtils)
-BuildRequires: perl(List::Util)
-BuildRequires: perl(Module::Build)
+BuildRequires: perl(Module::Build) >= 0.400000
+BuildRequires: perl(Pod::Markdown)
+BuildRequires: perl(Pod::Readme)
BuildRequires: perl(Readonly)
-BuildRequires: perl(Readonly::XS)
BuildRequires: perl(Test::Exception)
-BuildRequires: perl(Text::TabularDisplay) >= 1.22
+BuildRequires: perl(Text::Autoformat)
BuildRequires: perl(version)
Requires: perl(Class::Accessor)
-Requires: perl(GraphViz)
Requires: perl(IO::Scalar)
Requires: perl(List::MoreUtils)
-Requires: perl(List::Util)
Requires: perl(Readonly)
-Requires: perl(Readonly::XS)
-Requires: perl(Text::TabularDisplay) >= 1.22
+Requires: perl(Text::Autoformat)
Requires: perl(version)
-Requires: cairo pango graphviz-gnome ghostscript-fonts-std
+Recommends: perl(GraphViz)
+Recommends: perl(Readonly::XS)
+Recommends: perl(Text::TabularDisplay) >= 1.22
+%{perl_requires}
+# MANUAL BEGIN
+BuildRequires: cairo
+BuildRequires: ghostscript-fonts-std
+BuildRequires: graphviz-gnome
+BuildRequires: pango
+BuildRequires: perl(GraphViz)
+# MANUAL END
%description
This module is for reading record-oriented data in a delimited text file.
@@ -61,10 +65,10 @@
separated by commas or tabs, but this module aims to provide a consistent
interface for handling sequential records in a file however they may be
delimited. Typically this data lists the fields in the first line of the
-file, in which case you should call bind_header to bind the field name (or
-not, and it will be called implicitly). If the first line contains data,
-you can still bind your own field names via bind_fields. Either way, you
-can then use many methods to get at the data as arrays or hashes.
+file, in which case you should call 'bind_header' to bind the field name
+(or not, and it will be called implicitly). If the first line contains
+data, you can still bind your own field names via 'bind_fields'. Either
+way, you can then use many methods to get at the data as arrays or hashes.
%prep
%setup -q -n %{cpan_name}-v%{version}
@@ -77,14 +81,11 @@
./Build test
%install
-./Build install destdir=$RPM_BUILD_ROOT create_packlist=0
+./Build install destdir=%{buildroot} create_packlist=0
%perl_gen_filelist
-%clean
-%{__rm} -rf $RPM_BUILD_ROOT
-
%files -f %{name}.files
-%defattr(-,root,root,-)
-%doc Changes README TODO
+%defattr(-,root,root,755)
+%doc Changes README.md TODO
%changelog
++++++ Text-RecordParser-v1.5.0.tar.gz -> Text-RecordParser-v1.6.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/Build.PL
new/Text-RecordParser-v1.6.3/Build.PL
--- old/Text-RecordParser-v1.5.0/Build.PL 2010-07-21 18:12:01.000000000
+0200
+++ new/Text-RecordParser-v1.6.3/Build.PL 2013-08-09 19:05:58.000000000
+0200
@@ -2,27 +2,72 @@
use Module::Build;
-my $build = Module::Build->new(
+my $class = Module::Build->subclass(
+ class => 'TRP::Builder',
+ code => q*
+ sub ACTION_docs {
+ require 'Pod/Readme.pm';
+ require 'Pod/Select.pm';
+ require 'Pod/Markdown.pm';
+
+ my $self = shift;
+ my $pod = 'README.pod';
+
+ Pod::Select::podselect({ -output => $pod },
'lib/Text/RecordParser.pm');
+
+ my $parser = Pod::Readme->new();
+
+ $parser->parse_from_file('README.pod', 'README');
+
+ open my $pod_fh, '<', $pod or die "Can't read POD '$pod'";
+ open my $md_fh , '>', 'README.md' or die "Can't write README.md";
+
+ my $md = Pod::Markdown->new;
+ $md->parse_from_filehandle($pod_fh);
+ print $md_fh $md->as_markdown;
+
+ close $pod_fh;
+ close $md_fh;
+
+ return $self->SUPER::ACTION_docs;
+ }
+ *
+);
+
+my $build = $class->new(
module_name => 'Text::RecordParser',
dist_author => 'Ken Youens-Clark <[email protected]>',
dist_version_from => 'lib/Text/RecordParser.pm',
add_to_cleanup => [ '$(DISTNAME)-$(VERSION).tar.gz' ],
- create_readme => 1,
dist_abstract => 'Parse record-oriented data in a text file',
license => 'gpl',
script_files => ['bin/tablify', 'bin/tabmerge', 'bin/tab2graph'],
+
+ configure_requires => {
+ 'Module::Build' => 0.40,
+ 'Pod::Markdown' => 0,
+ 'Pod::Readme' => 0,
+ 'Pod::Select' => 0,
+ },
+
requires => {
'IO::Scalar' => 0,
'Class::Accessor' => 0,
'Readonly' => 0,
'List::Util' => 0,
'List::MoreUtils' => 0,
+ 'Text::Autoformat' => 0,
'version' => 0,
},
+
build_requires => {
'Test::More' => 0,
'Test::Exception' => 0,
+ 'Pod::Readme' => 0,
+ 'Pod::Select' => 0,
+ 'Pod::Markdown' => 0,
},
+
recommends => {
'Readonly::XS' => 0,
'Text::TabularDisplay' => '1.22',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/Changes
new/Text-RecordParser-v1.6.3/Changes
--- old/Text-RecordParser-v1.5.0/Changes 2010-07-21 18:12:01.000000000
+0200
+++ new/Text-RecordParser-v1.6.3/Changes 2013-08-09 19:05:58.000000000
+0200
@@ -1,3 +1,24 @@
+1.6.3 August 9 2012
+
+- Fixed bug in "Build.PL" regarding "podselect," updated Build.PL reqs
+
+1.6.2 August 9 2012
+
+- Made output of "tablify -v" prettier using Text::Autoformat
+
+1.6.1 April 30 2013
+
+- Removed a debug statement
+- Fixed INSTALL
+
+1.6.0 April 30 2013
+
+- Moved to Git repo at github.com:kyclark/text-recordparser.git
+- Changes to "tablify"
+ - Allow for comment lines
+ - Added more single-letter argument names
+ - Allow for definition of column names
+
1.5.0 July 21 2010
- Some small changeds to be more defensive about non-existent fields
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/INSTALL
new/Text-RecordParser-v1.6.3/INSTALL
--- old/Text-RecordParser-v1.5.0/INSTALL 2010-07-21 18:12:01.000000000
+0200
+++ new/Text-RecordParser-v1.6.3/INSTALL 2013-08-09 19:05:58.000000000
+0200
@@ -1,5 +1,4 @@
-perl Makefile.PL;
-make;
-make test;
-su;
-make install;
+$ perl Build.PL
+$ sudo cpanm --installdeps .
+$ ./Build test
+$ sudo ./Build install
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/MANIFEST
new/Text-RecordParser-v1.6.3/MANIFEST
--- old/Text-RecordParser-v1.5.0/MANIFEST 2010-07-21 18:12:01.000000000
+0200
+++ new/Text-RecordParser-v1.6.3/MANIFEST 2013-08-09 19:05:58.000000000
+0200
@@ -10,8 +10,7 @@
lib/Text/RecordParser/Tab.pm
Makefile.PL
MANIFEST This list of files
-META.yml
-README
+README.md
t/00-pipe.t
t/01-new.t
t/02-filename-fh.t
@@ -48,3 +47,5 @@
t/pod-coverage.t
t/pod.t
TODO
+META.yml
+META.json
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/META.json
new/Text-RecordParser-v1.6.3/META.json
--- old/Text-RecordParser-v1.5.0/META.json 1970-01-01 01:00:00.000000000
+0100
+++ new/Text-RecordParser-v1.6.3/META.json 2013-08-09 19:05:58.000000000
+0200
@@ -0,0 +1,72 @@
+{
+ "abstract" : "Parse record-oriented data in a text file",
+ "author" : [
+ "Ken Youens-Clark <[email protected]>"
+ ],
+ "dynamic_config" : 1,
+ "generated_by" : "Module::Build version 0.4007, CPAN::Meta::Converter
version 2.120921",
+ "license" : [
+ "open_source"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Text-RecordParser",
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "Pod::Markdown" : "0",
+ "Pod::Readme" : "0",
+ "Pod::Select" : "0",
+ "Test::Exception" : "0",
+ "Test::More" : "0"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "Module::Build" : "0.4",
+ "Pod::Markdown" : "0",
+ "Pod::Readme" : "0",
+ "Pod::Select" : "0"
+ }
+ },
+ "runtime" : {
+ "recommends" : {
+ "GraphViz" : "0",
+ "Readonly::XS" : "0",
+ "Text::TabularDisplay" : "1.22"
+ },
+ "requires" : {
+ "Class::Accessor" : "0",
+ "IO::Scalar" : "0",
+ "List::MoreUtils" : "0",
+ "List::Util" : "0",
+ "Readonly" : "0",
+ "Text::Autoformat" : "0",
+ "version" : "0"
+ }
+ }
+ },
+ "provides" : {
+ "Text::RecordParser" : {
+ "file" : "lib/Text/RecordParser.pm",
+ "version" : "v1.6.3"
+ },
+ "Text::RecordParser::Object" : {
+ "file" : "lib/Text/RecordParser/Object.pm",
+ "version" : "v1.4.0"
+ },
+ "Text::RecordParser::Tab" : {
+ "file" : "lib/Text/RecordParser/Tab.pm",
+ "version" : "v1.4.0"
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "license" : [
+ "http://opensource.org/licenses/gpl-license.php"
+ ]
+ },
+ "version" : "v1.6.3"
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/META.yml
new/Text-RecordParser-v1.6.3/META.yml
--- old/Text-RecordParser-v1.5.0/META.yml 2010-07-21 18:12:01.000000000
+0200
+++ new/Text-RecordParser-v1.6.3/META.yml 2013-08-09 19:05:58.000000000
+0200
@@ -3,12 +3,19 @@
author:
- 'Ken Youens-Clark <[email protected]>'
build_requires:
+ Pod::Markdown: 0
+ Pod::Readme: 0
+ Pod::Select: 0
Test::Exception: 0
Test::More: 0
configure_requires:
- Module::Build: 0.36
-generated_by: 'Module::Build version 0.3607'
-license: gpl
+ Module::Build: 0.4
+ Pod::Markdown: 0
+ Pod::Readme: 0
+ Pod::Select: 0
+dynamic_config: 1
+generated_by: 'Module::Build version 0.4007, CPAN::Meta::Converter version
2.120921'
+license: open_source
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
@@ -16,7 +23,7 @@
provides:
Text::RecordParser:
file: lib/Text/RecordParser.pm
- version: v1.5.0
+ version: v1.6.3
Text::RecordParser::Object:
file: lib/Text/RecordParser/Object.pm
version: v1.4.0
@@ -33,7 +40,8 @@
List::MoreUtils: 0
List::Util: 0
Readonly: 0
+ Text::Autoformat: 0
version: 0
resources:
license: http://opensource.org/licenses/gpl-license.php
-version: v1.5.0
+version: v1.6.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/README
new/Text-RecordParser-v1.6.3/README
--- old/Text-RecordParser-v1.5.0/README 2010-07-21 18:12:01.000000000 +0200
+++ new/Text-RecordParser-v1.6.3/README 1970-01-01 01:00:00.000000000 +0100
@@ -1,430 +0,0 @@
-NAME
- Text::RecordParser - read record-oriented files
-
-SYNOPSIS
- use Text::RecordParser;
-
- # use default record (\n) and field (,) separators
- my $p = Text::RecordParser->new( $file );
-
- # or be explicit
- my $p = Text::RecordParser->new({
- filename => $file,
- field_separator => "\t",
- });
-
- $p->filename('foo.csv');
-
- # Split records on two newlines
- $p->record_separator("\n\n");
-
- # Split fields on tabs
- $p->field_separator("\t");
-
- # Skip lines beginning with hashes
- $p->comment( qr/^#/ );
-
- # Trim whitespace
- $p->trim(1);
-
- # Use the fields in the first line as column names
- $p->bind_header;
-
- # Get a list of the header fields (in order)
- my @columns = $p->field_list;
-
- # Extract a particular field from the next row
- my ( $name, $age ) = $p->extract( qw[name age] );
-
- # Return all the fields from the next row
- my @fields = $p->fetchrow_array;
-
- # Define a field alias
- $p->set_field_alias( name => 'handle' );
-
- # Return all the fields from the next row as a hashref
- my $record = $p->fetchrow_hashref;
- print $record->{'name'};
- # or
- print $record->{'handle'};
-
- # Return the record as an object with fields as accessors
- my $object = $p->fetchrow_object;
- print $object->name; # or $object->handle;
-
- # Get all data as arrayref of arrayrefs
- my $data = $p->fetchall_arrayref;
-
- # Get all data as arrayref of hashrefs
- my $data = $p->fetchall_arrayref( { Columns => {} } );
-
- # Get all data as hashref of hashrefs
- my $data = $p->fetchall_hashref('name');
-
-DESCRIPTION
- This module is for reading record-oriented data in a delimited text
- file. The most common example have records separated by newlines and
- fields separated by commas or tabs, but this module aims to provide a
- consistent interface for handling sequential records in a file however
- they may be delimited. Typically this data lists the fields in the first
- line of the file, in which case you should call "bind_header" to bind
- the field name (or not, and it will be called implicitly). If the first
- line contains data, you can still bind your own field names via
- "bind_fields". Either way, you can then use many methods to get at the
- data as arrays or hashes.
-
-METHODS
- new
- This is the object constructor. It takes a hash (or hashref) of
- arguments. Each argument can also be set through the method of the same
- name.
-
- * filename
-
- The path to the file being read. If the filename is passed and the
- fh is not, then it will open a filehandle on that file and sets "fh"
- accordingly.
-
- * comment
-
- A compiled regular expression identifying comment lines that should
- be skipped.
-
- * data
-
- The data to read.
-
- * fh
-
- The filehandle of the file to read.
-
- * field_separator | fs
-
- The field separator (default is comma).
-
- * record_separator | rs
-
- The record separator (default is newline).
-
- * field_filter
-
- A callback applied to all the fields as they are read.
-
- * header_filter
-
- A callback applied to the column names.
-
- * trim
-
- Boolean to enable trimming of leading and trailing whitespace from
- fields (useful if splitting on whitespace only).
-
- See methods for each argument name for more information.
-
- Alternately, if you supply a single argument to "new", it will be
- treated as the "filename" argument.
-
- bind_fields
- $p->bind_fields( qw[ name rank serial_number ] );
-
- Takes an array of field names and memorizes the field positions for
- later use. If the input file has no header line but you still wish to
- retrieve the fields by name (or even if you want to call "bind_header"
- and then give your own field names), simply pass in the an array of
- field names you wish to use.
-
- Pass in an empty array reference to unset:
-
- $p->bind_field( [] ); # unsets fields
-
- bind_header
- $p->bind_header;
- my $name = $p->extract('name');
-
- Takes the fields from the next row under the cursor and assigns the
- field names to the values. Usually you would call this immediately after
- opening the file in order to bind the field names in the first row.
-
- comment
- $p->comment( qr/^#/ ); # Perl-style comments
- $p->comment( qr/^--/ ); # SQL-style comments
-
- Takes a regex to apply to a record to see if it looks like a comment to
- skip.
-
- data
- $p->data( $string );
- $p->data( \$string );
- $p->data( @lines );
- $p->data( [$line1, $line2, $line3] );
- $p->data( IO::File->new('<data') );
-
- Allows a scalar, scalar reference, glob, array, or array reference as
- the thing to read instead of a file handle.
-
- It's not advised to pass a filehandle to "data" as it will read the
- entire contents of the file rather than one line at a time if you set it
- via "fh".
-
- extract
- my ( $foo, $bar, $baz ) = $p->extract( qw[ foo bar baz ] );
-
- Extracts a list of fields out of the last row read. The field names must
- correspond to the field names bound either via "bind_fields" or
- "bind_header".
-
- fetchrow_array
- my @values = $p->fetchrow_array;
-
- Reads a row from the file and returns an array or array reference of the
- fields.
-
- fetchrow_hashref
- my $record = $p->fetchrow_hashref;
- print "Name = ", $record->{'name'}, "\n";
-
- Reads a line of the file and returns it as a hash reference. The keys of
- the hashref are the field names bound via "bind_fields" or
- "bind_header". If you do not bind fields prior to calling this method,
- the "bind_header" method will be implicitly called for you.
-
- fetchrow_object
- while ( my $object = $p->fetchrow_object ) {
- my $id = $object->id;
- my $name = $object->naem; # <-- this will throw a runtime error
- }
-
- This will return the next data record as a Text::RecordParser::Object
- object that has read-only accessor methods of the field names and any
- aliases. This allows you to enforce field names, further helping ensure
- that your code is reading the input file correctly. That is, if you are
- using the "fetchrow_hashref" method to read each line, you may misspell
- the hash key and introduce a bug in your code. With this method, Perl
- will throw an error if you attempt to read a field not defined in the
- file's headers. Additionally, any defined field aliases will be created
- as additional accessor methods.
-
- fetchall_arrayref
- my $records = $p->fetchall_arrayref;
- for my $record ( @$records ) {
- print "Name = ", $record->[0], "\n";
- }
-
- my $records = $p->fetchall_arrayref( { Columns => {} } );
- for my $record ( @$records ) {
- print "Name = ", $record->{'name'}, "\n";
- }
-
- Like DBI's fetchall_arrayref, returns an arrayref of arrayrefs. Also
- accepts optional "{ Columns => {} }" argument to return an arrayref of
- hashrefs.
-
- fetchall_hashref
- my $records = $p->fetchall_hashref('id');
- for my $id ( keys %$records ) {
- my $record = $records->{ $id };
- print "Name = ", $record->{'name'}, "\n";
- }
-
- Like DBI's fetchall_hashref, this returns a hash reference of hash
- references. The keys of the top-level hashref are the field values of
- the field argument you supply. The field name you supply can be a field
- created by a "field_compute".
-
- fh
- open my $fh, '<', $file or die $!;
- $p->fh( $fh );
-
- Gets or sets the filehandle of the file being read.
-
- field_compute
- A callback applied to the fields identified by position (or field name
- if "bind_fields" or "bind_header" was called).
-
- The callback will be passed two arguments:
-
- 1 The current field
-
- 2 A reference to all the other fields, either as an array or hash
- reference, depending on the method which you called.
-
- If data looks like this:
-
- parent children
- Mike Greg,Peter,Bobby
- Carol Marcia,Jane,Cindy
-
- You could split the "children" field into an array reference with the
- values like so:
-
- $p->field_compute( 'children', sub { [ split /,/, shift() ] } );
-
- The field position or name doesn't actually have to exist, which means
- you could create new, computed fields on-the-fly. E.g., if you data
- looks like this:
-
- 1,3,5
- 32,4,1
- 9,5,4
-
- You could write a field_compute like this:
-
- $p->field_compute( 3,
- sub {
- my ( $cur, $others ) = @_;
- my $sum;
- $sum += $_ for @$others;
- return $sum;
- }
- );
-
- Field "3" will be created as the sum of the other fields. This allows
- you to further write:
-
- my $data = $p->fetchall_arrayref;
- for my $rec ( @$data ) {
- print "$rec->[0] + $rec->[1] + $rec->[2] = $rec->[3]\n";
- }
-
- Prints:
-
- 1 + 3 + 5 = 9
- 32 + 4 + 1 = 37
- 9 + 5 + 4 = 18
-
- field_filter
- $p->field_filter( sub { $_ = shift; uc(lc($_)) } );
-
- A callback which is applied to each field. The callback will be passed
- the current value of the field. Whatever is passed back will become the
- new value of the field. The above example capitalizes field values. To
- unset the filter, pass in the empty string.
-
- field_list
- $p->bind_fields( qw[ foo bar baz ] );
- my @fields = $p->field_list;
- print join ', ', @fields; # prints "foo, bar, baz"
-
- Returns the fields bound via "bind_fields" (or "bind_header").
-
- field_positions
- my %positions = $p->field_positions;
-
- Returns a hash of the fields and their positions bound via "bind_fields"
- (or "bind_header"). Mostly for internal use.
-
- field_separator
- $p->field_separator("\t"); # splits fields on tabs
- $p->field_separator('::'); # splits fields on double colons
- $p->field_separator(qr/\s+/); # splits fields on whitespace
- my $sep = $p->field_separator; # returns the current separator
-
- Gets and sets the token to use as the field delimiter. Regular
- expressions can be specified using qr//. If not specified, it will take
- a guess based on the filename extension ("comma" for ".txt," ".dat," or
- ".csv"; "tab" for ".tab"). The default is a comma.
-
- filename
- $p->filename('/path/to/file.dat');
-
- Gets or sets the complete path to the file to be read. If a file is
- already opened, then the handle on it will be closed and a new one
- opened on the new file.
-
- get_field_aliases
- my @aliases = $p->get_field_aliases('name');
-
- Allows you to define alternate names for fields, e.g., sometimes your
- input file calls city "town" or "township," sometimes a file uses
- "Moniker" instead of "name."
-
- header_filter
- $p->header_filter( sub { $_ = shift; s/\s+/_/g; lc $_ } );
-
- A callback applied to column header names. The callback will be passed
- the current value of the header. Whatever is returned will become the
- new value of the header. The above example collapses spaces into a
- single underscore and lowercases the letters. To unset a filter, pass in
- the empty string.
-
- record_separator
- $p->record_separator("\n//\n");
- $p->field_separator("\n");
-
- Gets and sets the token to use as the record separator. The default is a
- newline ("\n").
-
- The above example would read a file that looks like this:
-
- field1
- field2
- field3
- //
- data1
- data2
- data3
- //
-
- set_field_alias
- $p->set_field_alias({
- name => 'Moniker,handle', # comma-separated string
- city => [ qw( town township ) ], # or anonymous arrayref
- });
-
- Allows you to define alternate names for fields, e.g., sometimes your
- input file calls city "town" or "township," sometimes a file uses
- "Moniker" instead of "name."
-
- trim
- my $trim_value = $p->trim(1);
-
- Provide "true" argument to remove leading and trailing whitespace from
- fields. Use a "false" argument to disable.
-
-AUTHOR
- Ken Youens-Clark <[email protected]>
-
-CREDITS
- Thanks to the following:
-
- * Benjamin Tilly
-
- For Text::xSV, the inspirado for this module
-
- * Tim Bunce et al.
-
- For DBI, from which many of the methods were shamelessly stolen
-
- * Tom Aldcroft
-
- For contributing code to make it easy to parse whitespace-delimited
- data
-
- * Liya Ren
-
- For catching the column-ordering error when parsing with
- "no-headers"
-
- * Sharon Wei
-
- For catching bug in "extract" that sets up infinite loops
-
- * Lars Thegler
-
- For bug report on missing "script_files" arg in Build.PL
-
-BUGS
- None known. Please use http://rt.cpan.org/ for reporting bugs.
-
-LICENSE AND COPYRIGHT
- Copyright (C) 2006-10 Ken Youens-Clark. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/README.md
new/Text-RecordParser-v1.6.3/README.md
--- old/Text-RecordParser-v1.5.0/README.md 1970-01-01 01:00:00.000000000
+0100
+++ new/Text-RecordParser-v1.6.3/README.md 2013-08-09 19:05:58.000000000
+0200
@@ -0,0 +1,466 @@
+# NAME
+
+Text::RecordParser - read record-oriented files
+
+# SYNOPSIS
+
+ use Text::RecordParser;
+
+ # use default record (\n) and field (,) separators
+ my $p = Text::RecordParser->new( $file );
+
+ # or be explicit
+ my $p = Text::RecordParser->new({
+ filename => $file,
+ field_separator => "\t",
+ });
+
+ $p->filename('foo.csv');
+
+ # Split records on two newlines
+ $p->record_separator("\n\n");
+
+ # Split fields on tabs
+ $p->field_separator("\t");
+
+ # Skip lines beginning with hashes
+ $p->comment( qr/^#/ );
+
+ # Trim whitespace
+ $p->trim(1);
+
+ # Use the fields in the first line as column names
+ $p->bind_header;
+
+ # Get a list of the header fields (in order)
+ my @columns = $p->field_list;
+
+ # Extract a particular field from the next row
+ my ( $name, $age ) = $p->extract( qw[name age] );
+
+ # Return all the fields from the next row
+ my @fields = $p->fetchrow_array;
+
+ # Define a field alias
+ $p->set_field_alias( name => 'handle' );
+
+ # Return all the fields from the next row as a hashref
+ my $record = $p->fetchrow_hashref;
+ print $record->{'name'};
+ # or
+ print $record->{'handle'};
+
+ # Return the record as an object with fields as accessors
+ my $object = $p->fetchrow_object;
+ print $object->name; # or $object->handle;
+
+ # Get all data as arrayref of arrayrefs
+ my $data = $p->fetchall_arrayref;
+
+ # Get all data as arrayref of hashrefs
+ my $data = $p->fetchall_arrayref( { Columns => {} } );
+
+ # Get all data as hashref of hashrefs
+ my $data = $p->fetchall_hashref('name');
+
+# DESCRIPTION
+
+This module is for reading record-oriented data in a delimited text
+file. The most common example have records separated by newlines and
+fields separated by commas or tabs, but this module aims to provide a
+consistent interface for handling sequential records in a file however
+they may be delimited. Typically this data lists the fields in the
+first line of the file, in which case you should call `bind_header`
+to bind the field name (or not, and it will be called implicitly). If
+the first line contains data, you can still bind your own field names
+via `bind_fields`. Either way, you can then use many methods to get
+at the data as arrays or hashes.
+
+# METHODS
+
+## new
+
+This is the object constructor. It takes a hash (or hashref) of
+arguments. Each argument can also be set through the method of the
+same name.
+
+- filename
+
+ The path to the file being read. If the filename is passed and the fh
+ is not, then it will open a filehandle on that file and sets `fh`
+ accordingly.
+
+- comment
+
+ A compiled regular expression identifying comment lines that should
+ be skipped.
+
+- data
+
+ The data to read.
+
+- fh
+
+ The filehandle of the file to read.
+
+- field\_separator | fs
+
+ The field separator (default is comma).
+
+- record\_separator | rs
+
+ The record separator (default is newline).
+
+- field\_filter
+
+ A callback applied to all the fields as they are read.
+
+- header\_filter
+
+ A callback applied to the column names.
+
+- trim
+
+ Boolean to enable trimming of leading and trailing whitespace from fields
+ (useful if splitting on whitespace only).
+
+See methods for each argument name for more information.
+
+Alternately, if you supply a single argument to `new`, it will be
+treated as the `filename` argument.
+
+## bind\_fields
+
+ $p->bind_fields( qw[ name rank serial_number ] );
+
+Takes an array of field names and memorizes the field positions for
+later use. If the input file has no header line but you still wish to
+retrieve the fields by name (or even if you want to call
+`bind_header` and then give your own field names), simply pass in the
+an array of field names you wish to use.
+
+Pass in an empty array reference to unset:
+
+ $p->bind_field( [] ); # unsets fields
+
+## bind\_header
+
+ $p->bind_header;
+ my $name = $p->extract('name');
+
+Takes the fields from the next row under the cursor and assigns the field
+names to the values. Usually you would call this immediately after
+opening the file in order to bind the field names in the first row.
+
+## comment
+
+ $p->comment( qr/^#/ ); # Perl-style comments
+ $p->comment( qr/^--/ ); # SQL-style comments
+
+Takes a regex to apply to a record to see if it looks like a comment
+to skip.
+
+## data
+
+ $p->data( $string );
+ $p->data( \$string );
+ $p->data( @lines );
+ $p->data( [$line1, $line2, $line3] );
+ $p->data( IO::File->new('<data') );
+
+Allows a scalar, scalar reference, glob, array, or array reference as
+the thing to read instead of a file handle.
+
+It's not advised to pass a filehandle to `data` as it will read the
+entire contents of the file rather than one line at a time if you set
+it via `fh`.
+
+## extract
+
+ my ( $foo, $bar, $baz ) = $p->extract( qw[ foo bar baz ] );
+
+Extracts a list of fields out of the last row read. The field names
+must correspond to the field names bound either via `bind_fields` or
+`bind_header`.
+
+## fetchrow\_array
+
+ my @values = $p->fetchrow_array;
+
+Reads a row from the file and returns an array or array reference
+of the fields.
+
+## fetchrow\_hashref
+
+ my $record = $p->fetchrow_hashref;
+ print "Name = ", $record->{'name'}, "\n";
+
+Reads a line of the file and returns it as a hash reference. The keys
+of the hashref are the field names bound via `bind_fields` or
+`bind_header`. If you do not bind fields prior to calling this method,
+the `bind_header` method will be implicitly called for you.
+
+## fetchrow\_object
+
+ while ( my $object = $p->fetchrow_object ) {
+ my $id = $object->id;
+ my $name = $object->naem; # <-- this will throw a runtime error
+ }
+
+This will return the next data record as a Text::RecordParser::Object
+object that has read-only accessor methods of the field names and any
+aliases. This allows you to enforce field names, further helping
+ensure that your code is reading the input file correctly. That is,
+if you are using the "fetchrow\_hashref" method to read each line, you
+may misspell the hash key and introduce a bug in your code. With this
+method, Perl will throw an error if you attempt to read a field not
+defined in the file's headers. Additionally, any defined field
+aliases will be created as additional accessor methods.
+
+## fetchall\_arrayref
+
+ my $records = $p->fetchall_arrayref;
+ for my $record ( @$records ) {
+ print "Name = ", $record->[0], "\n";
+ }
+
+ my $records = $p->fetchall_arrayref( { Columns => {} } );
+ for my $record ( @$records ) {
+ print "Name = ", $record->{'name'}, "\n";
+ }
+
+Like DBI's fetchall\_arrayref, returns an arrayref of arrayrefs. Also
+accepts optional "{ Columns => {} }" argument to return an arrayref of
+hashrefs.
+
+## fetchall\_hashref
+
+ my $records = $p->fetchall_hashref('id');
+ for my $id ( keys %$records ) {
+ my $record = $records->{ $id };
+ print "Name = ", $record->{'name'}, "\n";
+ }
+
+Like DBI's fetchall\_hashref, this returns a hash reference of hash
+references. The keys of the top-level hashref are the field values
+of the field argument you supply. The field name you supply can be
+a field created by a `field_compute`.
+
+## fh
+
+ open my $fh, '<', $file or die $!;
+ $p->fh( $fh );
+
+Gets or sets the filehandle of the file being read.
+
+## field\_compute
+
+A callback applied to the fields identified by position (or field
+name if `bind_fields` or `bind_header` was called).
+
+The callback will be passed two arguments:
+
+- 1
+
+ The current field
+
+- 2
+
+ A reference to all the other fields, either as an array or hash
+ reference, depending on the method which you called.
+
+If data looks like this:
+
+ parent children
+ Mike Greg,Peter,Bobby
+ Carol Marcia,Jane,Cindy
+
+You could split the "children" field into an array reference with the
+values like so:
+
+ $p->field_compute( 'children', sub { [ split /,/, shift() ] } );
+
+The field position or name doesn't actually have to exist, which means
+you could create new, computed fields on-the-fly. E.g., if you data
+looks like this:
+
+ 1,3,5
+ 32,4,1
+ 9,5,4
+
+You could write a field\_compute like this:
+
+ $p->field_compute( 3,
+ sub {
+ my ( $cur, $others ) = @_;
+ my $sum;
+ $sum += $_ for @$others;
+ return $sum;
+ }
+ );
+
+Field "3" will be created as the sum of the other fields. This allows
+you to further write:
+
+ my $data = $p->fetchall_arrayref;
+ for my $rec ( @$data ) {
+ print "$rec->[0] + $rec->[1] + $rec->[2] = $rec->[3]\n";
+ }
+
+Prints:
+
+ 1 + 3 + 5 = 9
+ 32 + 4 + 1 = 37
+ 9 + 5 + 4 = 18
+
+## field\_filter
+
+ $p->field_filter( sub { $_ = shift; uc(lc($_)) } );
+
+A callback which is applied to each field. The callback will be
+passed the current value of the field. Whatever is passed back will
+become the new value of the field. The above example capitalizes
+field values. To unset the filter, pass in the empty string.
+
+## field\_list
+
+ $p->bind_fields( qw[ foo bar baz ] );
+ my @fields = $p->field_list;
+ print join ', ', @fields; # prints "foo, bar, baz"
+
+Returns the fields bound via `bind_fields` (or `bind_header`).
+
+## field\_positions
+
+ my %positions = $p->field_positions;
+
+Returns a hash of the fields and their positions bound via
+`bind_fields` (or `bind_header`). Mostly for internal use.
+
+## field\_separator
+
+ $p->field_separator("\t"); # splits fields on tabs
+ $p->field_separator('::'); # splits fields on double colons
+ $p->field_separator(qr/\s+/); # splits fields on whitespace
+ my $sep = $p->field_separator; # returns the current separator
+
+Gets and sets the token to use as the field delimiter. Regular
+expressions can be specified using qr//. If not specified, it will
+take a guess based on the filename extension ("comma" for ".txt,"
+".dat," or ".csv"; "tab" for ".tab"). The default is a comma.
+
+## filename
+
+ $p->filename('/path/to/file.dat');
+
+Gets or sets the complete path to the file to be read. If a file is
+already opened, then the handle on it will be closed and a new one
+opened on the new file.
+
+## get\_field\_aliases
+
+ my @aliases = $p->get_field_aliases('name');
+
+Allows you to define alternate names for fields, e.g., sometimes your
+input file calls city "town" or "township," sometimes a file uses "Moniker"
+instead of "name."
+
+## header\_filter
+
+ $p->header_filter( sub { $_ = shift; s/\s+/_/g; lc $_ } );
+
+A callback applied to column header names. The callback will be
+passed the current value of the header. Whatever is returned will
+become the new value of the header. The above example collapses
+spaces into a single underscore and lowercases the letters. To unset
+a filter, pass in the empty string.
+
+## record\_separator
+
+ $p->record_separator("\n//\n");
+ $p->field_separator("\n");
+
+Gets and sets the token to use as the record separator. The default is
+a newline ("\\n").
+
+The above example would read a file that looks like this:
+
+ field1
+ field2
+ field3
+ //
+ data1
+ data2
+ data3
+ //
+
+## set\_field\_alias
+
+ $p->set_field_alias({
+ name => 'Moniker,handle', # comma-separated string
+ city => [ qw( town township ) ], # or anonymous arrayref
+ });
+
+Allows you to define alternate names for fields, e.g., sometimes your
+input file calls city "town" or "township," sometimes a file uses "Moniker"
+instead of "name."
+
+## trim
+
+ my $trim_value = $p->trim(1);
+
+Provide "true" argument to remove leading and trailing whitespace from
+fields. Use a "false" argument to disable.
+
+# AUTHOR
+
+Ken Youens-Clark <[email protected]>
+
+# SOURCE
+
+http://github.com/kyclark/text-recordparser
+
+# CREDITS
+
+Thanks to the following:
+
+- Benjamin Tilly
+
+ For Text::xSV, the inspirado for this module
+
+- Tim Bunce et al.
+
+ For DBI, from which many of the methods were shamelessly stolen
+
+- Tom Aldcroft
+
+ For contributing code to make it easy to parse whitespace-delimited data
+
+- Liya Ren
+
+ For catching the column-ordering error when parsing with "no-headers"
+
+- Sharon Wei
+
+ For catching bug in `extract` that sets up infinite loops
+
+- Lars Thegler
+
+ For bug report on missing "script\_files" arg in Build.PL
+
+# BUGS
+
+None known. Please use http://rt.cpan.org/ for reporting bugs.
+
+# LICENSE AND COPYRIGHT
+
+Copyright (C) 2006-10 Ken Youens-Clark. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/bin/tablify
new/Text-RecordParser-v1.6.3/bin/tablify
--- old/Text-RecordParser-v1.5.0/bin/tablify 2010-07-21 18:12:01.000000000
+0200
+++ new/Text-RecordParser-v1.6.3/bin/tablify 2013-08-09 19:05:58.000000000
+0200
@@ -3,12 +3,12 @@
use strict;
use warnings;
use version;
-use English qw( -no_match_vars );
use File::Basename;
use Getopt::Long;
-use List::Util qw( max );
+use List::Util 'max';
use Pod::Usage;
use Readonly;
+use Text::Autoformat 'autoformat';
use Text::RecordParser;
use Text::TabularDisplay;
@@ -17,9 +17,12 @@
Readonly my $EMPTY_STR => q{};
Readonly my $TAB => qq{\t};
Readonly my $NEWLINE => qq{\n};
+Readonly my $WIDTH => 78;
+my $comment_start = '';
my $fs = $TAB;
my $rs = $NEWLINE;
+my $headers = '';
my $no_headers = 0;
my $show_vertically = 0;
my $no_pager = 0;
@@ -27,15 +30,17 @@
my ( $show_fields, $list, $limit, @where, $help, $man_page, $show_version );
GetOptions(
+ 'c|comment:s' => \$comment_start,
'fs:s' => \$fs,
'rs:s' => \$rs,
'f|fields:s' => \$show_fields,
'l|list' => \$list,
- 'limit:i' => \$limit,
+ 'i|limit:i' => \$limit,
'w|where:s' => \@where,
'v|vertical' => \$show_vertically,
'strip-quotes' => \$strip_quotes,
- 'no-headers' => \$no_headers,
+ 'n|no-headers' => \$no_headers,
+ 'h|headers:s' => \$headers,
'no-pager' => \$no_pager,
'help' => \$help,
'man' => \$man_page,
@@ -50,7 +55,7 @@
};
if ( $show_version ) {
- my $prog = basename( $PROGRAM_NAME );
+ my $prog = basename( $0 );
print "$prog $VERSION\n";
exit 0;
}
@@ -59,6 +64,7 @@
my $p = Text::RecordParser->new(
field_separator => $fs,
record_separator => $rs,
+ comment => $comment_start ? qr/^$comment_start/ : undef,
);
if ( $strip_quotes ) {
@@ -73,7 +79,10 @@
}
my @fields;
-unless ( $no_headers ) {
+if ( @fields = split( /\s*,\s*/, $headers ) ) {
+ $p->bind_fields( @fields );
+}
+elsif ( !$no_headers ) {
$p->bind_header;
@fields = $p->field_list;
}
@@ -150,8 +159,8 @@
RECORD:
while ( my @data = $p->fetchrow_array ) {
if ( !@fields ) {
- @fields = ( 0..$#data );
- @field_names = map { 'Field' . ($_+1) } @fields;
+ @fields = ( 0..$#data );
+ @field_names = map { 'Field' . ($_+1) } @fields;
$max_col_length = max( map { length $_ } @field_names );
$tab->columns( @field_names );
}
@@ -194,9 +203,13 @@
printf $fh $separator, $num_records;
for my $field ( @fields ) {
next unless $field;
- printf $fh "%${max_col_length}s: %s\n",
- $field,
- defined $data->{ $field } ? $data->{ $field } : q{};
+ my $v = defined $data->{ $field } ? $data->{ $field } : q{};
+ if ( length $v > $WIDTH ) {
+ ( $v = autoformat( $v, { left => $max_col_length + 3 } ) )
+ =~ s/^\s+|\s+$//g;
+ }
+
+ printf $fh "%${max_col_length}s: %s\n", $field, $v;
}
}
else {
@@ -238,7 +251,8 @@
Options:
-h|--help Show help
- --no-headers Assume first line is data, not headers
+ -c|--comment Define the beginning of a (single-line) comment
+ -n|--no-headers Assume first line is data, not headers
--no-pager Do not use $ENV{'PAGER'} even if defined
--strip-quotes Strip " or ' around fields
-l|--list List the fields in the file (for use with -f)
@@ -250,12 +264,14 @@
where field "f" matches the value "v"; acceptable
operators include ==, eq, >, >=, <=, and =~
-v|--vertical Show records vertically
- --limit=n Limit to first "n" records
+ -i|--limit=n Limit to given number of records
--fs=x Use "x" as the field separator
(default is tab "\t")
--rs=x Use "x" as the record separator
(default is newline "\n")
--as-html Create an HTML table instead of plain text
+ --headers Comma-separated list of names matching
+ the number of columns
=head1 DESCRIPTION
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Text-RecordParser-v1.5.0/lib/Text/RecordParser.pm
new/Text-RecordParser-v1.6.3/lib/Text/RecordParser.pm
--- old/Text-RecordParser-v1.5.0/lib/Text/RecordParser.pm 2010-07-21
18:12:01.000000000 +0200
+++ new/Text-RecordParser-v1.6.3/lib/Text/RecordParser.pm 2013-08-09
19:05:58.000000000 +0200
@@ -91,7 +91,7 @@
use Readonly;
use Text::ParseWords qw( parse_line );
-our $VERSION = version->new('1.5.0');
+our $VERSION = version->new('1.6.3');
Readonly my $COMMA => q{,};
Readonly my $EMPTY_STR => q{};
@@ -1109,6 +1109,10 @@
Ken Youens-Clark E<lt>[email protected]<gt>
+=head1 SOURCE
+
+http://github.com/kyclark/text-recordparser
+
=head1 CREDITS
Thanks to the following:
++++++ cpanspec.yml ++++++
---
#description_paragraphs: 3
#no_testing: broken upstream
#sources:
# - source1
# - source2
#patches:
# foo.patch: -p1
# bar.patch:
preamble: |-
BuildRequires: cairo
BuildRequires: ghostscript-fonts-std
BuildRequires: graphviz-gnome
BuildRequires: pango
BuildRequires: perl(GraphViz)
#post_prep: |-
# hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s, *,,g'`
# sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL
#post_install: |-
# sed on %{name}.files
license: GPL-2.0
#skip_noarch: 1
#custom_build: -
#./Build build flags=%{?_smp_mflags} --myflag