line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AlignDB::SQL::Library; |
2
|
4
|
|
|
4
|
|
69761
|
use Moose; |
|
4
|
|
|
|
|
1509597
|
|
|
4
|
|
|
|
|
38
|
|
3
|
4
|
|
|
4
|
|
25660
|
use AlignDB::SQL; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
3288
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has 'lib' => ( is => 'rw', isa => 'Str', required => 1 ); |
6
|
|
|
|
|
|
|
has 'contents' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub BUILD { |
9
|
3
|
|
|
3
|
0
|
3184
|
my $self = shift; |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
|
|
12
|
my @lib_arr = (); |
12
|
3
|
100
|
|
|
|
128
|
if ( -e $self->lib ) { |
13
|
2
|
50
|
|
|
|
90
|
open my $lib_fh, '<', $self->lib |
14
|
|
|
|
|
|
|
or die "Cannot open file: $!"; |
15
|
2
|
|
|
|
|
53
|
@lib_arr = <$lib_fh>; |
16
|
2
|
|
|
|
|
36
|
close $lib_fh; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
9
|
my $curr_name = ''; |
20
|
3
|
|
|
|
|
12
|
foreach (@lib_arr) { |
21
|
57
|
100
|
|
|
|
185
|
next if m{^\s*$}; |
22
|
54
|
50
|
|
|
|
133
|
next if m{^\s*#}; |
23
|
54
|
50
|
|
|
|
126
|
next if m{^\s*//}; |
24
|
54
|
100
|
|
|
|
118
|
if (m{^\[([^\]]+)\]}) { |
25
|
3
|
|
|
|
|
11
|
$curr_name = $1; |
26
|
3
|
|
|
|
|
5
|
next; |
27
|
|
|
|
|
|
|
} |
28
|
51
|
50
|
|
|
|
101
|
if ($curr_name) { |
29
|
51
|
|
|
|
|
105
|
$self->{contents}->{$curr_name} .= $_; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
18
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub retr { |
37
|
9
|
|
|
9
|
0
|
974
|
my $self = shift; |
38
|
9
|
|
|
|
|
13
|
my $entity_name = shift; |
39
|
9
|
|
|
|
|
42
|
return $self->{contents}->{$entity_name}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub retrieve { |
43
|
2
|
|
|
2
|
0
|
11
|
my $self = shift; |
44
|
2
|
|
|
|
|
5
|
my $entity_name = shift; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
9
|
my $thaw_sql = AlignDB::SQL->thaw( $self->retr($entity_name) ); |
47
|
2
|
|
|
|
|
32056
|
return $thaw_sql; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub set { |
51
|
4
|
|
|
4
|
0
|
10
|
my $self = shift; |
52
|
4
|
|
|
|
|
6
|
my $entity_name = shift; |
53
|
4
|
|
|
|
|
6
|
my $entity = shift; |
54
|
|
|
|
|
|
|
|
55
|
4
|
100
|
|
|
|
13
|
if ( ref $entity eq 'AlignDB::SQL' ) { |
56
|
2
|
|
|
|
|
8
|
$entity->_sql( $entity->as_sql ); |
57
|
2
|
|
|
|
|
10
|
$self->{contents}->{$entity_name} = $entity->freeze; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
2
|
|
|
|
|
4
|
$self->{contents}->{$entity_name} = $entity; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
15188
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub drop { |
67
|
2
|
|
|
2
|
0
|
99
|
my $self = shift; |
68
|
2
|
|
|
|
|
4
|
my $entity_name = shift; |
69
|
2
|
|
|
|
|
6
|
delete $self->{contents}->{$entity_name}; |
70
|
2
|
|
|
|
|
4
|
return $self; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub elements { |
74
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
75
|
1
|
|
|
|
|
1
|
return sort keys %{ $self->{contents} }; |
|
1
|
|
|
|
|
12
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub dump { |
79
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
80
|
2
|
|
|
|
|
3
|
my $output = ''; |
81
|
2
|
|
|
|
|
5
|
foreach ( sort keys %{ $self->{contents} } ) { |
|
2
|
|
|
|
|
13
|
|
82
|
3
|
|
|
|
|
20
|
$output .= sprintf "[%s]\n%s\n", $_, $self->{contents}->{$_}; |
83
|
|
|
|
|
|
|
} |
84
|
2
|
|
|
|
|
13
|
return $output; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub write { |
88
|
1
|
|
|
1
|
0
|
7420
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
1
|
50
|
|
|
|
42
|
open my $lib_fh, '>', $self->lib |
91
|
|
|
|
|
|
|
or die "Cannot open file: $!"; |
92
|
1
|
|
|
|
|
3
|
print {$lib_fh} $self->dump; |
|
1
|
|
|
|
|
6
|
|
93
|
1
|
|
|
|
|
81
|
close $lib_fh; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
6
|
return $self; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |