File Coverage

blib/lib/App/bif/drop/hub.pm
Criterion Covered Total %
statement 15 26 57.6
branch 0 2 0.0
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 21 35 60.0


line stmt bran cond sub pod time code
1             package App::bif::drop::hub;
2 1     1   4506 use strict;
  1         2  
  1         32  
3 1     1   5 use warnings;
  1         2  
  1         32  
4 1     1   4 use Bif::Mo;
  1         2  
  1         7  
5 1     1   766 use DBIx::ThinSQL qw/sq/;
  1         27618  
  1         9  
6              
7             our $VERSION = '0.1.5_6';
8             extends 'App::bif';
9              
10             sub run {
11 1     1 1 2 my $self = shift;
12 1         14 my $opts = $self->opts;
13 1         9 my $dbw = $self->dbw;
14 0           my $info = $self->get_hub( $opts->{name} );
15              
16 0 0         if ( !$opts->{force} ) {
17 0           print "Nothing dropped (missing --force, -f)\n";
18 0           return $self->ok('DropNoForce');
19             }
20              
21 0           my $uuid = substr( $info->{uuid}, 0, 8 );
22              
23             $dbw->txn(
24             sub {
25 0     0     $self->start_work(
26             start => time,
27             start_comment => "drop hub $info->{name} <$uuid>",
28             billable => 0,
29             save => 1,
30             );
31              
32             $dbw->xdo(
33             delete_from => 'hubs',
34             where => { id => $info->{id} },
35 0           );
36              
37 0           print "Hub dropped: $info->{name} <$uuid>\n";
38              
39 0           $self->stop_work(
40             stop => time,
41             restore => 1,
42             );
43             }
44 0           );
45              
46 0           return $self->ok('DropHub');
47             }
48              
49             1;
50             __END__