String-Redactable
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
a module.
To build the distribution, run this file normally:
% perl Makefile.PL
But, it's more interesting than that. You can load it with C<require>
and call C<arguments> to get the data structure it passes to
C<WriteMakefile>:
my $package = require '/path/to/Makefile.PL';
my $arguments = $package->arguments;
Note that C<require>-ing a file makes an entry in C<%INC> for exactly
that name. If you try to C<require> another file with the same name,
even from a different path, C<require> thinks it has already loaded
the file. As such, I recommend you always require the full path to the
file.
The return value of the C<require> is a package name (in this case,
the name of the main module. Use that to call the C<arguments> method.
lib/String/Redactable.pm view on Meta::CPAN
map { $_ => sub { () } } qw(
<=> cmp
lt le gt ge eq ne
~~
)
;
my %keys = ();
my $new_key = sub ($class, $length = 512) {
state $rc = require List::Util;
substr(
join( '',
List::Util::shuffle(
map { List::Util::shuffle( 'A' .. 'Z', 'a' .. 'z', qw(= ! : ;) ) } 1 .. 25
)
),
0, $length
)
;
};
lib/String/Redactable.pm view on Meta::CPAN
delete $keys{overload::StrVal($self)};
}
=item placeholder
The value that is substituted for the actual string.
=cut
sub placeholder ( $class ) {
state $rc = require Carp;
Carp::cluck(
"Possible unintended interpolation of a redactable string",
) if warnings::enabled();
'<redacted data>'
}
=item STORABLE_freeze
Redact strings used in L<Storable>.
t/multiple.t view on Meta::CPAN
use v5.20;
use utf8;
use open qw(:std :utf8);
use Test::More;
use Data::Dumper;
my $class = require './Makefile.PL';
my $warnings;
$SIG{__WARN__} = sub { $warnings = $_[0] };
my $warning_regex = qr/Possible unintended interpolation of a redactable string/;
subtest 'sanity' => sub {
use_ok $class;
can_ok $class, qw(new placeholder);
isa_ok my $obj = $class->new('1234'), $class;
t/placeholder.t view on Meta::CPAN
use v5.20;
use Test::More;
no warnings;
use String::Redactable;
my $class;
BEGIN { $class = require './Makefile.PL' }
my $method = 'placeholder';
subtest 'sanity' => sub {
use_ok $class;
can_ok $class, $method;
};
subtest 'warnings enabled' => sub {
use warnings;
use v5.20;
use utf8;
use open qw(:std :utf8);
use Test::More;
use Data::Dumper;
my $class = require './Makefile.PL';
my $warnings;
$SIG{__WARN__} = sub { $warnings = $_[0] };
my $warning_regex = qr/Possible unintended interpolation of a redactable string/;
subtest 'sanity' => sub {
use_ok $class;
can_ok $class, qw(new placeholder);
isa_ok my $obj = $class->new('1234'), $class;
use v5.20;
use Test::More;
use Data::Dumper;
my $parent_class = require './Makefile.PL';
my $class = 'Tie::' . $parent_class;
subtest 'sanity' => sub {
use_ok $class;
can_ok $class, qw(new);
local $SIG{__WARN__} = sub {};
my $string = 'abcdef';
isa_ok my $obj = $class->new('1234'), $class;
( run in 0.874 second using v1.01-cache-2.11-cpan-39bf76dae61 )