Cmd/WithDSN/Write.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 CC 2 SCAR 12.0
CC
2
Cov
0%
_build_backend
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 #!/usr/bin/perl
2  
3 package KiokuDB::Cmd::WithDSN::Write;
4 use Moose::Role;
5  
6 use Carp qw(croak);
7  
8 use namespace::clean -except => 'meta';
9  
10 with qw(
11 KiokuDB::Cmd::WithDSN
12 KiokuDB::Cmd::TXN
13 );
14  
15 requires "v";
16  
17 has dry_run => (
18 traits => [qw(Getopt)],
19 isa => "Bool",
20 is => "ro",
21 cmd_flag => "dry-run",
22 cmd_aliases => "n",
23 documentation => "don't modify the database",
24 );
25  
26 sub _build_backend {
27 my $self = shift;
28  
29 my $dsn = $self->dsn || croak("--dsn is required");
30  
31 $self->v("Connecting to DSN $dsn...");
32  
33 require KiokuDB::Util;
34  
35 my $b = KiokuDB::Util::dsn_to_backend( $dsn, $self->dry_run ? ( readonly => 1 ) : () );
36  
37 $self->v(" $b\n");
38  
39 $self->try_txn_begin($b);
40  
41 $b;
42 }
43  
44 __PACKAGE__
45  
46 __END__