File-Drawing
view release on metacpan or search on metacpan
lib/File/Drawing.pm view on Meta::CPAN
if ($repository) {
$repository .= '::' unless substr($repository, -2, 2) eq '::';
}
##########
# Determine the program module file and its include path
#
my $pm = number2pm($drawing_number, $repository);
my ($pm_file, $inc_path) = File::Where->where_pm( $pm );
unless($pm_file) {
$event = "# Locate error. Cannot find $pm in " . join( ' ', @INC) . "\n";
goto EVENT;
}
######
# Read the contents of the program module file contents
#
my $file_contents = File::SmartNL->fin($pm_file);
unless (defined $file_contents) {
remove($drawing_number, $repository);
$event = "# ($repository)$drawing_number read error. $!\n";
goto EVENT;
}
#####
# Force the package name to agree with program package file name
#
my $release = 0;
if($file_contents !~ /^\s*package\s*$pm\s*;/m) {
$file_contents =~ s/^\s*package.*;/package $pm;/m;
$release = 1; # Force update of revision and version
}
####
# Place to store data from the program module file
#
local ($contents, $white_tape, $pod) = ('','');
#####
# Pick up the values for the white_tape and the contents
#
if ($file_contents =~ /(.*)\n\s*__END__(.*)/s) {
$file_contents = $1;
$pod = $2;
}
if($pod) {
$pod = $1 if $pod =~ /^\s*(.*?)\s*$/s;
}
$pod = '# end of file' unless($pod);
#####
# Locate and extract drawing block
#
my $drawing_block='';
$file_contents = '' unless $file_contents;
if($file_contents =~ s|$options->{drawing_block_regex}|$options->{drawing_block_holder}|s) {
$drawing_block = $1;
}
if(!$drawing_block && $options->{retrieve_unblocked}) {
if($file_contents =~ s|(\$white_tape = # parts.*)|$options->{drawing_block_holder}|s) {
$drawing_block = $1;
}
}
unless($drawing_block) {
$self->broken($drawing_number, $repository);
$event = "# Drawing block error. Removing ($repository)$drawing_number.\n";
goto EVENT;
}
$file_contents .= "\n\n1\n" unless $file_contents =~ /1\s*$/; # 1 at end of program module
######
# Take care of variables in the contents
#
$drawing_block = '' unless $drawing_block;
$drawing_block =~ s/\Q__FILE__\E/\'$pm_file\'/g;
####
# When running under test harness, get all kinds things coming out
#
eval($drawing_block);
if($@) {
$self->broken($drawing_number, $repository);
$event = "# Contents eval error. Removing ($repository)$drawing_number.\n#\t$@";
goto EVENT;
}
my $drawing = $self->File::Drawing::new($contents, $white_tape, $pod, $file_contents, $drawing_number, $repository);
$drawing->release( clobber => 1 ) if $release;
return $drawing;
EVENT:
$event .= "\tFile::Drawing::retrieve $VERSION\n";
if($options->{warnings} ) {
warn($event);
}
elsif($options->{die}) {
die($event);
}
$event;
}
######
# Release the docuemnt.
#
sub release
{
my ($self, @options) = @_;
my $options = new Data::Startup(@options);
$options->{original} = 1;
$self->revise( $options );
}
######
# Revise the document by updating the drawing program module with
# the latest content for the drawing. If successful, returns '';
lib/File/Drawing.pm view on Meta::CPAN
or hash reference, C<\%options>, C<{@options}>.
If a subroutine will process an array reference, C<\@options>, C<[@options]>,
that subroutine will also process a hash reference, C<\%options>, C<{@options}>.
See the description for a subroutine for details and exceptions.
=head1 DESCRIPTION
The C<File::Drawing> program module uses American National Standards
for drawings as a model for storing data.
Commercial, governement and casual orgainizations
have stored information over the centuries as drawings.
Drawings probably evolved from the census that the Roman's
rulers, started back when Rome was a little
frontier town.
In other words, the practices of the drafting displines
have evolved over time and have stood the test of time.
Any deviation must be a crystal clear advantage.
Many of the practices are in place to avoid common and
costly human mistakes that obviously a computerize
drafting system will not make.
A good approach is to make the computerized data structure
optimum for computers and have the computer render the
computerized data into a form that meets the
drafting standards.
The C<File::Drawing> program module, uses
the Perl program module name as a drawing repository,
drawing number combination.
The contents of the drawing is contained in the
program module file.
The <File::Drawing> program module established methods
to retrieve contents from a program module drawing file,
create an Perl drawing object with the contents, and methods to
release and revise the contents in a program module
drawing file from a Perl drawing object.
Other popular methods for computerize date are the SQL and XML.
Perl has a wide range of program modules using these approach.
In this time in history, the Drawings are highly standardize
and even subject to Internationl standarization agreements.
The Drawing Sheet Size and Format conform to ANSI Y14.1-1975
or its successor.
The drawing has a box with zone numbers running right to left
alon the top and bottom, and zone letters running bottom to
top along the sides. There is a section inside the box,
lower right corner with the blocks for such things as the
title, drawing number, current revision, authoriztion, and
sheet number.
There is an expandable
four column table in the top right corner to record the revision
history.
The data in a drawing may be divided into two parts
as follows:
=over 4
=item contents
The contents proper is the text and graphics inside the
drawing boundaries, not including the lower right corner
blocked off area containing the title and the upper right
corner revision history.
The contents should conform to standards for contents
such as ANSI X3.5-1970, Flowchart Symbols and their
Usage in Information Processing.
=item white tape
The white tape is the drawing information that is not
the contents such as the drawing number, revision,
revision history. This is meta type data about
the contents.
The term white tape is derived from a common practice of writing
part numbers and drawing numbers on white tape and affixing the white
tape to parts and drawing media such as magnetic tape, disks, etc.
There are vendors that sell gadgets whereby you can punch in text
and it will generate tape with the text to affix to parts and drawings.
=back
The C<File::Drawing> program module provides a format for
very specific white tape data and 100% open, unspecified
contents.
The white tape data include information needed to
support rendering of the drawings for delivery to
other activities such as other commerical and
industry activities and government activities.
For example, for delivery to the US DOD, the
drawing number must meet very specific requirements.
The drawing number must
comply to DOD-STD-100C, Drawing Practices following
requirements
401.4. I<Drawing Number.> The drawing number consists of letters,
numbers or combination of letters and numbers, which may or may
not be separated by dashes. The number is assigned to a particular
drawing for identification purposes by the design activity.
402.5 I<Drawing number.> The drawing number shall not exceed 15
characters. These characters may include numbers, letter, and dashes
with the following limitations:
a. Letters "I", "O', "Q", "S", "X", and "Z" shall not be used;
however letters "S" and "Z" may be used only if they are a part of
the existing drawing numbering system. THey shall not be used in the
development of new drawing numbering systems. Letters shall be upper
case (capital letters).
b. Numbers shall be arabic numberals. Fractional, decimal and Roman
numberals shall not be used.
c. Blank spaces are not permitted.
d. Symbols such as: parentheseis, asterisks, virgule, degree, plus, minus
shall not be used, except when referencing the Government or non-governemnt
standardization document whose identification contains such symbol
e. The FSCM number, drawing format size letter, and drawing revision
( run in 1.015 second using v1.01-cache-2.11-cpan-5837b0d9d2c )