Permalink
Browse files

Checking for latest App::DuckPAN now

  • Loading branch information...
1 parent 681b578 commit 9c5c14630ec6bb7130029e919ac672c339344d3a @Getty Getty committed Jul 7, 2013
Showing with 38 additions and 1 deletion.
  1. +35 −1 lib/App/DuckPAN.pm
  2. +1 −0 lib/App/DuckPAN/Cmd/Check.pm
  3. +1 −0 lib/App/DuckPAN/Cmd/Query.pm
  4. +1 −0 lib/App/DuckPAN/Cmd/Server.pm
View
@@ -22,7 +22,7 @@ use Carp;
use Encode;
use Path::Class;
-our $VERSION ||= '0.000';
+our $VERSION ||= '9.999';
option dukgo_login => (
is => 'ro',
@@ -255,6 +255,40 @@ sub get_local_ddg_version {
return $self->perl->get_local_version('DDG');
}
+sub get_local_app_duckpan_version {
+ my ( $self ) = @_;
+ return $self->perl->get_local_version('App::DuckPAN');
+}
+
+sub check_app_duckpan {
+ my ( $self ) = @_;
+ my $ok = 1;
+ my $installed_version = $self->get_local_app_duckpan_version;
+ return $ok if $installed_version && $installed_version == '9.999';
+ print "Checking for latest App::DuckPAN ... ";
+ my $tempfile = tmpnam;
+ if (is_success(getstore($self->duckpan_packages,$tempfile))) {
+ my $packages = Parse::CPAN::Packages::Fast->new($tempfile);
+ my $module = $packages->package('App::DuckPAN');
+ my $latest = $self->duckpan.'authors/id/'.$module->distribution->pathname;
+ if ($installed_version && version->parse($installed_version) >= version->parse($module->version)) {
+ print $installed_version;
+ print " (duckpan has ".$module->version.")" if $installed_version ne $module->version;
+ } else {
+ if ($installed_version) {
+ print "You have version ".$installed_version.", latest is ".$module->version."!\n";
+ }
+ print "[ERROR] Please install the latest App::DuckPAN package with: duckpan upgrade\n";
+ $ok = 0;
+ }
+ } else {
+ print "[ERROR] Can't download ".$self->duckpan_packages;
+ $ok = 0;
+ }
+ print "\n";
+ return $ok;
+}
+
sub check_ddg {
my ( $self ) = @_;
my $ok = 1;
@@ -8,6 +8,7 @@ use MooX::Options;
sub run {
my ( $self ) = @_;
+ exit 1 unless $self->app->check_app_duckpan;
if ($self->app->check_requirements) {
print "\n[ERROR] Check for the requirements failed!! See instructions or reports above\n\n";
exit 1;
@@ -7,6 +7,7 @@ with qw( App::DuckPAN::Cmd );
sub run {
my ( $self, @args ) = @_;
+ exit 1 unless $self->app->check_app_duckpan;
exit 1 unless $self->app->check_ddg;
my @blocks = @{$self->app->ddg->get_blocks_from_current_dir(@args)};
@@ -17,6 +17,7 @@ use Config::INI;
sub run {
my ( $self, @args ) = @_;
+ exit 1 unless $self->app->check_app_duckpan;
exit 1 unless $self->app->check_ddg;
dir($self->app->cfg->cache_path)->mkpath unless -d $self->app->cfg->cache_path;

0 comments on commit 9c5c146

Please sign in to comment.