line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Environment::Plugin::Dump; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::Environment::Plugin::Dump - Dump files reader plugin |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Test::Environment qw{ |
10
|
|
|
|
|
|
|
Dump |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
dump_with_name('some_file.txt'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
set_dumps_folder($FindBin::Bin.'/dumps2'); |
16
|
|
|
|
|
|
|
dump_with_name('some_other_file.txt'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This plugin will export 'dump_with_name' and 'set_dumps_folder' functions. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
set_dumps_folder($path) will set the root path where dump files will be looked |
23
|
|
|
|
|
|
|
up. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
dump_with_name($file_name) will return |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
File::Slurp::read_file($dump_folder.'/'.$file_name) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Default $dump_folder is $FindBin::Bin.'/dumps'. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
35
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = "0.07"; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
5
|
use base qw{ Exporter }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
108
|
|
40
|
|
|
|
|
|
|
our @EXPORT = qw{ |
41
|
|
|
|
|
|
|
dump_with_name |
42
|
|
|
|
|
|
|
set_dumps_folder |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
5
|
use Carp::Clan; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
46
|
1
|
|
|
1
|
|
123
|
use File::Slurp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
47
|
1
|
|
|
1
|
|
5
|
use FindBin; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
213
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 FUNCTIONS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 import |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
All functions are exported 2 levels up. That is to the use Test::Environment caller. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub import { |
59
|
1
|
|
|
1
|
|
2
|
my $package = shift; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# export symbols two levels up - to the Test::Environment caller |
62
|
1
|
|
|
|
|
126
|
__PACKAGE__->export_to_level(2, $package, @EXPORT); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 dump_with_name($name) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns read_file($dumps_folder.'/'.$name). |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our $dumps_folder = $FindBin::Bin.'/dumps'; |
73
|
|
|
|
|
|
|
sub dump_with_name { |
74
|
1
|
|
|
1
|
1
|
7
|
my $name = shift; |
75
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
6
|
croak 'please set dump name' if not defined $name; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
4
|
$name = $dumps_folder.'/'.$name; |
79
|
1
|
50
|
|
|
|
37
|
croak 'file not found "'.$name.'"' if not -f $name; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
7
|
return read_file($name); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 set_dumps_folder($folder_name) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Set dumps root folder to $folder_name. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub set_dumps_folder { |
92
|
0
|
|
|
0
|
1
|
|
my $folder_name = shift; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
croak 'pass folder name' if not defined $folder_name; |
95
|
0
|
0
|
|
|
|
|
croak 'folder not found' if not -d $folder_name; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$dumps_folder = $folder_name; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Test::Environment L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Jozef Kutej - Ejozef@kutej.netE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|