[Bast-commits] r9517 - in DBIx-Class/0.08/branches/namespace-clean: lib/DBIx/Class lib/DBIx/Class/Relationship lib/DBIx/Class/ResultSourceProxy lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI lib/DBIx/Class/Storage/DBI/ODBC lib/DBIx/Class/Storage/DBI/Oracle lib/DBIx/Class/Storage/DBI/Sybase lib/DBIx/Class/Storage/DBI/Sybase/ASE lib/SQL/Translator/Parser/DBIx t t/cdbi

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Tue Jun 1 14:46:52 GMT 2010


Author: caelum
Date: 2010-06-01 15:46:52 +0100 (Tue, 01 Jun 2010)
New Revision: 9517

Modified:
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/DB.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Relationship/Base.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSet.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSetColumn.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSource.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSourceProxy/Table.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Row.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/SQLAHacks.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Schema.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Informix.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/InterBase.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/MSSQL.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Pg.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBIHacks.pm
   DBIx-Class/0.08/branches/namespace-clean/lib/SQL/Translator/Parser/DBIx/Class.pm
   DBIx-Class/0.08/branches/namespace-clean/t/03podcoverage.t
   DBIx-Class/0.08/branches/namespace-clean/t/52cycle.t
   DBIx-Class/0.08/branches/namespace-clean/t/cdbi/02-Film.t
Log:
use namespace::cleaned out imports for some common utilities

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/DB.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/DB.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/DB.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -8,7 +8,8 @@
 use DBIx::Class::Storage::DBI;
 use DBIx::Class::ClassResolver::PassThrough;
 use DBI;
-use Scalar::Util;
+use Scalar::Util 'blessed';
+use namespace::clean;
 
 unless ($INC{"DBIx/Class/CDBICompat.pm"}) {
   warn "IMPORTANT: DBIx::Class::DB is DEPRECATED AND *WILL* BE REMOVED. DO NOT USE.\n";
@@ -183,7 +184,7 @@
   }
 
   my($source, $result_class) = @{$class->_result_source_instance};
-  return unless Scalar::Util::blessed($source);
+  return unless blessed $source;
 
   if ($result_class ne $class) {  # new class
     # Give this new class its own source and register it.

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Relationship/Base.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Relationship/Base.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Relationship/Base.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -3,8 +3,9 @@
 use strict;
 use warnings;
 
-use Scalar::Util ();
 use base qw/DBIx::Class/;
+
+use Scalar::Util qw/weaken blessed/;
 use Try::Tiny;
 use namespace::clean;
 
@@ -255,10 +256,10 @@
       foreach my $rev_rel (keys %$reverse) {
         if ($reverse->{$rev_rel}{attrs}{accessor} && $reverse->{$rev_rel}{attrs}{accessor} eq 'multi') {
           $attrs->{related_objects}{$rev_rel} = [ $self ];
-          Scalar::Util::weaken($attrs->{related_object}{$rev_rel}[0]);
+          weaken $attrs->{related_object}{$rev_rel}[0];
         } else {
           $attrs->{related_objects}{$rev_rel} = $self;
-          Scalar::Util::weaken($attrs->{related_object}{$rev_rel});
+          weaken $attrs->{related_object}{$rev_rel};
         }
       }
     }
