lib/File/Atomism/Protozoa.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/Draft/Entity/Reference.pm ↑ Summary lib/Draft/Entity/Line.pm »
1 package File::Atomism::Protozoa;
2  
3 =head1 NAME
4  
5 File::Atomism::Protozoa - CAD drawing as an atomised directory
6  
7 =head1 SYNOPSIS
8  
9 A directory that contains multiple drawing entities each represented
10 by a single file.
11  
12 =head1 DESCRIPTION
13  
14 A simple file-system directory/folder that contains any number of
15 drawing objects, represented by files; and optionally, any number of
16 further drawings represented by subdirectories.
17  
18 Note that this is not completely analogous to a traditional
19 monolithic CAD file format, as blocks/symbols associated with a
20 drawing are complete drawings in their own right.
21  
22 =cut
23  
24 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 0 ▶use SGI::FAM;
Subroutine BEGIN: called CC=1 SCAR=2.6
27  
28 sub Scan
29 {
30 my $self = shift;
31 my @freshfiles;
32 my @stalefiles;
33  
34 $self->_init;
35  
36 while ($self->{_fam}->pending)
37 {
38 my $event = $self->{_fam}->next_event;
39  
40 push (@freshfiles, $event->filename)
41 if ($event->type =~ /^(create|change|exist)$/);
42  
43 push (@stalefiles, $event->filename)
44 if ($event->type eq 'delete');
45  
46 # mark for canvas erase if file changed or removed
47 $File::Atomism::EVENT->{_old}->{$self->{_path} . $event->filename} = 'TRUE'
48 if ($event->type =~ /^(change|delete)$/);
49  
50 # mark for canvas draw if file new or changed
51 $File::Atomism::EVENT->{_new}->{$self->{_path} . $event->filename} = 'TRUE'
52 if ($event->type =~ /^(create|change|exist)$/);
53 }
54  
55 =pod
56  
57 Files titled "F<DIRTYPE>" or beginning with "." or "_" are not considered part of
58 the data and are therefore ignored.
59  
60 =cut
61  
62 @stalefiles = grep (!/^(DIRTYPE$|[._])/, @stalefiles);
63 @freshfiles = grep (!/^(DIRTYPE$|[._])/, @freshfiles);
64  
65 return \@freshfiles, \@stalefiles;
66 }
67  
68 =pod
69  
70 L<SGI::FAM> (File Activation Monitor) is used to grapple the file list.
71  
72 =cut
73  
74 sub _init
75 {
76 my $self = shift;
77 unless ($self->{_fam})
78 {
79 $self->{_fam} = SGI::FAM->new;
80 $self->{_fam}->monitor ($self->{_path});
81 }
82 return $self;
83 }
84  
85 # FIXME: needs Clone(), Delete(), Journal() and Rename() methods for elements
86  
87 }
88  
89 1;
« lib/Draft/Entity/Reference.pm ↑ Summary lib/Draft/Entity/Line.pm »