Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #52 from techman83/optimise_netkan_tool
Browse files Browse the repository at this point in the history
Minor code tidy up, make supplying token, netkan and cache optional
  • Loading branch information
techman83 committed May 22, 2016
2 parents 4cb1948 + 1f178a3 commit 5d56a8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
9 changes: 1 addition & 8 deletions lib/App/KSP_CKAN/NetKAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,8 @@ method _inflate_all(:$rescan = 1) {
$self->_NetKAN->pull;
local $CWD = $self->config->working."/".$self->_NetKAN->working;
foreach my $file (glob("NetKAN/*.netkan")) {

# TODO: We're already passing in the config, is it really
# necessary to pass in each of the other things as attributes?
my $config = $self->config;
my $netkan = App::KSP_CKAN::Tools::NetKAN->new(
config => $config,
netkan => $config->working."/netkan.exe",
cache => $config->cache,
token => $config->GH_token,
config => $self->config,
file => $file,
ckan_meta => $self->_CKAN_meta,
status => $self->_status,
Expand Down
18 changes: 15 additions & 3 deletions lib/App/KSP_CKAN/Tools/NetKAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ my $Status = sub {
};

has 'config' => ( is => 'ro', required => 1, isa => $Ref );
has 'netkan' => ( is => 'ro', required => 1 );
has 'cache' => ( is => 'ro', default => sub { File::Spec->tmpdir()."/NetKAN-cache"; } );
has 'file' => ( is => 'ro', required => 1 );
has 'ckan_meta' => ( is => 'ro', required => 1, isa => $Meta );
has 'status' => ( is => 'rw', required => 1, isa => $Status );
has 'token' => ( is => 'ro' );
has 'rescan' => ( is => 'ro', default => sub { 1 } );
has 'token' => ( is => 'ro', lazy => 1, builder => 1 );
has 'netkan' => ( is => 'ro', lazy => 1, builder => 1 );
has 'cache' => ( is => 'ro', lazy => 1, builder => 1 );
has '_ckan_meta_working' => ( is => 'ro', lazy => 1, builder => 1 );
has '_output' => ( is => 'ro', lazy => 1, builder => 1 );
has '_cli' => ( is => 'ro', lazy => 1, builder => 1 );
Expand Down Expand Up @@ -99,6 +99,18 @@ method _build__cli {
}
}

method _build_cache {
return $self->config->cache;
}

method _build_token {
return $self->config->GH_token;
}

method _build_netkan {
return $self->config->working."/netkan.exe";
}

method _build__status {
return $self->status->get_status($self->_basename);
}
Expand Down
8 changes: 1 addition & 7 deletions lib/App/KSP_CKAN/WebHooks/InflateNetKAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ method inflate($identifiers) {
next;
}

# TODO: We're already passing in the config, is it really
# necessary to pass in each of the other things as attributes?
my $config = $self->config;
my $netkan = App::KSP_CKAN::Tools::NetKAN->new(
config => $config,
netkan => $config->working."/netkan.exe",
cache => $config->cache,
token => $config->GH_token,
config => $self->config,
file => $file,
ckan_meta => $self->_CKAN_meta,
status => $self->_status,
Expand Down

0 comments on commit 5d56a8c

Please sign in to comment.