line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::FedDB::Base; |
2
|
1
|
|
|
1
|
|
563
|
use Class::Std; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Class::Std::Utils; |
4
|
|
|
|
|
|
|
use DBIx::MySperqlOO; |
5
|
|
|
|
|
|
|
use File::Spec; |
6
|
|
|
|
|
|
|
use YAML qw(DumpFile LoadFile); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use warnings; |
9
|
|
|
|
|
|
|
use strict; |
10
|
|
|
|
|
|
|
use Carp; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use version; our $VERSION = qv('0.0.1'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
my %dbh_of :ATTR(); |
16
|
|
|
|
|
|
|
my %attribute_of :ATTR( :get :set :default<''> :init_arg ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub dbh { my ( $self ) = @_; return $dbh_of{ident $self}; } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub BUILD { |
21
|
|
|
|
|
|
|
my ($self, $ident, $arg_ref) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$dbh_of{$ident} = DBIx::MySperqlOO->new( $arg_ref->{connection} ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _sum { |
29
|
|
|
|
|
|
|
my ( $self, @values ) = @_; |
30
|
|
|
|
|
|
|
my $total = 0; |
31
|
|
|
|
|
|
|
foreach my $value ( @values ) { |
32
|
|
|
|
|
|
|
$total += $value; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
return $total; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _sql_escape { |
38
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
39
|
|
|
|
|
|
|
if ($string) { $string =~ s/(['"\\])/\\$1/g; } |
40
|
|
|
|
|
|
|
return $string; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _html_to_sql { |
44
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
45
|
|
|
|
|
|
|
$string = $self->_html_unescape( $string ); |
46
|
|
|
|
|
|
|
$string = $self->_sql_escape( $string ); |
47
|
|
|
|
|
|
|
return $string; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _html_escape { |
51
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
52
|
|
|
|
|
|
|
$string =~ s/'/'/g; |
53
|
|
|
|
|
|
|
$string =~ s/"/"/g; |
54
|
|
|
|
|
|
|
return $string; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _html_encode { |
58
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
59
|
|
|
|
|
|
|
$string =~ s/ /%20/g; |
60
|
|
|
|
|
|
|
$string =~ s/'/%27/g; |
61
|
|
|
|
|
|
|
$string =~ s/\{/%7B/g; |
62
|
|
|
|
|
|
|
$string =~ s/\}/%7D/g; |
63
|
|
|
|
|
|
|
return $string; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _html_unescape { |
67
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
68
|
|
|
|
|
|
|
$string =~ s/'/'/g; |
69
|
|
|
|
|
|
|
$string =~ s/"/"/g; |
70
|
|
|
|
|
|
|
$string =~ s/%20/ /g; |
71
|
|
|
|
|
|
|
return $string; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _phone_format { |
75
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
76
|
|
|
|
|
|
|
$string =~ s/(\d{3})(\d{3})(\d{4})/($1) $2-$3/; |
77
|
|
|
|
|
|
|
return $string; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _phone_unformat { |
81
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
82
|
|
|
|
|
|
|
$string =~ s/[^\d]//g; |
83
|
|
|
|
|
|
|
return $string; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _commify { # Perl Cookbook 2.17 |
87
|
|
|
|
|
|
|
my ( $self, $string ) = @_; |
88
|
|
|
|
|
|
|
my $text = reverse $string; |
89
|
|
|
|
|
|
|
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; |
90
|
|
|
|
|
|
|
return scalar reverse $text; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
98
|
|
|
|
|
|
|
__END__ |