r43165 - in /branches/upstream/libsysadm-install-perl/current: Changes MANIFEST META.yml README lib/Sysadm/Install.pm t/014utf8.t t/canned/utf8.txt

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Fri Aug 28 16:45:44 UTC 2009


Author: jawnsy-guest
Date: Fri Aug 28 16:45:38 2009
New Revision: 43165

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=43165
Log:
[svn-upgrade] Integrating new upstream version, libsysadm-install-perl (0.31)

Added:
    branches/upstream/libsysadm-install-perl/current/t/014utf8.t
    branches/upstream/libsysadm-install-perl/current/t/canned/utf8.txt   (with props)
Modified:
    branches/upstream/libsysadm-install-perl/current/Changes
    branches/upstream/libsysadm-install-perl/current/MANIFEST
    branches/upstream/libsysadm-install-perl/current/META.yml
    branches/upstream/libsysadm-install-perl/current/README
    branches/upstream/libsysadm-install-perl/current/lib/Sysadm/Install.pm

Modified: branches/upstream/libsysadm-install-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/Changes?rev=43165&op=diff
==============================================================================
--- branches/upstream/libsysadm-install-perl/current/Changes (original)
+++ branches/upstream/libsysadm-install-perl/current/Changes Fri Aug 28 16:45:38 2009
@@ -1,6 +1,12 @@
 ########################################
 Revision history for Sysadm::Install
 ########################################
+
+0.30 2009/08/27
+    (ms) nhandler(at)ubuntu.com provided a patch to resolve pod2man errors:
+         https://rt.cpan.org/Public/Bug/Display.html?id=47525
+    (ms) slurp() and blurt() now use utf8 mode by default if available
+    (ms) added utf8_available() and is_utf8_data()
 
 0.29 2009/06/25
     (ms) Greg Olszewski added proper error handling to print and 

Modified: branches/upstream/libsysadm-install-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/MANIFEST?rev=43165&op=diff
==============================================================================
--- branches/upstream/libsysadm-install-perl/current/MANIFEST (original)
+++ branches/upstream/libsysadm-install-perl/current/MANIFEST Fri Aug 28 16:45:38 2009
@@ -23,6 +23,8 @@
 t/011defor.t
 t/012tap.t
 t/013download.t
+t/014utf8.t
 t/canned/test.tar
 t/canned/testa.tar
+t/canned/utf8.txt
 META.yml                                 Module meta-data (added by MakeMaker)

Modified: branches/upstream/libsysadm-install-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/META.yml?rev=43165&op=diff
==============================================================================
--- branches/upstream/libsysadm-install-perl/current/META.yml (original)
+++ branches/upstream/libsysadm-install-perl/current/META.yml Fri Aug 28 16:45:38 2009
@@ -1,31 +1,18 @@
---- #YAML:1.0
-name:               Sysadm-Install
-version:            0.29
-abstract:           Typical installation tasks for system administrators
-author:
-    - Mike Schilli <m at perlmeister.com>
-license:            unknown
-distribution_type:  module
-configure_requires:
-    ExtUtils::MakeMaker:  0
-build_requires:
-    ExtUtils::MakeMaker:  0
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Sysadm-Install
+version:      0.31
+version_from: lib/Sysadm/Install.pm
+installdirs:  site
 requires:
-    Cwd:             0
-    File::Basename:  0
-    File::Copy:      0
-    File::Path:      0
-    File::Temp:      0.16
-    Log::Log4perl:   1
-    LWP::Simple:     0
-    Term::ReadKey:   0
-resources:
-    repository:  http://github.com/mschilli/sysadm-install-perl
-no_index:
-    directory:
-        - t
-        - inc
-generated_by:       ExtUtils::MakeMaker version 6.50
-meta-spec:
-    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
-    version:  1.4
+    Cwd:                           0
+    File::Basename:                0
+    File::Copy:                    0
+    File::Path:                    0
+    File::Temp:                    0.16
+    Log::Log4perl:                 1
+    LWP::Simple:                   0
+    Term::ReadKey:                 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30_01

Modified: branches/upstream/libsysadm-install-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/README?rev=43165&op=diff
==============================================================================
--- branches/upstream/libsysadm-install-perl/current/README (original)
+++ branches/upstream/libsysadm-install-perl/current/README Fri Aug 28 16:45:38 2009
@@ -1,5 +1,5 @@
 ######################################################################
-    Sysadm::Install 0.29
+    Sysadm::Install 0.31
 ######################################################################
 
 NAME
@@ -447,6 +447,16 @@
         apparently passed in by value? Modifying $_[0] within the subroutine
         is an old Perl trick to do exactly that.
 
+    "is_utf8_data($data)"
+        Check if the given string has the utf8 flag turned on. Works just
+        like Encode.pm's is_utf8() function, except that it silently returns
+        a false if Encode isn't available, for example when an ancient perl
+        without proper utf8 support is used.
+
+    "utf8_check($data)"
+        Check if we're using a perl with proper utf8 support, by verifying
+        the Encode.pm module is available for loading.
+
 AUTHOR
     Mike Schilli, <m at perlmeister.com>
 

