package Devscripts::Uscan::Templates::Cran;

use strict;

sub transform {
    my $watchSource = shift;
    delete $watchSource->{template};
    my $package = delete $watchSource->{package};

    print "Package $package\n";

    die 'Missing Package field' unless $package;

    $watchSource->{source} ||= "https://cran.r-project.org/package=$package";
    $watchSource->{matchingpattern}
      ||= '.*_@ANY_VERSION@.tar.gz';    # zip and tgz files are binary packages
    $watchSource->{compression}    ||= 'xz';
    $watchSource->{dversionmangle} ||= 's/\+dfsg[0-9]*//g';
    $watchSource->{downloadurlmangle}
      ||= 's%.*/src/contrib/%https://cran.r-project.org/src/contrib/%';
    $watchSource->{repacksuffix} ||= '+dfsg';

    return $watchSource;
}

1;
