r44827 - in /branches/upstream/liborlite-perl/current: Changes MANIFEST META.yml Makefile.PL README lib/ORLite.pm t/08_prune.pl t/08_prune.t t/lib/Test.pm

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Fri Sep 25 20:04:44 UTC 2009


Author: jawnsy-guest
Date: Fri Sep 25 20:04:37 2009
New Revision: 44827

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

Added:
    branches/upstream/liborlite-perl/current/t/08_prune.pl
    branches/upstream/liborlite-perl/current/t/08_prune.t
Modified:
    branches/upstream/liborlite-perl/current/Changes
    branches/upstream/liborlite-perl/current/MANIFEST
    branches/upstream/liborlite-perl/current/META.yml
    branches/upstream/liborlite-perl/current/Makefile.PL
    branches/upstream/liborlite-perl/current/README
    branches/upstream/liborlite-perl/current/lib/ORLite.pm
    branches/upstream/liborlite-perl/current/t/lib/Test.pm

Modified: branches/upstream/liborlite-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/Changes?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/Changes (original)
+++ branches/upstream/liborlite-perl/current/Changes Fri Sep 25 20:04:37 2009
@@ -1,4 +1,18 @@
 Changes for Perl extension ORLite
+
+1.28 Fri 25 Sep 2009
+	- Adding ->prune method that so that pruning can also be done
+	  in subclasses.
+	- Apply rel2abs to pruned directories so they still get deleted
+	  even when our current directory moves.
+
+1.27 Fri 25 Sep 2009
+	- Adding test script for the prune feature
+
+1.26_01 Fri 25 Sep 2009
+	- Adding the prune option to have ORLite to track every file and
+	  directory it creates and remove them during END phase.
+	  (This should be especially handy in test scripts)
 
 1.25 Sat 15 Aug 2009
 	- Adding base and table metadata methods to each class to support

Modified: branches/upstream/liborlite-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/MANIFEST?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/MANIFEST (original)
+++ branches/upstream/liborlite-perl/current/MANIFEST Fri Sep 25 20:04:37 2009
@@ -25,6 +25,8 @@
 t/06_create.t
 t/07_pk.sql
 t/07_pk.t
+t/08_prune.pl
+t/08_prune.t
 t/97_meta.t
 t/98_pod.t
 t/99_pmv.t

Modified: branches/upstream/liborlite-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/META.yml?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/META.yml (original)
+++ branches/upstream/liborlite-perl/current/META.yml Fri Sep 25 20:04:37 2009
@@ -5,6 +5,7 @@
 build_requires:
   ExtUtils::MakeMaker: 6.42
   Test::More: 0.47
+  Test::Script: 1.06
 configure_requires:
   ExtUtils::MakeMaker: 6.42
 distribution_type: module
@@ -24,6 +25,7 @@
   DBI: 1.607
   File::Basename: 0
   File::Path: 2.04
+  File::Remove: 1.40
   File::Spec: 0.80
   File::Temp: 0.20
   Params::Util: 0.33
@@ -32,4 +34,4 @@
   ChangeLog: http://fisheye2.atlassian.com/changelog/cpan/trunk/ORLite
   license: http://dev.perl.org/licenses/
   repository: http://svn.ali.as/cpan/trunk/ORLite
-version: 1.25
+version: 1.28

Modified: branches/upstream/liborlite-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/Makefile.PL?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/Makefile.PL (original)
+++ branches/upstream/liborlite-perl/current/Makefile.PL Fri Sep 25 20:04:37 2009
@@ -2,5 +2,7 @@
 
 all_from      lib/ORLite.pm
 requires_from lib/ORLite.pm
-requires      File::Spec 3.2701 if winlike
-test_requires Test::More 0.47
+requires      File::Spec   3.2701 if winlike
+requires      File::Remove 1.40
+test_requires Test::More   0.47
+test_requires Test::Script 1.06

Modified: branches/upstream/liborlite-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/README?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/README (original)
+++ branches/upstream/liborlite-perl/current/README Fri Sep 25 20:04:37 2009
@@ -3,13 +3,33 @@
 
 SYNOPSIS
       package Foo;
-
-      use strict;
+      
+  # Simplest possible usage
+      
+  use strict;
       use ORLite 'data/sqlite.db';
