~ubuntu-branches/ubuntu/quantal/libyaml-libyaml-perl/quantal-security

« back to all changes in this revision

Viewing changes to inc/Module/Install/VersionCheck.pm

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann, Ansgar Burchardt, Salvatore Bonaccorso, gregor herrmann
  • Date: 2011-10-01 17:23:11 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20111001172311-lo7q2s7x0nmk3ihz
Tags: 0.37-1
[ Ansgar Burchardt ]
* debian/control: Convert Vcs-* fields to Git.

[ Salvatore Bonaccorso ]
* debian/copyright: Replace DEP5 Format-Specification URL from
  svn.debian.org to anonscm.debian.org URL.

[ gregor herrmann ]
* New upstream release.
* Update copyright years for inc/Module/*.
* Add /me to Uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#line 1
2
 
package Module::Install::VersionCheck;
3
 
use strict;
4
 
use warnings;
5
 
use 5.008003;
6
 
 
7
 
use Module::Install::Base;
8
 
 
9
 
my $DEFAULT = '0.00';
10
 
 
11
 
use vars qw($VERSION @ISA);
12
 
BEGIN {
13
 
    $VERSION = '0.11';
14
 
    @ISA     = 'Module::Install::Base';
15
 
}
16
 
 
17
 
sub version_check {
18
 
    my $self = shift;
19
 
    return unless $self->is_admin;
20
 
 
21
 
    my $module_version = $self->_get_module_version();
22
 
    my $changes_version = $self->_get_changes_version();
23
 
    my $git_tag_version = $self->_get_git_tag_version();
24
 
 
25
 
    $self->_report(
26
 
        $module_version,
27
 
        $changes_version,
28
 
        $git_tag_version,
29
 
    );
30
 
}
31
 
 
32
 
sub _get_module_version {
33
 
    my $self = shift;
34
 
    return $DEFAULT unless $self->admin->{extensions};
35
 
    my ($metadata) = grep {
36
 
        ref($_) eq 'Module::Install::Metadata';
37
 
    } @{$self->admin->{extensions}};
38
 
    return $DEFAULT unless $metadata;
39
 
    return $metadata->{values}{version} || $DEFAULT;
40
 
}
41
 
 
42
 
sub _get_changes_version {
43
 
    my $self = shift;
44
 
    return $DEFAULT unless -e 'Changes';
45
 
    open IN, 'Changes' or die "Can't open 'Changes' for input: $!";
46
 
    my $text = do {local $/; <IN>};
47
 
    $text =~ /\b(\d\.\d\d)\b/ or return $DEFAULT;
48
 
    return $1;
49
 
}
50
 
 
51
 
sub _get_git_tag_version {
52
 
    my $self = shift;
53
 
    return $DEFAULT unless -e '.git';
54
 
    require Capture::Tiny;
55
 
    my $text = Capture::Tiny::capture_merged(sub { system('git tag') });
56
 
    my $version = $DEFAULT;
57
 
    for (split "\n", $text) {
58
 
        if (/\b(\d\.\d\d)\b/ and $1 > $version) {
59
 
            $version = $1;
60
 
        }
61
 
    }
62
 
    return $version;
63
 
}
64
 
 
65
 
sub _report {
66
 
    my $self = shift;
67
 
    print "version_check @_\n";
68
 
}
69
 
 
70
 
1;
71
 
 
72
 
=encoding utf8
73
 
 
74
 
#line 107