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   221213  
  8         21  
  8         51  
3             use Exporter qw(import);
4 8     8   1346 use Mojo::Loader qw(load_class);
  8         15  
  8         209  
5 8     8   2955 use Mojo::Util qw(dumper monkey_patch);
  8         79424  
  8         449  
6 8     8   54 use UUID::Tiny ':std';
  8         13  
  8         284  
7 8     8   3349  
  8         102170  
  8         3774  
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 1535 return $uuid;
13 58         6427 }
14 58         391  
15             return $string if (ref($string) || $max == 0);
16              
17 12     12 0 2571 return length($string) <= $max ? $string : substr($string, 0, $max) . '...';
  12         16  
  12         17  
  12         13  
18 12 50 33     69 }
19              
20 12 100       50 $target->{$key}
21             = { ($target->{$key} // {})->%*, ($source->{$key} // {})->%* };
22             }
23 64     64 0 2531  
  64         69  
  64         68  
  64         77  
  64         69  
24             my %Patched = ();
25 64   100     321  
      50        
26             my $key = $package . '::' . $method;
27             return if $Patched{$key};
28              
29             if (my $e = load_class $package) {
30 7     7 0 2875 die ref $e ? "Exception: $e" : "Module $package not found";
  7         15  
  7         9  
  7         18  
  7         11  
31 7         18 }
32 7 50       25  
33             my $orig = $package->can($method);
34 7 50       21  
35 0 0       0 monkey_patch $package, $method => sub { $cb->($orig, @_) };
36              
37             $Patched{$key} = 1;
38 7         85672  
39             return;
40 7     4   52 }
  4     4   8011  
        2      
41              
42 7         135 1;