Make Pingback::pingback() do all the work, return list of advices (suggestions). More Pingback tests. Rename --check-for-updates to --version-check and document. Make VersionCheck::parse_server_response() optionally not split vars, so the same proto can be used for server advice lines.

This commit is contained in:
Daniel Nichter
2012-08-09 16:44:47 -06:00
parent 1370490fb6
commit 70c295bc0a
5 changed files with 173 additions and 72 deletions

View File

@@ -52,15 +52,15 @@ sub parse_server_response {
}
my ($response) = @args{@required_args};
PTDEBUG && _d('Server response:', $response);
my %items = map {
my ($item, $type, $vars) = split(";", $_);
my (@vars) = split(",", ($vars || ''));
if ( !defined $args{split_vars} || $args{split_vars} ) {
$vars = [ split(",", ($vars || '')) ];
}
$item => {
item => $item,
type => $type,
vars => \@vars,
vars => $vars,
};
} split("\n", $response);
@@ -252,9 +252,11 @@ sub get_bin_version {
return unless $cmd;
my $sanitized_command = File::Basename::basename($cmd);
PTDEBUG && _d('cmd:', $cmd, 'sanitized:', $sanitized_command);
return if $sanitized_command !~ /\A[a-zA-Z0-9_-]+\z/;
my $output = `$sanitized_command --version 2>&1`;
PTDEBUG && _d('output:', $output);
my ($version) = $output =~ /v?([0-9]+\.[0-9]+(?:\.[\w-]+)?)/;