| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 31 | use 5.006; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 37 |  | 
| 2 | 1 |  |  | 1 |  | 4 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 28 |  | 
| 3 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 39 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | package Metabase::Resource::perl::commit; | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.024'; # VERSION | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 4 | use Carp (); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 14 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 1 |  |  | 1 |  | 5 | use Metabase::Resource::perl; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 318 |  | 
| 11 |  |  |  |  |  |  | our @ISA = qw/Metabase::Resource::perl/; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub _metadata_types { | 
| 14 | 1 |  |  | 1 |  | 16 | return { sha1 => '//str', }; | 
| 15 |  |  |  |  |  |  | } | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub _init { | 
| 18 | 1 |  |  | 1 |  | 1 | my ($self) = @_; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  |  |  | 102 | my ($string) = $self =~ m{\Aperl:///commit/(.+)\z}; | 
| 21 | 1 | 50 | 33 |  |  | 7 | Carp::confess("could not determine commit from '$self'\n") | 
| 22 |  |  |  |  |  |  | unless defined $string && length $string; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 1 |  |  |  |  | 2 | my $sha1 = $1; | 
| 25 | 1 | 50 |  |  |  | 4 | Carp::confess("illegal commit hash") | 
| 26 |  |  |  |  |  |  | unless $sha1 =~ m/^[a-f0-9]+$/; | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 1 |  |  |  |  | 7 | $self->_add( 'sha1' => $sha1 ); | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 1 |  |  |  |  | 2 | return $self; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | # =method full_url | 
| 34 |  |  |  |  |  |  | # | 
| 35 |  |  |  |  |  |  | #   my $url = $self->full_url($host); | 
| 36 |  |  |  |  |  |  | # | 
| 37 |  |  |  |  |  |  | # Returns an ordinary HTTP URL to the resource.  If C<$host> is not | 
| 38 |  |  |  |  |  |  | # given, it defaults to the official master Perl repository at | 
| 39 |  |  |  |  |  |  | # L. | 
| 40 |  |  |  |  |  |  | # | 
| 41 |  |  |  |  |  |  | # =cut | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub full_url { | 
| 44 | 2 |  |  | 2 | 1 | 5 | my ( $self, $host ) = @_; | 
| 45 | 2 |  | 100 |  |  | 13 | $host ||= 'perl5.git.perl.org'; | 
| 46 | 2 |  |  |  |  | 9 | return "http://${host}/perl.git/" . $self->sha1; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | # 'commit' validates during _init, really | 
| 50 | 1 |  |  | 1 | 1 | 2 | sub validate { 1 } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | # =pod | 
| 53 |  |  |  |  |  |  | # | 
| 54 |  |  |  |  |  |  | # =head1 SYNOPSIS | 
| 55 |  |  |  |  |  |  | # | 
| 56 |  |  |  |  |  |  | #   my $resource = Metabase::Resource->new( | 
| 57 |  |  |  |  |  |  | #     'perl:///commit/8c576062', | 
| 58 |  |  |  |  |  |  | #   ); | 
| 59 |  |  |  |  |  |  | # | 
| 60 |  |  |  |  |  |  | #   my $resource_meta = $resource->metadata; | 
| 61 |  |  |  |  |  |  | #   my $typemap       = $resource->metadata_types; | 
| 62 |  |  |  |  |  |  | #   my $url = $self->full_url; | 
| 63 |  |  |  |  |  |  | # | 
| 64 |  |  |  |  |  |  | # =head1 DESCRIPTION | 
| 65 |  |  |  |  |  |  | # | 
| 66 |  |  |  |  |  |  | # Generates resource metadata for resources of the scheme 'perl:///commit'. | 
| 67 |  |  |  |  |  |  | # | 
| 68 |  |  |  |  |  |  | #   my $resource = Metabase::Resource->new( | 
| 69 |  |  |  |  |  |  | #     'perl:///commit/8c576062', | 
| 70 |  |  |  |  |  |  | #   ); | 
| 71 |  |  |  |  |  |  | # | 
| 72 |  |  |  |  |  |  | # For the example above, the resource metadata structure would contain the | 
| 73 |  |  |  |  |  |  | # following elements: | 
| 74 |  |  |  |  |  |  | # | 
| 75 |  |  |  |  |  |  | #   scheme       => perl | 
| 76 |  |  |  |  |  |  | #   type         => commit | 
| 77 |  |  |  |  |  |  | #   sha1         => 8c576062 | 
| 78 |  |  |  |  |  |  | # | 
| 79 |  |  |  |  |  |  | # =head1 BUGS | 
| 80 |  |  |  |  |  |  | # | 
| 81 |  |  |  |  |  |  | # Please report any bugs or feature using the CPAN Request Tracker. | 
| 82 |  |  |  |  |  |  | # Bugs can be submitted through the web interface at | 
| 83 |  |  |  |  |  |  | # L | 
| 84 |  |  |  |  |  |  | # | 
| 85 |  |  |  |  |  |  | # When submitting a bug or request, please include a test-file or a patch to an | 
| 86 |  |  |  |  |  |  | # existing test-file that illustrates the bug or desired feature. | 
| 87 |  |  |  |  |  |  | # | 
| 88 |  |  |  |  |  |  | # =cut | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | 1; | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | # ABSTRACT: class for Metabase resources about perl commits | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | __END__ |