Modified: branches/upstream/libsysadm-install-perl/current/lib/Sysadm/Install.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/lib/Sysadm/Install.pm?rev=43165&op=diff
==============================================================================
--- branches/upstream/libsysadm-install-perl/current/lib/Sysadm/Install.pm (original)
+++ branches/upstream/libsysadm-install-perl/current/lib/Sysadm/Install.pm Fri Aug 28 16:45:38 2009
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.29';
+our $VERSION = '0.31';
 
 use File::Copy;
 use File::Path;
@@ -84,6 +84,7 @@
 fs_read_open fs_write_open pipe_copy
 snip password_read nice_time
 def_or blurt_atomic
+is_utf8_data utf8_available
 );
 
 our %EXPORTABLE = map { $_ => 1 } @EXPORTABLE;
@@ -174,10 +175,6 @@
 =head2 FUNCTIONS
 
 =over 4
-
-=cut
-
-=pod
 
 =item C<cp($source, $target)>
 
@@ -671,6 +668,11 @@
 
         open FILE, "<$file" or 
             LOGCROAK("Cannot open $file ($!)");
+
+        if( utf8_available() ) {
+            binmode FILE, ":utf8";
+        }
+
         while(<FILE>) {
             $out .= $coderef->($_);
         }
@@ -711,6 +713,11 @@
 
         open FILE, "<$file" or 
             LOGCROAK("Cannot open $file ($!)");
+
+        if( utf8_available() ) {
+            binmode FILE, ":utf8";
+        }
+
         while(<FILE>) {
             $coderef->($_);
         }
@@ -745,6 +752,9 @@
         INFO "Slurping data from $file";
         open FILE, "<$file" or 
             LOGCROAK("Cannot open $file ($!)");
+        if( utf8_available() ) {
+            binmode FILE, ":utf8";
+        }
         $data = <FILE>;
         close FILE;
         DEBUG "Read ", snip($data, $DATA_SNIPPED_LEN), " from $file";
@@ -782,6 +792,11 @@
     open FILE, ">" . ($append ? ">" : "") . $file 
         or 
         LOGCROAK("Cannot open $file for writing ($!)");
+
+    if( is_utf8_data( $data ) ) {
+        binmode FILE, ":utf8";
+    }
+
     print FILE $data
         or 
         LOGCROAK("Cannot write to $file ($!)");        
@@ -1545,6 +1560,50 @@
     }
 }
 
+=item C<is_utf8_data($data)>
+
+Check if the given string has the utf8 flag turned on. Works just like 
+Encode.pm's is_utf8() function, except that it silently returns a 
+false if Encode isn't available, for example when an ancient perl 
+without proper utf8 support is used.
+
+=cut
+
+###############################################
+sub is_utf8_data {
+###############################################
+    my($data) = @_;
+
+    if( !utf8_available() ) {
+        return 0;
+    }
+
+    return Encode::is_utf8( $data );
+}
+
+=item C<utf8_check($data)>
+
+Check if we're using a perl with proper utf8 support, by verifying the
+Encode.pm module is available for loading.
+
+=cut
+
+###############################################
+sub utf8_available {
+###############################################
+
+    eval {
+        use Encode;
+    };
+
+    if($@) {
+        return 0;
+    }
+
+    return 1;
+}
+
+
 =pod
 
 =back

Added: branches/upstream/libsysadm-install-perl/current/t/014utf8.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/t/014utf8.t?rev=43165&op=file
==============================================================================
--- branches/upstream/libsysadm-install-perl/current/t/014utf8.t (added)
+++ branches/upstream/libsysadm-install-perl/current/t/014utf8.t Fri Aug 28 16:45:38 2009
@@ -1,0 +1,36 @@
+#####################################
+# Tests for Sysadm::Install/s utf8 handling
+#####################################
+use Test::More;
+
+use Sysadm::Install qw(:all);
+use File::Spec;
+use File::Path;
+
+#use Log::Log4perl qw(:easy);
+#Log::Log4perl->easy_init($DEBUG);
+
+BEGIN {
+    eval {
+        require 5.8.0;
+        use Encode qw(is_utf8);
+        use utf8; # local scope only, needs to be repeated below
+    };
+
+    if ($@) {
+        plan skip_all => "Skipping utf8 tests (requires perl >5.8)";
+    } else {
+        plan tests => 2;
+    }
+}
+
+my $TEST_DIR = ".";
+$TEST_DIR = "t" if -d 't';
+
+my $utf8file = File::Spec->catfile($TEST_DIR, "canned", "utf8.txt");
+
+my $data = slurp $utf8file;
+ok is_utf8( $data ), "slurped utf8 file data stored in utf8";
+
+use utf8;
+like $data, qr/äÜß/, "slurped utf8 file data";

Added: branches/upstream/libsysadm-install-perl/current/t/canned/utf8.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsysadm-install-perl/current/t/canned/utf8.txt?rev=43165&op=file
==============================================================================
Binary file - no diff available.

Propchange: branches/upstream/libsysadm-install-perl/current/t/canned/utf8.txt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream




More information about the Pkg-perl-cvs-commits mailing list