|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ## no critic: Modules::ProhibitAutomaticExportation  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Perinci::Package::CopyContents;  | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY  | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $DATE = '2020-02-16'; # DATE  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $DIST = 'Perinci-Package-CopyContents'; # DIST  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '0.002'; # VERSION  | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
53815
 | 
 use strict 'subs', 'vars';  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
    | 
| 
10
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
5
 | 
 use warnings;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
    | 
| 
11
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
1325
 | 
 use Log::ger;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Exporter;  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @ISA = qw(Exporter);  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT = qw(copy_contents_from);  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
612
 | 
 use Package::CopyContents ();  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1279
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
168
 | 
    | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub copy_contents_from {  | 
| 
20
 | 
1
 | 
  
 50
  
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
83
 | 
     my $opts = ref $_[0] eq 'HASH' ? shift : {};  | 
| 
21
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
     my $src_pkg = shift;  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $opts->{to} = caller unless defined $opts->{to};  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $opts->{_before_copy} = sub {  | 
| 
26
 | 
24
 | 
 
 | 
 
 | 
  
24
  
 | 
 
 | 
843
 | 
         my ($name, $src_pkg, $target_pkg, $opts, $overwrite) = @_;  | 
| 
27
 | 
24
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
40
 | 
         return 1 if $name eq '%SPEC';  | 
| 
28
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
         0;  | 
| 
29
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     };  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $opts->{_after_copy} = sub {  | 
| 
31
 | 
23
 | 
 
 | 
 
 | 
  
23
  
 | 
 
 | 
463
 | 
         my ($name, $src_pkg, $target_pkg, $opts, $overwrite) = @_;  | 
| 
32
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
         ${"$target_pkg\::SPEC"}{$name} = ${"$src_pkg\::SPEC"}{$name}  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
    | 
| 
33
 | 
23
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
28
 | 
             if defined ${"$src_pkg\::SPEC"}{$name};  | 
| 
 
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
73
 | 
    | 
| 
34
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     };  | 
| 
35
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     Package::CopyContents::copy_contents_from($opts, $src_pkg);  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Copy (some) contents from another package (with Rinci metadata awareness)  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |