line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package DataCube::Connection::Table; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1403
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
5
|
use Storable; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
52
|
|
9
|
1
|
|
|
1
|
|
518
|
use DataCube::Table; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use DataCube::Schema; |
11
|
|
|
|
|
|
|
use DataCube::FileUtils; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
my($class,$source) = @_; |
15
|
|
|
|
|
|
|
die "DataCube::Connection::Table(new):\nplease provide a directory to the new constructor\n$!\n" |
16
|
|
|
|
|
|
|
unless -d($source); |
17
|
|
|
|
|
|
|
die "DataCube::Connection::Table(new):\nsource:\n$source\ndoes not contain a valid schema file\n$!\n" |
18
|
|
|
|
|
|
|
unless -f("$source/.schema"); |
19
|
|
|
|
|
|
|
die "DataCube::Connection::Table(new):\nsource:\n$source\ndoes not contain a valid digests file\n$!\n" |
20
|
|
|
|
|
|
|
unless -f("$source/.digests"); |
21
|
|
|
|
|
|
|
die "DataCube::Connection::Table(new):\nsource:\n$source\ndoes not contain a valid config file\n$!\n" |
22
|
|
|
|
|
|
|
unless -f("$source/.config"); |
23
|
|
|
|
|
|
|
my $self = bless { |
24
|
|
|
|
|
|
|
source => $source, |
25
|
|
|
|
|
|
|
config => Storable::retrieve("$source/.config"), |
26
|
|
|
|
|
|
|
schema => Storable::retrieve("$source/.schema"), |
27
|
|
|
|
|
|
|
digests => Storable::retrieve("$source/.digests"), |
28
|
|
|
|
|
|
|
}, ref($class) || $class; |
29
|
|
|
|
|
|
|
$self->{table} = DataCube::Table->new; |
30
|
|
|
|
|
|
|
$self->{table}->{schema} = $self->{schema}; |
31
|
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub sync { |
35
|
|
|
|
|
|
|
my($self,$dir) = @_; |
36
|
|
|
|
|
|
|
die "DataCube::Connection::Table(report):\nplease provide a directory to save reports\n$!\n" |
37
|
|
|
|
|
|
|
unless -d($dir); |
38
|
|
|
|
|
|
|
my $file_name = "$dir/.report"; |
39
|
|
|
|
|
|
|
$self->report_to_file($file_name); |
40
|
|
|
|
|
|
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub source { |
44
|
|
|
|
|
|
|
my($self) = @_; |
45
|
|
|
|
|
|
|
return $self->{source}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub schema { |
49
|
|
|
|
|
|
|
my($self) = @_; |
50
|
|
|
|
|
|
|
return $self->{schema}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub report { |
54
|
|
|
|
|
|
|
my($self,$dir) = @_; |
55
|
|
|
|
|
|
|
die "DataCube::Connection::Table(report):\nplease provide a directory to save reports\n$!\n" |
56
|
|
|
|
|
|
|
unless -d($dir); |
57
|
|
|
|
|
|
|
my $file_name = $self->schema->safe_file_name; |
58
|
|
|
|
|
|
|
$self->report_to_file($dir . '/' .$file_name . '.dat'); |
59
|
|
|
|
|
|
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub report_to_file { |
63
|
|
|
|
|
|
|
my($self,$file) = @_; |
64
|
|
|
|
|
|
|
my @report = $self->files_to_table; |
65
|
|
|
|
|
|
|
open(my $F, '>' , $file) |
66
|
|
|
|
|
|
|
or die "DataCube::Connection(report_to_file | open):\ncant open report file:\n$file\n$!\n"; |
67
|
|
|
|
|
|
|
print $F join("\n", map { join("\t",@$_) } @report); |
68
|
|
|
|
|
|
|
close $F; |
69
|
|
|
|
|
|
|
return $self; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub files_to_table { |
73
|
|
|
|
|
|
|
my($self) = @_; |
74
|
|
|
|
|
|
|
my $source = $self->source; |
75
|
|
|
|
|
|
|
my $utils = DataCube::FileUtils->new; |
76
|
|
|
|
|
|
|
my @files = grep { /^[a-f0-9]+$/i } $utils->dir($source); |
77
|
|
|
|
|
|
|
my @report = (); |
78
|
|
|
|
|
|
|
for(my $i = 0; $i < @files; ++$i){ |
79
|
|
|
|
|
|
|
my $file = $files[$i]; |
80
|
|
|
|
|
|
|
my $data = Storable::retrieve("$source/$file"); |
81
|
|
|
|
|
|
|
$self->{table}->{cube} = $data; |
82
|
|
|
|
|
|
|
my @table = $self->{table}->to_table; |
83
|
|
|
|
|
|
|
shift @table unless $i == 0; |
84
|
|
|
|
|
|
|
push @report,@table; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
@report[1..$#report] = sort { join("\t",@$a) cmp join("\t",@$b)} @report[1..$#report]; |
87
|
|
|
|
|
|
|
return @report; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub report_html { |
91
|
|
|
|
|
|
|
my($self,$dir) = @_; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
die "DataCube::Connection::Table(report_html):\nplease provide a directory to save reports\n$!\n" |
94
|
|
|
|
|
|
|
unless -d($dir); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my @table = $self->files_to_table; |
97
|
|
|
|
|
|
|
my $file_name = $self->schema->safe_file_name; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
open(my $F, '>' , $dir . '/' . $file_name.'.html') |
100
|
|
|
|
|
|
|
or die "cant open purge file:\n$dir/$file_name.html\n$!\n"; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $driver = DataCube::Cube::Style::HTML->new; |
103
|
|
|
|
|
|
|
print $F $driver->html_from_table($self->{table},@table); |
104
|
|
|
|
|
|
|
close $F; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $self; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|