File: perl.pm

package info (click to toggle)
devscripts 2.21.3%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,044 kB
  • sloc: perl: 26,093; sh: 10,874; python: 2,502; makefile: 341; ansic: 11
file content (36 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package Devscripts::Uscan::Ctype::perl;

use strict;

use Moo;
use JSON;
use Devscripts::Uscan::Output;

has dir => (is => 'ro');
has pkg => (
    is      => 'rw',
    lazy    => 1,
    default => sub {
        $_[0]->{dir} . '/META.json';
    });

sub version {
    my ($self) = @_;
    return unless $self->dir and -d $self->dir;
    unless (-r $self->pkg) {
        uscan_warn "Unable to read $self->{pkg}, skipping current version";
        return;
    }
    my ($version, $content);
    {
        local $/ = undef;
        open my $f, $self->pkg;
        $content = <$f>;
        close $f;
    }
    eval { $version = decode_json($content)->{version}; };
    uscan_warn $@ if $@;
    return $version;
}

1;