r8335 - in /trunk/libfile-read-perl: Changes MANIFEST META.yml debian/changelog eg/ lib/File/Read.pm t/00-load.t t/file-read.t t/pod-coverage.t t/pod.t
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Thu Oct 18 19:45:30 UTC 2007
Author: dmn
Date: Thu Oct 18 19:45:30 2007
New Revision: 8335
URL: http://svn.debian.org/wsvn/?sc=1&rev=8335
Log:
* New upstream release
Added:
trunk/libfile-read-perl/eg/
- copied from r8334, branches/upstream/libfile-read-perl/current/eg/
Modified:
trunk/libfile-read-perl/Changes
trunk/libfile-read-perl/MANIFEST
trunk/libfile-read-perl/META.yml
trunk/libfile-read-perl/debian/changelog
trunk/libfile-read-perl/lib/File/Read.pm
trunk/libfile-read-perl/t/00-load.t
trunk/libfile-read-perl/t/file-read.t
trunk/libfile-read-perl/t/pod-coverage.t
trunk/libfile-read-perl/t/pod.t
Modified: trunk/libfile-read-perl/Changes
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/Changes?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/Changes (original)
+++ trunk/libfile-read-perl/Changes Thu Oct 18 19:45:30 2007
@@ -1,4 +1,11 @@
Revision history for File-Read
+
+0.07 2007.10.17 (SAPER)
+ [FEATURE] Option "cmd" to set the command used to read files as root.
+ [TESTS] Removed the clunky tests for "as_root" as the "cmd" option
+ allows for easy mocking.
+ [TESTS] t/file-read.t also tests if the functions are actually exported.
+ [DIST] eg/read_hosts.pl really present now.
0.0602 2006.10.13 (SAPER)
[DIST] Added example eg/read_hosts.pl
Modified: trunk/libfile-read-perl/MANIFEST
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/MANIFEST?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/MANIFEST (original)
+++ trunk/libfile-read-perl/MANIFEST Thu Oct 18 19:45:30 2007
@@ -4,6 +4,7 @@
META.yml
Makefile.PL
README
+eg/read_host.pl
lib/File/Read.pm
t/00-load.t
t/distchk.t
Modified: trunk/libfile-read-perl/META.yml
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/META.yml?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/META.yml (original)
+++ trunk/libfile-read-perl/META.yml Thu Oct 18 19:45:30 2007
@@ -1,6 +1,6 @@
---
name: File-Read
-version: 0.0602
+version: 0.07
author:
- 'Sebastien Aperghis-Tramoni <sebastien at aperghis.net>'
abstract: Unique interface for reading one or more files
@@ -13,8 +13,8 @@
provides:
File::Read:
file: lib/File/Read.pm
- version: 0.0602
-generated_by: Module::Build version 0.2805
+ version: 0.07
+generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
Modified: trunk/libfile-read-perl/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/debian/changelog?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/debian/changelog (original)
+++ trunk/libfile-read-perl/debian/changelog Thu Oct 18 19:45:30 2007
@@ -1,4 +1,6 @@
-libfile-read-perl (0.0602-2) UNRELEASED; urgency=low
+libfile-read-perl (0.0700-1) UNRELEASED; urgency=low
+
+ * New upstream release
[ gregor herrmann ]
* debian/control: Added: Vcs-Svn field (source stanza); Vcs-Browser
@@ -9,7 +11,7 @@
* [debian/watch] mangle upstream version so that 0.07 becomes 0.0700 to keep
versions sequential (dpkg-wise)
- -- Damyan Ivanov <dmn at debian.org> Thu, 18 Oct 2007 22:42:10 +0300
+ -- Damyan Ivanov <dmn at debian.org> Thu, 18 Oct 2007 22:44:58 +0300
libfile-read-perl (0.0602-1) unstable; urgency=low
Modified: trunk/libfile-read-perl/lib/File/Read.pm
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/lib/File/Read.pm?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/lib/File/Read.pm (original)
+++ trunk/libfile-read-perl/lib/File/Read.pm Thu Oct 18 19:45:30 2007
@@ -5,7 +5,7 @@
require Exporter;
{ no strict;
- $VERSION = '0.0602';
+ $VERSION = '0.07';
@ISA = qw(Exporter);
@EXPORT = qw(read_file read_files);
}
@@ -18,7 +18,7 @@
=head1 VERSION
-Version 0.06
+Version 0.07
=head1 SYNOPSIS
@@ -86,8 +86,13 @@
=item *
C<as_root> tells the function to read the given file(s) as root using
-B<sudo(8)> and B<cat(1)>. You therefore need to edit F<sudoers(5)> in
-order to allow the user to execute B<cat(1)>.
+the command indicated by the C<cmd> option.
+
+=item *
+
+C<cmd> sets the shell command used for reading files as root. Default
+is C<"sudo cat">. Therefore you need B<sudo(8)> and B<cat(1)> on your
+system, and F<sudoers(5)> must be set so the user can execute B<cat(1)>.
=item *
@@ -140,6 +145,7 @@
my %defaults = (
aggregate => 1,
+ cmd => "sudo cat",
err_mode => 'croak',
skip_comments => 0,
skip_blanks => 0,
@@ -147,16 +153,16 @@
);
sub import {
- my($module, at args) = @_;
+ my ($module, @args) = @_;
my @new = ();
# parse arguments
for my $arg (@args) {
- if(index($arg, '=') >= 0) {
- my($opt,$val) = split('=', $arg);
+ if (index($arg, '=') >= 0) {
+ my ($opt, $val) = split '=', $arg;
$defaults{$opt} = $val if exists $defaults{$opt};
-
- } else {
+ }
+ else {
push @new, $arg
}
}
@@ -192,22 +198,24 @@
my $error = '';
# first, read the file
- if ($opts{as_root}) { # ... as root
+ if ($opts{as_root}) { # ... as root
my $redir = $opts{err_mode} eq 'quiet' ? '2>&1' : '';
- @lines = `sudo /bin/cat $path $redir`;
+ @lines = `$opts{cmd} $path $redir`;
if ($?) {
if (not -f $path) {
$! = eval { require Errno; Errno->import(":POSIX"); ENOENT() } || 2
- } elsif (not -r $path) {
+ }
+ elsif (not -r $path) {
$! = eval { require Errno; Errno->import(":POSIX"); EACCES() } || 13
- } else {
+ }
+ else {
$! = 1024
}
($error = "$!") =~ s/ 1024//;
}
-
- } else { # ... as a normal user
+ }
+ else { # ... as a normal user
@lines = eval { File::Slurp::read_file($path) };
$error = $@;
}
@@ -235,10 +243,10 @@
sub _to_ascii {
# use Text::Unidecode if available
- if($has_unidecode) {
+ if ($has_unidecode) {
return Text::Unidecode::unidecode(@_)
-
- } else { # use a simple s///
+ }
+ else { # use a simple s///
my @text = @_;
map { s/[^\x00-\x7f]//g } @text;
return @text
Modified: trunk/libfile-read-perl/t/00-load.t
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/t/00-load.t?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/t/00-load.t (original)
+++ trunk/libfile-read-perl/t/00-load.t Thu Oct 18 19:45:30 2007
@@ -1,5 +1,5 @@
#!perl -T
-
+use strict;
use Test::More tests => 1;
BEGIN {
Modified: trunk/libfile-read-perl/t/file-read.t
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/t/file-read.t?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/t/file-read.t (original)
+++ trunk/libfile-read-perl/t/file-read.t Thu Oct 18 19:45:30 2007
@@ -1,10 +1,10 @@
use strict;
eval 'use warnings';
-use File::Read;
+use Cwd qw(abs_path);
use File::Spec;
use Test::More;
-my $has_unidecode = defined $Text::Unidecode::VERSION;
+my $has_unidecode = eval "use Text::Unidecode; 1";
# describe the tests
my @one_result_tests = (
@@ -83,17 +83,15 @@
expected => $has_unidecode ? # Text::Unidecode is available
"agrave:a aelig:ae eacute:e szlig:ss eth:d thorn:th mu:u\n" .
"pound:PS laquo:<< raquo:>> sect:SS para:P middot:*\n"
- : # Text::Unidecode isn't available, non ASCII chars should be deleted
+ : # Text::Unidecode isn't available, non-ASCII chars should be deleted
"agrave: aelig: eacute: szlig: eth: thorn: mu:\n" .
"pound: laquo: raquo: sect: para: middot:\n"
,
},
-);
-
-my @one_result_root_tests = (
{
args => [ { as_root => 1 },
- File::Spec->catfile(File::Spec->rootdir, qw(etc shadow)) ],
+ File::Spec->catfile(qw(t samples hello)) ],
+ expected => "ROOT:Hello",
},
);
@@ -113,12 +111,21 @@
);
+# determine the path of the current perl(1)
+my $perl = abs_path($^X);
+$perl = qq{"$perl"} if $perl =~ m/\s/;
+
# "I love it when a plan comes together"
-plan tests => 5 + @one_result_tests * 2 + @one_result_root_tests * 2 + @many_results_tests * 3;
+plan tests => 7 + @one_result_tests * 2 + @many_results_tests * 3;
+# load File::Read
+use_ok( "File::Read", "cmd=$perl -pe s/^/ROOT:/" );
# check that the advertised functions are present
can_ok( 'File::Read' => qw(read_file read_files) );
+
+# check that the exported functions are available in the current package
+can_ok( __PACKAGE__, qw(read_file read_files) );
# check diagnostics
@@ -154,35 +161,6 @@
is( $file, $test->{expected}, "checking result" );
}
-
-# read files as root, returning one result
-for my $test (@one_result_root_tests) {
- (eval { Dumper($test->{args}) } || '') =~ /\[(.+)\];$/;
- my $args_str = $1 || "@{$test->{args}}";
-
- # I don't know why, but Perl 5.005_04 chokes on the "SKIP:" line
- # with the error "Not a HASH reference". Fortunately, it's trappable
- # so we just eval{} it.
- # Perl 5.8 also produces a warning "Pseudo-hashes are deprecated"
- # on the same line.
- eval {
- SKIP: {
- skip "no such file", 2 unless -f $test->{args}[1];
- skip "sudo (usually needs interactive password)", 2 if $ENV{AUTOMATED_TESTING};
-
- my $file = eval { read_file( @{$test->{args}} ) };
- is( $@, '', "calling read_file() with args: $args_str" );
- cmp_ok( length $file, '>=', 0, "checking result" );
- }
- };
- if($@) {
- # something happened, preventing the previous block to
- # execute, so we just skip these tests by OK'ing them
- pass(); pass();
- }
-}
-
-
# read files, returning several results
for my $test (@many_results_tests) {
(eval { Dumper($test->{args}) } || '') =~ /\[(.+)\];$/;
Modified: trunk/libfile-read-perl/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/t/pod-coverage.t?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/t/pod-coverage.t (original)
+++ trunk/libfile-read-perl/t/pod-coverage.t Thu Oct 18 19:45:30 2007
@@ -1,5 +1,5 @@
#!perl -T
-
+use strict;
use Test::More;
eval "use Test::Pod::Coverage 1.04";
plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
Modified: trunk/libfile-read-perl/t/pod.t
URL: http://svn.debian.org/wsvn/trunk/libfile-read-perl/t/pod.t?rev=8335&op=diff
==============================================================================
--- trunk/libfile-read-perl/t/pod.t (original)
+++ trunk/libfile-read-perl/t/pod.t Thu Oct 18 19:45:30 2007
@@ -1,5 +1,5 @@
#!perl -T
-
+use strict;
use Test::More;
eval "use Test::Pod 1.14";
plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
More information about the Pkg-perl-cvs-commits
mailing list