@@ -459,7 +460,7 @@
   if (defined $f_obj) {
     my $f_class = $rel_info->{class};
     $self->throw_exception( "Object $f_obj isn't a ".$f_class )
-      unless Scalar::Util::blessed($f_obj) and $f_obj->isa($f_class);
+      unless blessed $f_obj and $f_obj->isa($f_class);
   }
   $self->set_columns(
     $self->result_source->_resolve_condition(

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSet.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSet.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -2,10 +2,7 @@
 
 use strict;
 use warnings;
-use overload
-        '0+'     => "count",
-        'bool'   => "_bool",
-        fallback => 1;
+use base qw/DBIx::Class/;
 use Carp::Clan qw/^DBIx::Class/;
 use DBIx::Class::Exception;
 use Data::Page;
@@ -13,9 +10,14 @@
 use DBIx::Class::ResultSetColumn;
 use DBIx::Class::ResultSourceHandle;
 use List::Util ();
-use Scalar::Util ();
-use base qw/DBIx::Class/;
+use Scalar::Util 'blessed';
+use namespace::clean;
 
+use overload
+        '0+'     => "count",
+        'bool'   => "_bool",
+        fallback => 1;
+
 __PACKAGE__->mk_group_accessors('simple' => qw/_result_class _source_handle/);
 
 =head1 NAME
@@ -1933,7 +1935,7 @@
   my $value = shift;
   my $ref_type = ref $value;
   return 1 if $ref_type eq '' || $ref_type eq 'SCALAR';
-  return 1 if Scalar::Util::blessed($value);
+  return 1 if blessed $value;
   return 0;
 }
 

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSetColumn.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSetColumn.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSetColumn.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -7,7 +7,8 @@
 
 use Carp::Clan qw/^DBIx::Class/;
 use DBIx::Class::Exception;
-use List::Util;
+use List::Util ();
+use namespace::clean;
 
 =head1 NAME
 

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSource.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSource.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -9,6 +9,7 @@
 use DBIx::Class::Exception;
 use Carp::Clan qw/^DBIx::Class/;
 use Try::Tiny;
+use List::Util 'first';
 use namespace::clean;
 
 use base qw/DBIx::Class/;
@@ -1292,7 +1293,7 @@
                -is_single => (
                   $rel_info->{attrs}{accessor}
                     &&
-                  List::Util::first { $rel_info->{attrs}{accessor} eq $_ } (qw/single filter/)
+                  first { $rel_info->{attrs}{accessor} eq $_ } (qw/single filter/)
                 ),
                -alias => $as,
                -relation_chain_depth => $seen->{-relation_chain_depth} || 0,

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSourceProxy/Table.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSourceProxy/Table.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/ResultSourceProxy/Table.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -6,7 +6,8 @@
 use base qw/DBIx::Class::ResultSourceProxy/;
 
 use DBIx::Class::ResultSource::Table;
-use Scalar::Util ();
+use Scalar::Util 'blessed';
+use namespace::clean;
 
 __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
 
@@ -80,7 +81,7 @@
   my ($class, $table) = @_;
   return $class->result_source_instance->name unless $table;
 
-  unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
+  unless (blessed $table && $table->isa($class->table_class)) {
 
     my $table_class = $class->table_class;
     $class->ensure_class_loaded($table_class);

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Row.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Row.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -6,7 +6,7 @@
 use base qw/DBIx::Class/;
 
 use DBIx::Class::Exception;
-use Scalar::Util ();
+use Scalar::Util 'blessed';
 use Try::Tiny;
 use namespace::clean;
 
@@ -190,7 +190,7 @@
         my $acc_type = $info->{attrs}{accessor} || '';
         if ($acc_type eq 'single') {
           my $rel_obj = delete $attrs->{$key};
-          if(!Scalar::Util::blessed($rel_obj)) {
+          if(!blessed $rel_obj) {
             $rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj);
           }
 
@@ -210,7 +210,7 @@
           my @objects;
           foreach my $idx (0 .. $#$others) {
             my $rel_obj = $others->[$idx];
-            if(!Scalar::Util::blessed($rel_obj)) {
+            if(!blessed $rel_obj) {
               $rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj);
             }
 
@@ -228,7 +228,7 @@
         elsif ($acc_type eq 'filter') {
           ## 'filter' should disappear and get merged in with 'single' above!
           my $rel_obj = delete $attrs->{$key};
-          if(!Scalar::Util::blessed($rel_obj)) {
+          if(!blessed $rel_obj) {
             $rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj);
           }
           if ($rel_obj->in_storage) {
@@ -304,8 +304,7 @@
     my $rel_obj = $related_stuff{$relname};
 
     if (! $self->{_rel_in_storage}{$relname}) {
-      next unless (Scalar::Util::blessed($rel_obj)
-                    && $rel_obj->isa('DBIx::Class::Row'));
+      next unless (blessed $rel_obj && $rel_obj->isa('DBIx::Class::Row'));
 
       next unless $source->_pk_depends_on(
                     $relname, { $rel_obj->get_columns }
@@ -399,9 +398,7 @@
       : $related_stuff{$relname}
     ;
 
-    if (@cands
-          && Scalar::Util::blessed($cands[0])
-            && $cands[0]->isa('DBIx::Class::Row')
+    if (@cands && blessed $cands[0] && $cands[0]->isa('DBIx::Class::Row')
     ) {
       my $reverse = $source->reverse_relationship_info($relname);
       foreach my $obj (@cands) {

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/SQLAHacks.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/SQLAHacks.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -9,7 +9,9 @@
 use strict;
 use warnings;
 use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
-use Sub::Name();
+use List::Util 'first';
+use Sub::Name 'subname';
+use namespace::clean;
 
 BEGIN {
   # reinstall the carp()/croak() functions imported into SQL::Abstract
@@ -19,7 +21,7 @@
   for my $f (qw/carp croak/) {
 
     my $orig = \&{"SQL::Abstract::$f"};
-    *{"SQL::Abstract::$f"} = Sub::Name::subname "SQL::Abstract::$f" =>
+    *{"SQL::Abstract::$f"} = subname "SQL::Abstract::$f" =>
       sub {
         if (Carp::longmess() =~ /DBIx::Class::SQLAHacks::[\w]+ .+? called \s at/x) {
           __PACKAGE__->can($f)->(@_);
@@ -115,7 +117,7 @@
   # for possible further chaining)
   my (@in_sel, @out_sel, %renamed);
   for my $node (@sel) {
-    if (List::Util::first { $_ =~ / (?<! $re_alias ) $re_sep /x } ($node->{as}, $node->{unquoted_sql}) )  {
+    if (first { $_ =~ / (?<! $re_alias ) $re_sep /x } ($node->{as}, $node->{unquoted_sql}) )  {
       $node->{as} =~ s/ $re_sep /__/xg;
       my $quoted_as = $self->_quote($node->{as});
       push @in_sel, sprintf '%s AS %s', $node->{sql}, $quoted_as;

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Schema.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Schema.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -6,10 +6,11 @@
 use DBIx::Class::Exception;
 use Carp::Clan qw/^DBIx::Class/;
 use Try::Tiny;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
 use File::Spec;
-use Sub::Name ();
+use Sub::Name 'subname';
 use Module::Find();
+use Storable();
 use namespace::clean;
 
 use base qw/DBIx::Class/;
@@ -919,7 +920,7 @@
     no strict 'refs';
     no warnings 'redefine';
     foreach my $meth (qw/class source resultset/) {
-      *{"${target}::${meth}"} = Sub::Name::subname "${target}::${meth}" =>
+      *{"${target}::${meth}"} = subname "${target}::${meth}" =>
         sub { shift->schema->$meth(@_) };
     }
   }
@@ -1323,7 +1324,7 @@
 
   $source = $source->new({ %$source, source_name => $moniker });
   $source->schema($self);
-  Scalar::Util::weaken($source->{schema}) if ref($self);
+  weaken $source->{schema} if ref($self);
 
   my $rs_class = $source->result_class;
 
@@ -1431,7 +1432,7 @@
     {
       no strict 'refs';
       my $name = join '::', $target, 'schema';
-      *$name = Sub::Name::subname $name, sub { $schema };
+      *$name = subname $name, sub { $schema };
     }
 
     $schema->connection(@info);

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Informix.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Informix.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Informix.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -6,7 +6,8 @@
 use mro 'c3';
 
 use Scope::Guard ();
-use Context::Preserve ();
+use Context::Preserve 'preserve_context';
+use namespace::clean;
 
 __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
 
@@ -72,8 +73,7 @@
     $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
   });
 
-  return Context::Preserve::preserve_context(sub { $sub->() },
-    after => sub { $txn_scope_guard->commit });
+  return preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
 }
 
 =head2 connect_call_datetime_setup

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/InterBase.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/InterBase.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/InterBase.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -4,7 +4,7 @@
 use warnings;
 use base qw/DBIx::Class::Storage::DBI/;
 use mro 'c3';
-use List::Util();
+use List::Util 'first';
 use Try::Tiny;
 use namespace::clean;
 
@@ -80,7 +80,7 @@
       $generator = uc $generator unless $quoted;
 
       return $generator
-        if List::Util::first {
+        if first {
           $self->sql_maker->quote_char ? ($_ eq $col) : (uc($_) eq uc($col))
         } @trig_cols;
     }

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/MSSQL.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/MSSQL.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/MSSQL.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -6,10 +6,9 @@
 use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/;
 use mro 'c3';
 use Try::Tiny;
+use List::Util 'first';
 use namespace::clean;
 
-use List::Util();
-
 __PACKAGE__->mk_group_accessors(simple => qw/
   _identity _identity_method
 /);
@@ -50,12 +49,8 @@
   my $self = shift;
   my ($source, $cols, $data) = @_;
 
-  my $is_identity_insert = (List::Util::first
-      { $source->column_info ($_)->{is_auto_increment} }
-      (@{$cols})
-  )
-     ? 1
-     : 0;
+  my $is_identity_insert =
+    (first { $source->column_info ($_)->{is_auto_increment} } @{$cols}) ? 1 : 0;
 
   if ($is_identity_insert) {
      $self->_set_identity_insert ($source->name);
@@ -74,9 +69,8 @@
 
   my $supplied_col_info = $self->_resolve_column_info($source, [keys %$to_insert] );
 
-  my $is_identity_insert = (List::Util::first { $_->{is_auto_increment} } (values %$supplied_col_info) )
-     ? 1
-     : 0;
+  my $is_identity_insert =
+    (first { $_->{is_auto_increment} } values %$supplied_col_info) ? 1 : 0;
 
   if ($is_identity_insert) {
      $self->_set_identity_insert ($source->name);

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -4,9 +4,7 @@
 
 use base qw/DBIx::Class::Storage::DBI::MSSQL/;
 use mro 'c3';
-
-use List::Util();
-use Scalar::Util ();
+use Scalar::Util 'reftype';
 use Try::Tiny;
 use namespace::clean;
 
@@ -68,7 +66,7 @@
 
   my $dbi_attrs = $self->_dbi_connect_info->[-1];
 
-  unless (ref($dbi_attrs) && Scalar::Util::reftype($dbi_attrs) eq 'HASH') {
+  unless (ref($dbi_attrs) && reftype $dbi_attrs eq 'HASH') {
     $dbi_attrs = {};
     push @{ $self->_dbi_connect_info }, $dbi_attrs;
   }

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Scope::Guard ();
-use Context::Preserve ();
+use Context::Preserve 'preserve_context';
 use Try::Tiny;
 use namespace::clean;
 
@@ -361,8 +361,8 @@
     $self->_do_query('alter session set constraints = immediate');
   });
 
-  return Context::Preserve::preserve_context(sub { $sub->() },
-    after => sub { $txn_scope_guard->commit });
+  return
+    preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
 }
 
 =head1 AUTHOR

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Pg.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Pg.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Pg.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -10,7 +10,8 @@
 
 use DBD::Pg qw(:pg_types);
 use Scope::Guard ();
-use Context::Preserve ();
+use Context::Preserve 'preserve_context';
+use namespace::clean;
 
 # Ask for a DBD::Pg with array support
 warn __PACKAGE__.": DBD::Pg 2.9.2 or greater is strongly recommended\n"
@@ -36,8 +37,7 @@
     $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
   });
 
-  return Context::Preserve::preserve_context(sub { $sub->() },
-    after => sub { $txn_scope_guard->commit });
+  return preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
 }
 
 # only used when INSERT ... RETURNING is disabled

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -4,7 +4,7 @@
 use warnings;
 use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/;
 use mro 'c3';
-use List::Util ();
+use List::Util 'first';
 use Try::Tiny;
 use namespace::clean;
 
@@ -43,9 +43,8 @@
   my $self = shift;
   my ($source, $to_insert) = @_;
 
-  my $identity_col = List::Util::first {
-      $source->column_info($_)->{is_auto_increment}
-  } $source->columns;
+  my $identity_col =
+    first { $source->column_info($_)->{is_auto_increment} } $source->columns;
 
 # user might have an identity PK without is_auto_increment
   if (not $identity_col) {

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -5,8 +5,9 @@
   DBIx::Class::Storage::DBI::Sybase::ASE
 /;
 use mro 'c3';
-use List::Util ();
-use Scalar::Util ();
+use List::Util 'first';
+use Scalar::Util 'looks_like_number';
+use namespace::clean;
 
 sub _init {
   my $self = shift;
@@ -17,7 +18,7 @@
 
 sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method }
 
-my $number = sub { Scalar::Util::looks_like_number($_[0]) };
+my $number = sub { looks_like_number $_[0] };
 
 my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x };
 
@@ -38,7 +39,7 @@
 
   return $self->next::method(@_) if not defined $value or not defined $type;
 
-  if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) {
+  if (my $key = first { $type =~ /$_/i } keys %noquote) {
     return 1 if $noquote{$key}->($value);
   }
   elsif ($self->is_datatype_numeric($type) && $number->($value)) {

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -9,10 +9,10 @@
 /;
 use mro 'c3';
 use Carp::Clan qw/^DBIx::Class/;
-use Scalar::Util();
-use List::Util();
+use Scalar::Util 'blessed';
+use List::Util 'first';
 use Sub::Name();
-use Data::Dumper::Concise();
+use Data::Dumper::Concise 'Dumper';
 use Try::Tiny;
 use namespace::clean;
 
@@ -249,19 +249,18 @@
 
   my ($sql, $bind) = $self->next::method (@_);
 
-  my $table = Scalar::Util::blessed($ident) ? $ident->from : $ident;
+  my $table = blessed $ident ? $ident->from : $ident;
 
   my $bind_info = $self->_resolve_column_info(
     $ident, [map $_->[0], @{$bind}]
   );
-  my $bound_identity_col = List::Util::first
-    { $bind_info->{$_}{is_auto_increment} }
-    (keys %$bind_info)
+  my $bound_identity_col =
+    first { $bind_info->{$_}{is_auto_increment} }
+    keys %$bind_info
   ;
-  my $identity_col = Scalar::Util::blessed($ident) &&
-    List::Util::first
-    { $ident->column_info($_)->{is_auto_increment} }
-    $ident->columns
+  my $identity_col =
+    blessed $ident &&
+    first { $ident->column_info($_)->{is_auto_increment} } $ident->columns
   ;
 
   if (($op eq 'insert' && $bound_identity_col) ||
@@ -349,9 +348,9 @@
   my $self = shift;
   my ($source, $to_insert) = @_;
 
-  my $identity_col = (List::Util::first
-    { $source->column_info($_)->{is_auto_increment} }
-    $source->columns) || '';
+  my $identity_col =
+    (first { $source->column_info($_)->{is_auto_increment} } $source->columns)
+    || '';
 
   # check for empty insert
   # INSERT INTO foo DEFAULT VALUES -- does not work with Sybase
@@ -434,9 +433,8 @@
 
   my $table = $source->name;
 
-  my $identity_col = List::Util::first
-    { $source->column_info($_)->{is_auto_increment} }
-    $source->columns;
+  my $identity_col =
+    first { $source->column_info($_)->{is_auto_increment} } $source->columns;
 
   my $is_identity_update = $identity_col && defined $fields->{$identity_col};
 
@@ -485,14 +483,10 @@
   my $self = shift;
   my ($source, $cols, $data) = @_;
 
-  my $identity_col = List::Util::first
-    { $source->column_info($_)->{is_auto_increment} }
-    $source->columns;
+  my $identity_col =
+    first { $source->column_info($_)->{is_auto_increment} } $source->columns;
 
-  my $is_identity_insert = (List::Util::first
-    { $_ eq $identity_col }
-    @{$cols}
-  ) ? 1 : 0;
+  my $is_identity_insert = (first { $_ eq $identity_col } @{$cols}) ? 1 : 0;
 
   my @source_columns = $source->columns;
 
@@ -789,7 +783,7 @@
     if (not $sth) {
       $self->throw_exception(
           "Could not find row in table '$table' for blob update:\n"
-        . Data::Dumper::Concise::Dumper (\%where)
+        . (Dumper \%where)
       );
     }
 

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBI.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -11,12 +11,11 @@
 use DBI;
 use DBIx::Class::Storage::DBI::Cursor;
 use DBIx::Class::Storage::Statistics;
-use Scalar::Util();
-use List::Util();
-use Data::Dumper::Concise();
-use Sub::Name ();
+use Scalar::Util qw/refaddr weaken reftype blessed/;
+use Data::Dumper::Concise 'Dumper';
+use Sub::Name 'subname';
 use Try::Tiny;
-use File::Path ();
+use File::Path 'mkpath';
 use namespace::clean;
 
 __PACKAGE__->mk_group_accessors('simple' => qw/
@@ -67,7 +66,7 @@
 
   no strict qw/refs/;
   no warnings qw/redefine/;
-  *{__PACKAGE__ ."::$meth"} = Sub::Name::subname $meth => sub {
+  *{__PACKAGE__ ."::$meth"} = subname $meth => sub {
     if (not $_[0]->_driver_determined) {
       $_[0]->_determine_driver;
       goto $_[0]->can($meth);
@@ -1056,7 +1055,7 @@
       } else {
         # if connect_info is a CODEREF, we have no choice but to connect
         if (ref $self->_dbi_connect_info->[0] &&
-            Scalar::Util::reftype($self->_dbi_connect_info->[0]) eq 'CODE') {
+            reftype $self->_dbi_connect_info->[0] eq 'CODE') {
           $self->_populate_dbh;
           $driver = $self->_dbh->{Driver}{Name};
         }
@@ -1177,7 +1176,7 @@
 
     unless ($self->unsafe) {
       my $weak_self = $self;
-      Scalar::Util::weaken($weak_self);
+      weaken $weak_self;
       $dbh->{HandleError} = sub {
           if ($weak_self) {
             $weak_self->throw_exception("DBI Exception: $_[0]");
@@ -1392,7 +1391,7 @@
 sub _prep_for_execute {
   my ($self, $op, $extra_bind, $ident, $args) = @_;
 
-  if( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+  if( blessed $ident && $ident->isa("DBIx::Class::ResultSource") ) {
     $ident = $ident->from();
   }
 
@@ -1563,9 +1562,9 @@
       $cols->[$col_idx],
       do {
         local $Data::Dumper::Maxdepth = 1; # don't dump objects, if any
-        Data::Dumper::Concise::Dumper({
+        Dumper {
           map { $cols->[$_] => $data->[$slice_idx][$_] } (0 .. $#$cols)
-        }),
+        },
       }
     );
   };
@@ -1704,9 +1703,7 @@
 
     $self->throw_exception(sprintf "%s for populate slice:\n%s",
       ($tuple_status->[$i][1] || $err),
-      Data::Dumper::Concise::Dumper({
-        map { $cols->[$_] => $data->[$i][$_] } (0 .. $#$cols)
-      }),
+      Dumper { map { $cols->[$_] => $data->[$i][$_] } (0 .. $#$cols) },
     );
   }
 
@@ -2330,7 +2327,7 @@
     carp "No directory given, using ./\n";
     $dir = './';
   } else {
-      -d $dir or File::Path::mkpath($dir)
+      -d $dir or mkpath $dir
           or $self->throw_exception("create_ddl_dir: $! creating dir '$dir'");
   }
 

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBIHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBIHacks.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage/DBIHacks.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -14,6 +14,9 @@
 use mro 'c3';
 
 use Carp::Clan qw/^DBIx::Class/;
+use List::Util 'first';
+use Scalar::Util 'blessed';
+use namespace::clean;
 
 #
 # This code will remove non-selecting/non-restricting joins from
@@ -105,10 +108,7 @@
   # if a multi-type join was needed in the subquery - add a group_by to simulate the
   # collapse in the subq
   $inner_attrs->{group_by} ||= $inner_select
-    if List::Util::first
-      { ! $_->[0]{-is_single} }
-      (@{$inner_from}[1 .. $#$inner_from])
-  ;
+    if first { ! $_->[0]{-is_single} } (@{$inner_from}[1 .. $#$inner_from]);
 
   # generate the subquery
   my $subq = $self->_select_args_to_query (
@@ -324,7 +324,7 @@
 
   # the reason this is so contrived is that $ident may be a {from}
   # structure, specifying multiple tables to join
-  if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+  if ( blessed $ident && $ident->isa("DBIx::Class::ResultSource") ) {
     # this is compat mode for insert/update/delete which do not deal with aliases
     $alias2source->{me} = $ident;
     $rs_alias = 'me';

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/DBIx/Class/Storage.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -7,7 +7,7 @@
 use mro 'c3';
 
 use DBIx::Class::Exception;
-use Scalar::Util();
+use Scalar::Util 'weaken';
 use IO::File;
 use DBIx::Class::Storage::TxnScopeGuard;
 use Try::Tiny;
@@ -85,7 +85,7 @@
 sub set_schema {
   my ($self, $schema) = @_;
   $self->schema($schema);
-  Scalar::Util::weaken($self->{schema}) if ref $self->{schema};
+  weaken $self->{schema} if ref $self->{schema};
 }
 
 =head2 connected

Modified: DBIx-Class/0.08/branches/namespace-clean/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/lib/SQL/Translator/Parser/DBIx/Class.pm	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/lib/SQL/Translator/Parser/DBIx/Class.pm	2010-06-01 14:46:52 UTC (rev 9517)
@@ -15,7 +15,7 @@
 use Exporter;
 use SQL::Translator::Utils qw(debug normalize_name);
 use Carp::Clan qw/^SQL::Translator|^DBIx::Class|^Try::Tiny/;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
 use Try::Tiny;
 use namespace::clean;
 
@@ -35,7 +35,7 @@
 sub parse {
     # this is a hack to prevent schema leaks due to a retarded SQLT implementation
     # DO NOT REMOVE (until SQLT2 is out, the all of this will be rewritten anyway)
-    Scalar::Util::weaken ($_[1]) if ref ($_[1]);
+    weaken $_[1] if ref ($_[1]);
 
     my ($tr, $data)   = @_;
     my $args          = $tr->parser_args;

Modified: DBIx-Class/0.08/branches/namespace-clean/t/03podcoverage.t
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/t/03podcoverage.t	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/t/03podcoverage.t	2010-06-01 14:46:52 UTC (rev 9517)
@@ -2,9 +2,10 @@
 use strict;
 
 use Test::More;
-use List::Util ();
+use List::Util 'first';
 use lib qw(t/lib);
 use DBICTest;
+use namespace::clean;
 
 # Don't run tests for installs
 unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) {
@@ -140,8 +141,8 @@
 foreach my $module (@modules) {
   SKIP: {
 
-    my ($match) = List::Util::first
-      { $module =~ $_ }
+    my ($match) =
+      first { $module =~ $_ }
       (sort { length $b <=> length $a || $b cmp $a } (keys %$ex_lookup) )
     ;
 

Modified: DBIx-Class/0.08/branches/namespace-clean/t/52cycle.t
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/t/52cycle.t	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/t/52cycle.t	2010-06-01 14:46:52 UTC (rev 9517)
@@ -12,7 +12,8 @@
 
 use DBICTest;
 use DBICTest::Schema;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
+use namespace::clean;
 
 import Test::Memory::Cycle;
 
@@ -31,7 +32,7 @@
   my $row = $weak->{row} = $rs->first;
   memory_cycle_ok($row, 'No cycles in row');
 
-  Scalar::Util::weaken ($_) for values %$weak;
+  weaken $_ for values %$weak;
   memory_cycle_ok($weak, 'No cycles in weak object collection');
 }
 

Modified: DBIx-Class/0.08/branches/namespace-clean/t/cdbi/02-Film.t
===================================================================
--- DBIx-Class/0.08/branches/namespace-clean/t/cdbi/02-Film.t	2010-06-01 14:03:13 UTC (rev 9516)
+++ DBIx-Class/0.08/branches/namespace-clean/t/cdbi/02-Film.t	2010-06-01 14:46:52 UTC (rev 9517)
@@ -1,5 +1,7 @@
 use strict;
 use Test::More;
+use Scalar::Util 'refaddr';
+use namespace::clean;
 $| = 1;
 
 BEGIN {
@@ -383,21 +385,21 @@
   # my bad taste is your bad taste
   my $btaste  = Film->retrieve('Bad Taste');
   my $btaste2 = Film->retrieve('Bad Taste');
-  is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste2),
+  is refaddr $btaste, refaddr $btaste2,
     "Retrieving twice gives ref to same object";
 
   my ($btaste5) = Film->search(title=>'Bad Taste');
-  is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste5),
+  is refaddr $btaste, refaddr $btaste5,
     "Searching also gives ref to same object";
 
   $btaste2->remove_from_object_index;
   my $btaste3 = Film->retrieve('Bad Taste');
-  isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste3),
+  isnt refaddr $btaste2, refaddr $btaste3,
     "Removing from object_index and retrieving again gives new object";
 
   $btaste3->clear_object_index;
   my $btaste4 = Film->retrieve('Bad Taste');
-  isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste4),
+  isnt refaddr $btaste2, refaddr $btaste4,
     "Clearing cache and retrieving again gives new object";
  
   $btaste=Film->insert({
@@ -407,7 +409,7 @@
     NumExplodingSheep => 2,
   });
   $btaste2 = Film->retrieve('Bad Taste 2');
-  is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste2),
+  is refaddr $btaste, refaddr $btaste2,
     "Creating and retrieving gives ref to same object";
  
 }




More information about the Bast-commits mailing list