File Coverage

blib/lib/Sentry/Util.pm
Criterion Covered Total %
statement 43 44 97.7
branch 6 10 60.0
condition 4 7 57.1
subroutine 12 12 100.0
pod 0 4 0.0
total 65 77 84.4


line stmt bran cond sub pod time code
1             use Mojo::Base -strict, -signatures;
2 9     9   218926  
  9         27  
  9         67  
3             use Exporter qw(import);
4 9     9   1721 use Mojo::Loader qw(load_class);
  9         15  
  9         234  
5 9     9   3583 use Mojo::Util qw(dumper monkey_patch);
  9         88066  
  9         517  
6 9     9   77 use UUID::Tiny ':std';
  9         17  
  9         338  
7 9     9   4541  
  9         126959  
  9         4775  
8             our @EXPORT_OK = qw(uuid4 truncate merge around);
9              
10             my $uuid = create_uuid_as_string(UUID_V4);
11             $uuid =~ s/-//g;
12 61     61 0 1227 return $uuid;
13 61         7661 }
14 61         463  
15             return $string if (ref($string) || $max == 0);
16              
17 12     12 0 2021 return length($string) <= $max ? $string : substr($string, 0, $max) . '...';
  12         18  
  12         18  
  12         16  
18 12 50 33     46 }
19              
20 12 100       46 $target->{$key}
21             = { ($target->{$key} // {})->%*, ($source->{$key} // {})->%* };
22             }
23 64     64 0 2285  
  64         71  
  64         64  
  64         77  
  64         70  
24             my %Patched = ();
25 64   100     361  
      50        
26             my $key = $package . '::' . $method;
27             return if $Patched{$key};
28              
29             if (my $e = load_class $package) {
30 10     10 0 2287 die ref $e ? "Exception: $e" : "Module $package not found";
  10         18  
  10         17  
  10         41  
  10         21  
31 10         32 }
32 10 100       40  
33             my $orig = $package->can($method);
34 8 50       40  
35 0 0       0 monkey_patch $package, $method => sub { $cb->($orig, @_) };
36              
37             $Patched{$key} = 1;
38 8         133230  
39             return;
40 8     7   85 }
  7     7   22702  
        2      
41              
42 8         208 1;