Apps/Database/ExtractData.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« Model/DBM.pm ↑ Summary Apps/Database/ExtractGlobals.pm »
1 package XAS::Apps::Database::ExtractData;
2  
3 our $VERSION = '0.02';
4  
5 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 use XAS::Class
7 0 ▶ version => $VERSION,
Subroutine BEGIN: called CC=1 SCAR=2.6
8 base => 'XAS::Lib::App',
9 accessors => 'table schema file'
10 0 ;
11  
12 # ----------------------------------------------------------------------
13 # Public Methods
14 # ----------------------------------------------------------------------
15  
16 sub parse_file {
17 my $self = shift;
18  
19 my $fh;
20 my $table = $self->table;
21 my $schema = $self->schema;
22  
23 open($fh, "<", $self->file);
24  
25 while (<$fh>) {
26  
27 if ($_ =~ m/^COPY $table \(/ ) {
28  
29 printf("SET search_path = %s, pg_catalog;\n", $schema);
30 print $_;
31  
32 while (<$fh>) {
33  
34 print $_;
35  
36 return if ($_ =~ m/^\\\./);
37  
38 }
39  
40 }
41  
42 }
43  
44 }
45  
46 sub main {
47 my $self = shift;
48  
49 $self->log->debug('starting main section');
50  
51 $self->parse_file();
52  
53 $self->log->debug('ending main section');
54  
55 }
56  
57 sub options {
58 my $self = shift;
59  
60 $self->{'file'} = '';
61 $self->{'table'} = '';
62 $self->{'schema'} = '';
63  
64 return {
65 'file=s' => \$self->{'file'},
66 'table=s' => \$self->{'table'},
67 'schema=s' => \$self->{'schema'},
68 };
69  
70 }
71  
72 # ----------------------------------------------------------------------
73 # Private Methods
74 # ----------------------------------------------------------------------
75  
76 1;
77  
78 __END__
« Model/DBM.pm ↑ Summary Apps/Database/ExtractGlobals.pm »