File Coverage

blib/lib/Sentry/Util.pm
Criterion Covered Total %
statement 43 44 97.7
branch 5 10 50.0
condition 4 7 57.1
subroutine 12 12 100.0
pod 0 4 0.0
total 64 77 83.1


line stmt bran cond sub pod time code
1             use Mojo::Base -strict, -signatures;
2 8     8   236213  
  8         20  
  8         55  
3             use Exporter qw(import);
4 8     8   1367 use Mojo::Loader qw(load_class);
  8         14  
  8         249  
5 8     8   3023 use Mojo::Util qw(dumper monkey_patch);
  8         83912  
  8         523  
6 8     8   64 use UUID::Tiny ':std';
  8         14  
  8         314  
7 8     8   3789  
  8         107178  
  8         3901  
8             our @EXPORT_OK = qw(uuid4 truncate merge around);
9              
10             my $uuid = create_uuid_as_string(UUID_V4);
11             $uuid =~ s/-//g;
12 58     58 0 1172 return $uuid;
13 58         6812 }
14 58         404  
15             return $string if (ref($string) || $max == 0);
16              
17 12     12 0 2130 return length($string) <= $max ? $string : substr($string, 0, $max) . '...';
  12         21  
  12         22  
  12         17  
18 12 50 33     63 }
19              
20 12 100       74 $target->{$key}
21             = { ($target->{$key} // {})->%*, ($source->{$key} // {})->%* };
22             }
23 64     64 0 2365  
  64         67  
  64         66  
  64         71  
  64         62  
24             my %Patched = ();
25 64   100     351  
      50        
26             my $key = $package . '::' . $method;
27             return if $Patched{$key};
28              
29             if (my $e = load_class $package) {
30 7     7 0 2351 die ref $e ? "Exception: $e" : "Module $package not found";
  7         12  
  7         11  
  7         21  
  7         29  
31 7         20 }
32 7 50       26  
33             my $orig = $package->can($method);
34 7 50       25  
35 0 0       0 monkey_patch $package, $method => sub { $cb->($orig, @_) };
36              
37             $Patched{$key} = 1;
38 7         89491  
39             return;
40 7     4   54 }
  4     4   7748  
        2      
41              
42 7         176 1;