PurePerl/Compat.pm

filter: Statementstmt 100% 74 / 74 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 29 / 29 Podpod 85.7% 18 / 21 totaltotal 97.6% 123 / 126 SCAR 6.9
CC
2
Cov
100%
generator
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« PurePerl/RNG/rand.pm ↑ Summary
1 package UUID::Generator::PurePerl::Compat;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.02_01';
7  
8 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 *import = \&Exporter::import;
10  
11 3 our @EXPORT = qw( NameSpace_DNS NameSpace_URL NameSpace_OID NameSpace_X500 );
12  
13 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use UUID::Generator::PurePerl;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use UUID::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub new {
18 1 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19 1 my $self = bless {}, $class;
20  
21 1 return $self;
22 }
23  
24 sub generator {
25 17 ▶ my $self = shift;
Subroutine generator: called CC=2 SCAR=6.9
Pod undocumented
26  
27 17 ▶ if (! defined $self->{generator}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"generator"}) 1 16 17
28 1 $self->{generator} = UUID::Generator::PurePerl->new();
29 }
30  
31 17 return $self->{generator};
32 }
33  
34 sub _generate_v1 {
35 6 ▶ my ($self, $type) = @_;
Subroutine _generate_v1: called CC=1 SCAR=0.0
36  
37 6 return $self->generator->generate_v1()->$type();
38 }
39  
40 sub create_bin {
41 3 ▶ my $self = shift;
Subroutine create_bin: called CC=1 SCAR=0.0
Pod documented
42 3 return $self->_generate_v1('as_binary_np', @_);
43 }
44 3 *create = *create_bin;
45  
46 sub create_str {
47 1 ▶ my $self = shift;
Subroutine create_str: called CC=1 SCAR=0.0
Pod undocumented
48 1 return uc $self->_generate_v1('as_string', @_);
49 }
50  
51 sub create_hex {
52 1 ▶ my $self = shift;
Subroutine create_hex: called CC=1 SCAR=0.0
Pod documented
53 1 return '0x' . uc $self->_generate_v1('as_hex', @_);
54 }
55  
56 sub create_b64 {
57 1 ▶ my $self = shift;
Subroutine create_b64: called CC=1 SCAR=0.0
Pod documented
58 1 return $self->_generate_v1('as_base64_np', @_);
59 }
60  
61 sub _generate_v3 {
62 11 ▶ my ($self, $type, $ns, $name) = @_;
Subroutine _generate_v3: called CC=1 SCAR=0.0
63  
64 11 $ns = UUID::Object->create_from_binary_np($ns);
65  
66 11 return $self->generator->generate_v3($ns, $name)->$type();
67 }
68  
69 sub create_from_name_bin {
70 5 ▶ my $self = shift;
Subroutine create_from_name_bin: called CC=1 SCAR=0.0
Pod documented
71 5 return uc $self->_generate_v3('as_binary_np', @_);
72 }
73 3 *create_from_name = *create_from_name_bin;
74  
75 sub create_from_name_str {
76 2 ▶ my $self = shift;
Subroutine create_from_name_str: called CC=1 SCAR=0.0
Pod undocumented
77 2 return uc $self->_generate_v3('as_string', @_);
78 }
79  
80 sub create_from_name_hex {
81 2 ▶ my $self = shift;
Subroutine create_from_name_hex: called CC=1 SCAR=0.0
Pod documented
82 2 return '0x' . uc $self->_generate_v3('as_hex', @_);
83 }
84  
85 sub create_from_name_b64 {
86 2 ▶ my $self = shift;
Subroutine create_from_name_b64: called CC=1 SCAR=0.0
Pod documented
87 2 return $self->_generate_v3('as_base64_np', @_);
88 }
89  
90  
91 sub to_string {
92 1 ▶ my $self = shift;
Subroutine to_string: called CC=1 SCAR=0.0
Pod documented
93 1 return uc UUID::Object->create_from_binary_np(@_)->as_string;
94 }
95  
96 sub to_hexstring {
97 1 ▶ my $self = shift;
Subroutine to_hexstring: called CC=1 SCAR=0.0
Pod documented
98 1 return '0x' . uc UUID::Object->create_from_binary_np(@_)->as_hex;
99 }
100  
101 sub to_b64string {
102 2 ▶ my $self = shift;
Subroutine to_b64string: called CC=1 SCAR=0.0
Pod documented
103 2 return UUID::Object->create_from_binary_np(@_)->as_base64_np;
104 }
105  
106 sub from_string {
107 1 ▶ my $self = shift;
Subroutine from_string: called CC=1 SCAR=0.0
Pod documented
108 1 return UUID::Object->create_from_string(@_)->as_binary_np;
109 }
110  
111 sub from_hexstring {
112 1 ▶ my $self = shift;
Subroutine from_hexstring: called CC=1 SCAR=0.0
Pod documented
113 1 my $arg = shift;
114  
115 1 $arg =~ s{ \A 0x }{}ixmso;
116  
117 1 return UUID::Object->create_from_hex($arg)->as_binary_np;
118 }
119  
120 sub from_b64string {
121 1 ▶ my $self = shift;
Subroutine from_b64string: called CC=1 SCAR=0.0
Pod documented
122 1 return UUID::Object->create_from_base64_np(@_)->as_binary_np;
123 }
124  
125  
126 sub compare {
127 3 ▶ my ($self, $a, $b) = @_;
Subroutine compare: called CC=1 SCAR=0.0
Pod documented
128  
129 3 $a = UUID::Object->create_from_binary_np($a);
130 3 $b = UUID::Object->create_from_binary_np($b);
131  
132 3 return $a cmp $b;
133 }
134  
135  
136 sub NameSpace_DNS {
137 1 ▶ return UUID::Object::uuid_ns_dns()->as_binary_np;
Subroutine NameSpace_DNS: called CC=1 SCAR=0.0
Pod documented
138 }
139  
140 sub NameSpace_URL {
141 1 ▶ return UUID::Object::uuid_ns_url()->as_binary_np;
Subroutine NameSpace_URL: called CC=1 SCAR=0.0
Pod documented
142 }
143  
144 sub NameSpace_OID {
145 1 ▶ return UUID::Object::uuid_ns_oid()->as_binary_np;
Subroutine NameSpace_OID: called CC=1 SCAR=0.0
Pod documented
146 }
147  
148 sub NameSpace_X500 {
149 1 ▶ return UUID::Object::uuid_ns_x500()->as_binary_np;
Subroutine NameSpace_X500: called CC=1 SCAR=0.0
Pod documented
150 }
151  
152 3 1;
153 __END__
« PurePerl/RNG/rand.pm ↑ Summary