| 1 | package XML::Database::Tables; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 8 | #use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||
| 13 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||
| 14 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # This allows declaration use XML::Database::Tables ':all'; | ||||||||||||||||||||||||||||
| 17 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||
| 18 | # will save memory. | ||||||||||||||||||||||||||||
| 19 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | ) ] ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # Preloaded methods go here. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub new | ||||||||||||||||||||||||||||
| 34 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 36 | 1 | my %args = (@_); | |||||||||||||||||||||||||||
| 37 | 1 | return bless \%args, $self; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | sub tables | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
tables: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 43 | 0 | my %args = (@_); | |||||||||||||||||||||||||||
| 44 | 0 | %$self = (%$self, %args); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Carp::croak("The {Name} and/or directory properties are not set. Set them using XML::Database->new(...) method") | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | unless($self->{Database}->{Name} && $self->{Database}->{Directory}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Database"}{"Name"} and $self->{"Database"}{"Directory"}
MC/DC0%0/2
$self->{"Database"}{"Name"} and $self->{"Database"}{"Directory"}
$self->{"Database"}{"Name"}
$self->{"Database"}{"Directory"}
Truth table0%0/3
A and B
A= $self->{"Database"}{"Name"}B= $self->{"Database"}{"Directory"}
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my @files; | |||||||||||||||||||||||||||
| 50 | my $file; | ||||||||||||||||||||||||||||
| 51 | 0 | opendir(DB, "$self->{Database}->{Directory}/$self->{Database}->{Name}"); | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | while (defined ($file = readdir(DB))) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | push(@files, $file) unless $file =~ /(\.config)|(\.)|(\.\.)|(\.dtd)/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | return @files; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub create | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 0 | my %args = (@_); | |||||||||||||||||||||||||||
| 64 | 0 | %$self = (%$self, %args); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | #Carp::croak("Usage: ...->create(XML::Database->new(), [key => value])") | ||||||||||||||||||||||||||||
| 67 | #unless(ref $db && $self->{TableName}); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Carp::croak("The {Name} and/or directory properties are not set. Set them using XML::Database->new(...) method") | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | unless($self->{Database}->{Name} && $self->{Database}->{Directory}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Database"}{"Name"} and $self->{"Database"}{"Directory"}
MC/DC0%0/2
$self->{"Database"}{"Name"} and $self->{"Database"}{"Directory"}
$self->{"Database"}{"Name"}
$self->{"Database"}{"Directory"}
Truth table0%0/3
A and B
A= $self->{"Database"}{"Name"}B= $self->{"Database"}{"Directory"}
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | ## Create the directory needed by the table | ||||||||||||||||||||||||||||
| 73 | 0 | mkdir("$self->{Database}->{Directory}/$self->{Database}->{Name}/$self->{TableName}"); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | ## Create the config file(s) needed by the table | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | ## Attach a DTD to the table | ||||||||||||||||||||||||||||
| 79 | 0 | require XML::Database::DTD; | |||||||||||||||||||||||||||
| 80 | 0 | my $xmldtd = XML::Database::DTD->new(Table => $self); | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | $xmldtd->attach(DTDFile => $self->{DTDFile}) if $self->{DTDFile}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | $self->{DTDFile} = ''; ### Clear the DTDFile so that it won't attach to next table | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub drop | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
drop: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 88 | 0 | my %args = (@_); | |||||||||||||||||||||||||||
| 89 | 0 | %$self = (%$self, %args); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | #Carp::croak("Usage: ...->drop(XML::Database->new(), [key => value])") | ||||||||||||||||||||||||||||
| 92 | #unless(ref $db && $self->{tableName}); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Carp::croak("The {Name} and/or directory properties are not set. Set them using XML::Database->new(...) method") | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | unless($self->{Database}->{Name} && $self->{Database}->{Directory}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"Database"}{"Name"} and $self->{"Database"}{"Directory"}
MC/DC0%0/2
$self->{"Database"}{"Name"} and $self->{"Database"}{"Directory"}
$self->{"Database"}{"Name"}
$self->{"Database"}{"Directory"}
Truth table0%0/3
A and B
A= $self->{"Database"}{"Name"}B= $self->{"Database"}{"Directory"}
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | ## Create the directory needed by the table | ||||||||||||||||||||||||||||
| 98 | 0 | require File::Path; | |||||||||||||||||||||||||||
| 99 | 0 | ▶ | File::Path::rmtree("$self->{Database}->{Directory}/$self->{Database}->{Name}/$self->{TableName}") || | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | Carp::croak("Error deleting a table in $self->{Database}->{Directory}/$self->{Database}->{Name}/$self->{tableName}: $!"); | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | 1; | |||||||||||||||||||||||||||
| 108 | __END__ | ||||||||||||||||||||||||||||