| 1 |
package Test2::Harness::Util::UUID; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
our $VERSION = '1.000179'; |
| 6 |
|
| 7 |
use Data::UUID; |
| 8 |
use Importer 'Importer' => 'import'; |
| 9 |
|
| 10 |
our @EXPORT = qw/gen_uuid/; |
| 11 |
our @EXPORT_OK = qw/UG gen_uuid/; |
| 12 |
|
| 13 |
my ($UG, $UG_PID); |
| 14 |
sub UG { |
| 15 |
return $UG if $UG && $UG_PID && $UG_PID == $$; |
| 16 |
|
| 17 |
$UG_PID = $$; |
| 18 |
return $UG = Data::UUID->new; |
| 19 |
} |
| 20 |
|
| 21 |
sub gen_uuid { UG()->create_str() } |
| 22 |
|
| 23 |
1; |
| 24 |
|
| 25 |
__END__ |
| 26 |
|
| 27 |
=pod |
| 28 |
|
| 29 |
=encoding UTF-8 |
| 30 |
|
| 31 |
=head1 NAME |
| 32 |
|
| 33 |
Test2::Harness::Util::UUID - Utils for generating UUIDs. |
| 34 |
|
| 35 |
=head1 DESCRIPTION |
| 36 |
|
| 37 |
This module provides a consistent UUID source for all of Test2::Harness. |
| 38 |
|
| 39 |
=head1 SYNOPSIS |
| 40 |
|
| 41 |
use Test2::Harness::Util::UUID qw/gen_uuid/; |
| 42 |
|
| 43 |
my $uuid = gen_uuid; |
| 44 |
|
| 45 |
=head1 EXPORTS |
| 46 |
|
| 47 |
=over 4 |
| 48 |
|
| 49 |
=item $uuid = gen_uuid() |
| 50 |
|
| 51 |
Generate a UUID. |
| 52 |
|
| 53 |
=back |
| 54 |
|
| 55 |
=head1 SOURCE |
| 56 |
|
| 57 |
The source code repository for Test2-Harness can be found at |
| 58 |
F<http://github.com/Test-More/Test2-Harness/>. |
| 59 |
|
| 60 |
=head1 MAINTAINERS |
| 61 |
|
| 62 |
=over 4 |
| 63 |
|
| 64 |
=item Chad Granum E<lt>[email protected]<gt> |
| 65 |
|
| 66 |
=back |
| 67 |
|
| 68 |
=head1 AUTHORS |
| 69 |
|
| 70 |
=over 4 |
| 71 |
|
| 72 |
=item Chad Granum E<lt>[email protected]<gt> |
| 73 |
|
| 74 |
=back |
| 75 |
|
| 76 |
=head1 COPYRIGHT |
| 77 |
|
| 78 |
Copyright 2020 Chad Granum E<lt>[email protected]<gt>. |
| 79 |
|
| 80 |
This program is free software; you can redistribute it and/or |
| 81 |
modify it under the same terms as Perl itself. |
| 82 |
|
| 83 |
See F<http://dev.perl.org/licenses/> |
| 84 |
|
| 85 |
=cut |