From: Peter Rabbitson Date: Sat, 3 Jan 2015 16:30:14 +0000 (+0100) Subject: Emit Optional::Dependencies error messages in a way simplifying c/p for cpanm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34d2deae;p=dbsrgits%2FDBIx-Class.git Emit Optional::Dependencies error messages in a way simplifying c/p for cpanm The contrived no-space-containing output is sadly necessary - cpanm only considers an optspec if the module name is directly followed by ~ rabbit@Ahasver:~$ cpanm "SQL::Translator~ >= 0.11018" SQL::Translator is up to date. (0.11020) rabbit@Ahasver:~$ cpanm "SQL::Translator~ >=0.11018" SQL::Translator is up to date. (0.11020) rabbit@Ahasver:~$ cpanm "SQL::Translator ~ >= 0.11018" --> Working on SQL::Translator ^C --- diff --git a/Changes b/Changes index bc17ebb..88b863f 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ Revision history for DBIx::Class - Fix endless loop on BareSourcelessResultClass->throw_exception(...) * Misc + - Make the Optional::Dependencies error messages cpanm-friendly - Depend on newer SQL::Abstract (fixing overly-aggressive parenthesis opener: RT#99503) - Depend on newer Moo, fixing some interoperability issues: diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 9b8962d..9afc2be 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -723,8 +723,8 @@ sub _check_deps { my $res; if (keys %errors) { - my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) ); - $missing .= " (see $class for details)" if $reqs->{$group}{pod}; + my $missing = join (', ', map { $deps->{$_} ? qq("${_}~>=$deps->{$_}") : $_ } (sort keys %errors) ); + $missing .= " (see $class documentation for details)" if $reqs->{$group}{pod}; $res = { status => 0, errorlist => \%errors, @@ -926,7 +926,7 @@ be able to use a specific feature. For example if some of the requirements for C are not available, the returned string could look like: - SQL::Translator >= $sqltver (see $class for details) + "SQL::Translator~>=$sqltver" (see $class documentation for details) The author is expected to prepend the necessary text to this message before returning the actual error seen by the user. diff --git a/xt/optional_deps.t b/xt/optional_deps.t index 4507e3b..d73aab3 100644 --- a/xt/optional_deps.t +++ b/xt/optional_deps.t @@ -47,7 +47,14 @@ is_deeply ( like ( DBIx::Class::Optional::Dependencies->req_missing_for ('deploy'), - qr/^SQL::Translator \>\= \d/, + qr/ + (?: \A|\s ) + " SQL::Translator \~ \>\= [\d\.]+ " + \s + .*? + \Q(see DBIx::Class::Optional::Dependencies documentation for details)\E + \z + /x, 'expected missing string contents', );