File Coverage

lib/Draft/Entity/Reference.pm
Criterion Covered Total %
statement 27 30 90.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 35 40 87.5


line stmt bran cond sub pod time code
1             package Draft::Entity::Reference;
2              
3             =head1 NAME
4              
5             Draft::Entity::Reference - CAD reference drawing-object
6              
7             =head1 SYNOPSIS
8              
9             Points to one or more L objects and places them in
10             space.
11              
12             =cut
13              
14 1     1   6 use strict;
  1         1  
  1         28  
15 1     1   5 use warnings;
  1         2  
  1         22  
16 1     1   5 use Draft::Drawing;
  1         2  
  1         17  
17              
18             # FIXME shouldn't depend on Tk
19 1     1   483 use Draft::TkGui::Entity::Reference;
  1         2  
  1         30  
20 1     1   6 use vars qw /@ISA/;
  1         3  
  1         388  
21             @ISA = qw /Draft::TkGui::Entity::Reference/;
22              
23             =pod
24              
25             =head1 DESCRIPTION
26              
27             A reference has some interesting attributes; coordinates for placing
28             it in space, paths to L objects and parts of them to
29             ignore.
30              
31             =head1 USAGE
32              
33             Processing the data in a Reference object causes referenced drawings
34             to be read if necessary:
35              
36             $self->Process;
37              
38             =cut
39              
40             sub Process
41             {
42 1     1 0 7 my $self = shift;
43              
44 1         2 my $dir = $self->{_path};
45 1         7 $dir =~ s/[^\/]*$//;
46              
47 1         2 for my $path (@{$self->{location}})
  1         2  
48             {
49 1         4 $path = _clean_path ($dir . $path);
50 1 50       22 $Draft::WORLD->{$path} = Draft::Drawing->new ($path)
51             unless exists $Draft::WORLD->{$path};
52 1         6 $Draft::WORLD->{$path}->Read;
53             }
54              
55 0         0 @{$self->{ignore}} = map _clean_path ($dir . $_), @{$self->{ignore}};
  0         0  
  0         0  
56             }
57              
58             sub _clean_path
59             {
60 1     1   2 my $path = shift;
61 1         8 while ($path =~ /[^\/]\/\.\.\//) { $path =~ s/[^\/]+\/\.\.\/// }
  1         7  
62 1         2 return $path;
63             }
64              
65             1;