File Coverage

lib/Data/URIID/Digest.pm
Criterion Covered Total %
statement 12 23 52.1
branch n/a
condition n/a
subroutine 4 10 40.0
pod 0 5 0.0
total 16 38 42.1


line stmt bran cond sub pod time code
1             # Copyright (c) 2023-2024 Philipp Schafft
2              
3             # licensed under Artistic License 2.0 (see LICENSE file)
4              
5             # ABSTRACT: Extractor for identifiers from URIs
6              
7             package Data::URIID::Digest;
8              
9 4     4   31 use strict;
  4         7  
  4         220  
10 4     4   80 use warnings;
  4         12  
  4         394  
11              
12 4     4   29 use parent qw(Digest::base);
  4         37  
  4         39  
13              
14 4     4   325 use Carp;
  4         7  
  4         1322  
15              
16             our $VERSION = v0.20;
17              
18              
19             # Private constructor:
20             sub _new {
21 0     0     my ($pkg, $value) = @_;
22 0           return bless \$value, $pkg;
23             }
24              
25             sub new {
26 0     0 0   croak 'Not implemented';
27             }
28              
29             sub add {
30 0     0 0   croak 'Not implemented';
31             }
32              
33             # Just return ourselfs as we do not reset on digest read.
34             sub clone {
35 0     0 0   return $_[0];
36             }
37              
38             # Core digest method:
39             sub digest {
40 0     0 0   my ($self) = @_;
41 0           return pack('H*', ${$self});
  0            
42             }
43              
44             # Helper to avoid pack()/unpack():
45             sub hexdigest {
46 0     0 0   my ($self) = @_;
47 0           return ${$self};
  0            
48             }
49              
50             1;
51              
52             __END__
53              
54             =pod
55              
56             =encoding UTF-8
57              
58             =head1 NAME
59              
60             Data::URIID::Digest - Extractor for identifiers from URIs
61              
62             =head1 VERSION
63              
64             version v0.20
65              
66             =head1 SYNOPSIS
67              
68             use Data::URIID::Digest;
69              
70             my $extractor = Data::URIID->new;
71             my $result = $extractor->lookup( $URI );
72             my $digest = $result->digest('sha-3-512', as => 'Digest');
73              
74             This is an internal module. It is used to emulate an object created by L<Digest>.
75              
76             This module inherits from L<Digest::base>.
77              
78             =head1 AUTHOR
79              
80             Philipp Schafft <lion@cpan.org>
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This software is Copyright (c) 2023-2025 by Philipp Schafft <lion@cpan.org>.
85              
86             This is free software, licensed under:
87              
88             The Artistic License 2.0 (GPL Compatible)
89              
90             =cut