develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r34920 - trunk/lib/Parrot

From:
jkeenan
Date:
January 4, 2009 07:09
Subject:
[svn:parrot] r34920 - trunk/lib/Parrot
Message ID:
20090104150912.8C2BACB9F9@x12.develooper.com
Author: jkeenan
Date: Sun Jan  4 07:09:11 2009
New Revision: 34920

Modified:
   trunk/lib/Parrot/Distribution.pm
   trunk/lib/Parrot/Test.pm

Log:
1.  Alias Parrot::Test::slurp_file() to Parrot::BuildUtil::slurp_file().
2.  Delete Parrot::Distribution::slurp().  Function was never used.  If
needed, use Parrot::Configure::Utils::_slurp().
Cf.:  https://trac.parrot.org/parrot/ticket/117.


Modified: trunk/lib/Parrot/Distribution.pm
==============================================================================
--- trunk/lib/Parrot/Distribution.pm	(original)
+++ trunk/lib/Parrot/Distribution.pm	Sun Jan  4 07:09:11 2009
@@ -779,29 +779,6 @@
     };
 }
 
-=item C<slurp>
-
-Returns the text of the file at the given path
-
-=cut
-
-sub slurp {
-    my $self = shift;
-    my $path = shift;
-    my $buf;
-
-    # slurp in the file
-    open( my $fh, '<', $path )
-        or die "Cannot open '$path' for reading: $!\n";
-    {
-        local $/;
-        $buf = <$fh>;
-    }
-    close $fh;
-
-    return $buf;
-}
-
 1;
 
 # Local Variables:

Modified: trunk/lib/Parrot/Test.pm
==============================================================================
--- trunk/lib/Parrot/Test.pm	(original)
+++ trunk/lib/Parrot/Test.pm	Sun Jan  4 07:09:11 2009
@@ -225,7 +225,8 @@
 
 =item C<slurp_file($file_name)>
 
-Read the whole file $file_name and return the content as a string.
+Read the whole file $file_name and return the content as a string.  This is
+just an alias for C<Parrot::BuildUtil::slurp_file>.
 
 =item C<convert_line_endings($text)>
 
@@ -266,6 +267,8 @@
 use File::Basename;
 use Memoize ();
 
+use lib qw( lib );
+use Parrot::BuildUtil ();
 use Parrot::Config;
 
 require Exporter;
@@ -384,22 +387,10 @@
     return;
 }
 
-# We can inherit from Test::More, so we do it.
+# We can inherit from other modules, so we do so.
 *plan = \&Test::More::plan;
 *skip = \&Test::More::skip;
-
-# What about File::Slurp?
-sub slurp_file {
-    my ($file_name) = @_;
-
-    open( my $SLURP, '<', $file_name ) or die "open '$file_name': $!";
-    local $/ = undef;
-    my $file = <$SLURP> . '';
-    $file    =~ s/\cM\cJ/\n/g;
-    close $SLURP;
-
-    return $file;
-}
+*slurp_file = \&Parrot::BuildUtil::slurp_file;
 
 sub convert_line_endings {
     my ($text) = @_;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About