File: OSPrereqs.pm

package info (click to toggle)
libdatetime-timezone-perl 1%3A2.47-1%2B2023d
  • links: PTS, VCS
  • area: main
  • in suites: bullseye-updates
  • size: 97,508 kB
  • sloc: perl: 2,688; sh: 36; makefile: 10
file content (73 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package inc::OSPrereqs;

use strict;
use warnings;
use namespace::autoclean;

use MetaCPAN::Client;

use Moose;

extends 'Dist::Zilla::Plugin::OSPrereqs';

# This fixes https://github.com/dagolden/Dist-Zilla-Plugin-OSPrereqs/issues/16
## no critic (ValuesAndExpressions::ProhibitInterpolationOfLiterals )
sub BUILDARGS {
    my ( $class, @arg ) = @_;
    my %copy = ref $arg[0] ? %{ $arg[0] } : @arg;

    my $zilla = delete $copy{zilla};
    my $name  = delete $copy{plugin_name};
    my $os    = delete $copy{prereq_os};

    my @dashed = grep {/^-/} keys %copy;

    my %other;
    for my $dkey (@dashed) {
        ( my $key = $dkey ) =~ s/^-//;

        $other{$key} = delete $copy{$dkey};
    }

    Carp::confess "don't try to pass -_prereq as a build arg!"
        if $other{_prereq};

    return {
        zilla       => $zilla,
        plugin_name => $name,
        ( defined $os ? ( prereq_os => $os ) : () ),
        _prereq => \%copy,
        %other,
    };
}

my $FallbackVersion = '1.94';
my $Version;

## no critic (Subroutines::ProhibitUnusedPrivateSubroutines )
sub _prereq {
    my $self = shift;

    return if $ENV{CI};

    return { 'DateTime::TimeZone::Local::Win32' => $Version }
        if $Version;

    my $release
        = MetaCPAN::Client->new->release('DateTime-TimeZone-Local-Win32');
    if ($release) {
        $Version = $release->version;
    }
    else {
        $Version = $FallbackVersion;
        $self->log_warning(
            "Could not find DateTime-TimeZone-Local-Win32 on MetaCPAN. Falling back to hard-coded version $FallbackVersion"
        );
    }

    return { 'DateTime::TimeZone::Local::Win32' => $Version };
}

__PACKAGE__->meta->make_immutable;

1;