From: Dagfinn Ilmari Mannsåker Date: Tue, 27 Jan 2015 19:03:29 +0000 (+0000) Subject: Use {List,Sub}::Util instead of List::MoreUtils and Sub::Name X-Git-Tag: 0.07043~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ecf22f0ae0e0f639c0fc8dad9529a66b9374bfbd;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Use {List,Sub}::Util instead of List::MoreUtils and Sub::Name That means bumping the dependency on List::Util to 1.33, which means people on perl < 5.20 will have to upgrade anyway, so we might as well use Sub::Util (added in 1.40) instead of Sub::Name as well. Nick the apply, firstidx and uniq functions from List::MoreUtils::PP into DBIx::Class::Schema::Loader::Utils to avoid depending on it. --- diff --git a/Changes b/Changes index fe6a442..636f703 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader - Fix many_to_many bridges with overlapping foreign keys - Document how to add perltidy markers via filter_generated_code - Fix DB2 foreign-key introspection + - Remove dependency on List::MoreUtils and Sub::Name 0.07042 2014-08-20 - Fix unescaped left braces in regexes in tests diff --git a/Makefile.PL b/Makefile.PL index db297ef..e7573a7 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -49,13 +49,13 @@ requires 'Hash::Merge' => '0.12'; requires 'Lingua::EN::Inflect::Number' => '1.1'; requires 'Lingua::EN::Tagger' => '0.23'; requires 'Lingua::EN::Inflect::Phrase' => '0.15'; -requires 'List::MoreUtils' => '0.32'; +requires 'List::Util' => '1.33'; requires 'MRO::Compat' => '0.09'; requires 'namespace::clean' => '0.23'; requires 'Scope::Guard' => '0.20'; requires 'String::ToIdentifier::EN' => '0.05'; requires 'String::CamelCase' => '0.02'; -requires 'Sub::Name' => 0; +requires 'Sub::Util' => '1.40'; requires 'Try::Tiny' => 0; # core, but specific versions not available on older perls diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 55b1398..5411f80 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -7,7 +7,7 @@ use MRO::Compat; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use Scalar::Util 'weaken'; -use Sub::Name 'subname'; +use Sub::Util 'set_subname'; use DBIx::Class::Schema::Loader::Utils 'array_eq'; use Try::Tiny; use Hash::Merge 'merge'; @@ -341,7 +341,7 @@ sub connection { # ->load_components and we are now in a different place in the mro. no warnings 'redefine'; - local *connection = subname __PACKAGE__.'::connection' => sub { + local *connection = set_subname __PACKAGE__.'::connection' => sub { my $self = shift; $self->next::method(@_); }; diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index ab03a98..26d952a 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -20,12 +20,12 @@ use File::Temp (); use Class::Unload; use Class::Inspector (); use Scalar::Util 'looks_like_number'; -use DBIx::Class::Schema::Loader::Utils qw/split_name dumper_squashed eval_package_without_redefine_warnings class_path slurp_file sigwarn_silencer/; +use DBIx::Class::Schema::Loader::Utils qw/split_name dumper_squashed eval_package_without_redefine_warnings class_path slurp_file sigwarn_silencer firstidx uniq/; use DBIx::Class::Schema::Loader::Optional::Dependencies (); use Try::Tiny; use DBIx::Class (); use Encode qw/encode decode/; -use List::MoreUtils qw/all any firstidx uniq/; +use List::Util qw/all any none/; use File::Temp 'tempfile'; use namespace::clean; @@ -1283,7 +1283,7 @@ sub new { if (ref $self->moniker_parts ne 'ARRAY') { croak 'moniker_parts must be an arrayref'; } - if ((firstidx { $_ eq 'name' } @{ $self->moniker_parts }) == -1) { + if (none { $_ eq 'name' } @{ $self->moniker_parts }) { croak "moniker_parts option *must* contain 'name'"; } } diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index 5a895dc..653d30a 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -5,7 +5,7 @@ use warnings; use base qw/DBIx::Class::Schema::Loader::Base/; use mro 'c3'; use Try::Tiny; -use List::MoreUtils 'any'; +use List::Util 'any'; use Carp::Clan qw/^DBIx::Class/; use namespace::clean; use DBIx::Class::Schema::Loader::Table (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm index 45dabd3..942c064 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm @@ -8,7 +8,7 @@ use base qw/ /; use mro 'c3'; -use List::MoreUtils 'any'; +use List::Util 'any'; use namespace::clean; use DBIx::Class::Schema::Loader::Table (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Informix.pm b/lib/DBIx/Class/Schema/Loader/DBI/Informix.pm index 6ca0a2f..5111371 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Informix.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Informix.pm @@ -5,7 +5,7 @@ use warnings; use base qw/DBIx::Class::Schema::Loader::DBI/; use mro 'c3'; use Scalar::Util 'looks_like_number'; -use List::MoreUtils 'any'; +use List::Util 'any'; use Try::Tiny; use namespace::clean; use DBIx::Class::Schema::Loader::Table::Informix (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 57d9d41..214177c 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -5,7 +5,7 @@ use warnings; use base 'DBIx::Class::Schema::Loader::DBI::Sybase::Common'; use mro 'c3'; use Try::Tiny; -use List::MoreUtils 'any'; +use List::Util 'any'; use namespace::clean; use DBIx::Class::Schema::Loader::Table::Sybase (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm index ce8fa15..2c86347 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm @@ -4,7 +4,7 @@ use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault'; use mro 'c3'; -use List::MoreUtils 'any'; +use List::Util 'any'; use namespace::clean; use DBIx::Class::Schema::Loader::Table (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm index 05515e8..feae2b2 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm @@ -4,7 +4,7 @@ use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI::Sybase::Common'; use mro 'c3'; -use List::MoreUtils 'any'; +use List::Util 'any'; use namespace::clean; use DBIx::Class::Schema::Loader::Table::Sybase (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index 4c02f57..8a2559c 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -5,8 +5,7 @@ use warnings; use base 'DBIx::Class::Schema::Loader::DBI'; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; -use List::Util 'first'; -use List::MoreUtils 'any'; +use List::Util qw/any first/; use Try::Tiny; use Scalar::Util 'blessed'; use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/; diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index 64b3f40..b3ea5ef 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -6,10 +6,9 @@ use base 'Class::Accessor::Grouped'; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use Scalar::Util 'weaken'; -use DBIx::Class::Schema::Loader::Utils qw/split_name slurp_file array_eq/; +use DBIx::Class::Schema::Loader::Utils qw/split_name slurp_file array_eq apply uniq/; use Try::Tiny; -use List::Util 'first'; -use List::MoreUtils qw/apply uniq any all/; +use List::Util qw/all any first/; use namespace::clean; use Lingua::EN::Inflect::Phrase (); use Lingua::EN::Tagger (); diff --git a/lib/DBIx/Class/Schema/Loader/Utils.pm b/lib/DBIx/Class/Schema/Loader/Utils.pm index fca3c2f..f6315de 100644 --- a/lib/DBIx/Class/Schema/Loader/Utils.pm +++ b/lib/DBIx/Class/Schema/Loader/Utils.pm @@ -11,7 +11,7 @@ use namespace::clean; use Exporter 'import'; use Data::Dumper (); -our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path no_warnings warnings_exist warnings_exist_silent slurp_file write_file array_eq sigwarn_silencer/; +our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path no_warnings warnings_exist warnings_exist_silent slurp_file write_file array_eq sigwarn_silencer apply firstidx uniq/; use constant BY_CASE_TRANSITION_V7 => qr/(?<=[[:lower:]\d])[\W_]*(?=[[:upper:]])|[\W_]+/; @@ -61,6 +61,27 @@ sub sigwarn_silencer { return sub { &$orig_sig_warn unless $_[0] =~ $pattern }; } +# Copied with stylistic adjustments from List::MoreUtils::PP +sub firstidx (&@) { + my $f = shift; + foreach my $i (0..$#_) { + local *_ = \$_[$i]; + return $i if $f->(); + } + return -1; +} + +sub uniq (@) { + my %seen = (); + grep { not $seen{$_}++ } @_; +} + +sub apply (&@) { + my $action = shift; + $action->() foreach my @values = @_; + wantarray ? @values : $values[-1]; +} + sub eval_package_without_redefine_warnings { my ($pkg, $code) = @_; diff --git a/maint/travis-ci_scripts/30_before_script.bash b/maint/travis-ci_scripts/30_before_script.bash index 689c9ca..9c35b96 100755 --- a/maint/travis-ci_scripts/30_before_script.bash +++ b/maint/travis-ci_scripts/30_before_script.bash @@ -110,7 +110,7 @@ else parallel_installdeps_notest File::Spec Data::Dumper Module::Runtime parallel_installdeps_notest Test::Exception Encode::Locale Test::Fatal parallel_installdeps_notest Test::Warn B::Hooks::EndOfScope Test::Differences HTTP::Status - parallel_installdeps_notest Test::Pod::Coverage Test::EOL Devel::GlobalDestruction Sub::Name MRO::Compat Class::XSAccessor URI::Escape HTML::Entities + parallel_installdeps_notest Test::Pod::Coverage Test::EOL Devel::GlobalDestruction Sub::Util MRO::Compat Class::XSAccessor URI::Escape HTML::Entities parallel_installdeps_notest YAML LWP Class::Trigger JSON::XS DateTime::Format::Builder Class::Accessor::Grouped Package::Variant parallel_installdeps_notest SQL::Abstract Moose Module::Install JSON SQL::Translator File::Which parallel_installdeps_notest Module::Install::ReadmeFromPod diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 7bf14dd..4576d33 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -13,8 +13,7 @@ use File::Path 'rmtree'; use DBI; use File::Find 'find'; use Class::Unload (); -use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file sigwarn_silencer/; -use List::MoreUtils 'apply'; +use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file sigwarn_silencer apply/; use DBIx::Class::Schema::Loader::Optional::Dependencies (); use Try::Tiny; use File::Spec::Functions 'catfile'; diff --git a/t/lib/dbixcsl_dumper_tests.pm b/t/lib/dbixcsl_dumper_tests.pm index cc25509..d16a3bb 100644 --- a/t/lib/dbixcsl_dumper_tests.pm +++ b/t/lib/dbixcsl_dumper_tests.pm @@ -5,7 +5,7 @@ use Test::More; use File::Path; use IPC::Open3; use IO::Handle; -use List::MoreUtils 'any'; +use List::Util 'any'; use DBIx::Class::Schema::Loader::Utils 'dumper_squashed'; use DBIx::Class::Schema::Loader (); use Class::Unload ();