-
-      my @awesome = Foo::Person->select(
+      
+  my @awesome = Foo::Person->select(
          'where first_name = ?',
          'Adam',
+      );
+      
+  package Bar;
+      
+  # All available options enabled
+      # Some options shown are mutually exclusive, this would not actually run
+      
+  use ORLite {
+          package      => 'My::ORM',
+          file         => 'data/sqlite.db',
+          user_version => 12,
+          tables       => [ 'table1', 'table2' ],
+          readonly     => 1,
+          prune        => 1,
+          create       => sub {
+              my $dbh = shift;
+              $dbh->do('CREATE TABLE foo ( bar TEXT NOT NULL )');
+          },
       );
 
 DESCRIPTION

Modified: branches/upstream/liborlite-perl/current/lib/ORLite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/lib/ORLite.pm?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/lib/ORLite.pm (original)
+++ branches/upstream/liborlite-perl/current/lib/ORLite.pm Fri Sep 25 20:04:37 2009
@@ -9,13 +9,23 @@
 use File::Temp   0.20 ();
 use File::Path   2.04 ();
 use File::Basename  0 ();
-use Params::Util 0.33 qw{ _STRING _CLASS _HASHLIKE _CODELIKE };
+use Params::Util 0.33 ();
 use DBI         1.607 ();
 use DBD::SQLite  1.25 ();
 
 use vars qw{$VERSION};
 BEGIN {
-	$VERSION = '1.25';
+	$VERSION = '1.28';
+}
+
+# Support for the 'prune' option
+my @PRUNE = ();
+END {
+	foreach ( @PRUNE ) {
+		next unless -e $_;
+		require File::Remove;
+		File::Remove::remove($_);
+	}
 }
 
 
@@ -30,14 +40,14 @@
 
 	# Check for debug mode
 	my $DEBUG = 0;
-	if ( defined _STRING($_[-1]) and $_[-1] eq '-DEBUG' ) {
+	if ( defined Params::Util::_STRING($_[-1]) and $_[-1] eq '-DEBUG' ) {
 		$DEBUG = 1;
 		pop @_;
 	}
 
 	# Check params and apply defaults
 	my %params;
-	if ( defined _STRING($_[1]) ) {
+	if ( defined Params::Util::_STRING($_[1]) ) {
 		# Support the short form "use ORLite 'db.sqlite'"
 		%params = (
 			file     => $_[1],
@@ -45,7 +55,7 @@
 			package  => undef, # Automatic
 			tables   => 1,
 		);
-	} elsif ( _HASHLIKE($_[1]) ) {
+	} elsif ( Params::Util::_HASHLIKE($_[1]) ) {
 		%params = %{ $_[1] };
 	} else {
 		Carp::croak("Missing, empty or invalid params HASH");
@@ -54,7 +64,7 @@
 		$params{create} = 0;
 	}
 	unless (
-		defined _STRING($params{file})
+		defined Params::Util::_STRING($params{file})
 		and (
 			$params{create}
 			or
@@ -72,7 +82,7 @@
 	unless ( defined $params{package} ) {
 		$params{package} = scalar caller;
 	}
-	unless ( _CLASS($params{package}) ) {
+	unless ( Params::Util::_CLASS($params{package}) ) {
 		Carp::croak("Missing or invalid package class");
 	}
 
@@ -83,8 +93,10 @@
 		# Create the parent directory
 		my $dir = File::Basename::dirname($file);
 		unless ( -d $dir ) {
-			File::Path::mkpath( $dir, { verbose => 0 } );
+			my @dirs = File::Path::mkpath( $dir, { verbose => 0 } );
+			$class->prune(@dirs) if $params{prune};
 		}
+		$class->prune($file) if $params{prune};
 	}
 	my $pkg      = $params{package};
 	my $readonly = $params{readonly};
@@ -92,7 +104,7 @@
 	my $dbh      = DBI->connect($dsn);
 
 	# Schema creation support
-	if ( $created and _CODELIKE($params{create}) ) {
+	if ( $created and Params::Util::_CODELIKE($params{create}) ) {
 		$params{create}->( $dbh );
 	}
 
@@ -435,11 +447,16 @@
 	} grep {
 		/^(?:package|sub)\b/
 	} split /\n/, $_[0];
-	print STDERR @trace, "\nCode saved as $filename\n\n";
+	# print STDERR @trace, "\nCode saved as $filename\n\n";
 
 	return 1;
 }
 
+sub prune {
+	my $class = shift;
+	push @PRUNE, map { File::Spec->rel2abs($_) } @_;
+}
+
 1;
 
 __END__
@@ -453,14 +470,34 @@
 =head1 SYNOPSIS
 
   package Foo;
-
+  
+  # Simplest possible usage
+  
   use strict;
   use ORLite 'data/sqlite.db';
-
+  
   my @awesome = Foo::Person->select(
      'where first_name = ?',
      'Adam',
   );
+  
+  package Bar;
+  
+  # All available options enabled
+  # Some options shown are mutually exclusive, this would not actually run
+  
+  use ORLite {
+      package      => 'My::ORM',
+      file         => 'data/sqlite.db',
+      user_version => 12,
+      tables       => [ 'table1', 'table2' ],
+      readonly     => 1,
+      prune        => 1,
+      create       => sub {
+          my $dbh = shift;
+          $dbh->do('CREATE TABLE foo ( bar TEXT NOT NULL )');
+      },
+  );
 
 =head1 DESCRIPTION
 

Added: branches/upstream/liborlite-perl/current/t/08_prune.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/t/08_prune.pl?rev=44827&op=file
==============================================================================
--- branches/upstream/liborlite-perl/current/t/08_prune.pl (added)
+++ branches/upstream/liborlite-perl/current/t/08_prune.pl Fri Sep 25 20:04:37 2009
@@ -1,0 +1,17 @@
+#!/usr/bin/perl
+
+# Create an ORLite class, passing through all command line parameters
+
+use strict;
+
+unless ( $ORLite::VERSION eq '1.28' ) {
+	die('Failed to load correct ORLite version');
+}
+
+unless ( Foo->can('sqlite') ) {
+	die('Failed to generate Foo package');
+}
+
+package Foo;
+
+use ORLite +{ @ARGV };

Added: branches/upstream/liborlite-perl/current/t/08_prune.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/t/08_prune.t?rev=44827&op=file
==============================================================================
--- branches/upstream/liborlite-perl/current/t/08_prune.t (added)
+++ branches/upstream/liborlite-perl/current/t/08_prune.t Fri Sep 25 20:04:37 2009
@@ -1,0 +1,40 @@
+#!/usr/bin/perl
+
+# Test the { prune => 1 } feature of ORLite
+
+use strict;
+
+BEGIN {
+	$|  = 1;
+	$^W = 1;
+}
+
+use Test::More tests => 7;
+use Test::Script;
+use File::Remove;
+use t::lib::Test;
+
+# Where the test file will be
+my $file = test_db();
+ok( ! -f $file, 'File does not exist' );
+
+# Run the test program WITHOUT prune
+script_runs( [
+	't/08_prune.pl',
+	file   => $file,
+	create => 1,
+], '08_prune.pl without prune ran ok' );
+ok( -f $file, '08_prune.pl without prune created the file as expected' );
+
+# Clean up
+ok( File::Remove::remove($file), 'Removed the test file' );
+ok( ! -f $file, 'Removed test file' );
+
+# Run the test program again WITH prune
+script_runs( [
+	't/08_prune.pl',
+	file   => $file,
+	create => 1,
+	prune  => 1,
+], '08_prune.pl with prune ran ok' );
+ok( ! -f $file, '08_prune.pl with prune removed the file' );

Modified: branches/upstream/liborlite-perl/current/t/lib/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liborlite-perl/current/t/lib/Test.pm?rev=44827&op=diff
==============================================================================
--- branches/upstream/liborlite-perl/current/t/lib/Test.pm (original)
+++ branches/upstream/liborlite-perl/current/t/lib/Test.pm Fri Sep 25 20:04:37 2009
@@ -8,7 +8,7 @@
 
 use vars qw{$VERSION @ISA @EXPORT};
 BEGIN {
-	$VERSION = '1.25';
+	$VERSION = '1.28';
 	@ISA     = 'Exporter';
 	@EXPORT  = qw{ test_db connect_ok create_ok };
 }




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