Dita-GB-Standard

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

#!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/

use v5.16;
use Module::Build;

my $b = Module::Build->new
 (module_name   => 'Dita::GB::Standard',
  dist_author   => 'philiprbrenan@gmail.com',
  dist_abstract => 'The Gearhart-Brenan Dita Topic Naming Standard.',
  license       => 'perl',
  requires      =>
   {'Carp'                  => 0,
    'Data::Dump'            => 0,
    'Data::Table::Text'              => 20201029,
    'Test2::API'            => 0,
    'Test::More'            => 0,
   },

META.json  view on Meta::CPAN

         "requires" : {
            "Carp" : "0",
            "Data::Dump" : "0",
            "Data::Table::Text" : "20201029",
            "Test2::API" : "0",
            "Test::More" : "0"
         }
      }
   },
   "provides" : {
      "Dita::GB::Standard" : {
         "file" : "lib/Dita/GB/Standard.pm",
         "version" : "20201030"
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/philiprbrenan/DitaGBStandard/issues"
      },
      "license" : [

META.yml  view on Meta::CPAN

configure_requires:
  Module::Build: '0.4224'
dynamic_config: 1
generated_by: 'Module::Build version 0.4229, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Dita-GB-Standard
provides:
  Dita::GB::Standard:
    file: lib/Dita/GB/Standard.pm
    version: '20201030'
requires:
  Carp: '0'
  Data::Dump: '0'
  Data::Table::Text: '20201029'
  Test2::API: '0'
  Test::More: '0'
resources:
  bugtracker: https://github.com/philiprbrenan/DitaGBStandard/issues

lib/Dita/GB/Standard.pm  view on Meta::CPAN

#!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/
#-------------------------------------------------------------------------------
# The Gearhart-Brenan Dita Topic Naming Standard
# Philip R Brenan at gmail dot com, Appa Apps Ltd Inc., 2019
#-------------------------------------------------------------------------------
# podDocumentation
# gbBinaryStandardFileName produces different results when given the file name versus the file content - it should be the same
package Dita::GB::Standard;
our $VERSION = 20201030;
require v5.16;
use warnings FATAL => qw(all);
use strict;
use Carp qw(confess);
use Data::Dump qw(dump);
use Data::Table::Text qw(:all);
use utf8;

sub useWords{0}                                                                 #r Use word representation of md5 sum if true

lib/Dita/GB/Standard.pm  view on Meta::CPAN

might care to consider using links to implement their own file naming system on
top of the L<GBStandard> without disrupting the integrity of the L<GBStandard>.

For example: L<xref> produces B<Oxygen Project Files> which provide a virtual
hierarchical folder view of an otherwise flat folder.

`head2 Implementation

The L<GBStandard> has been implemented as a L<Perl> package at:

L<http://metacpan.org/pod/Dita::GB::Standard>

`head2 Binary vs Utf8

Files that are expected to contain data encoded with L<utf8> (eg .dita, .xml)
should use method names that start with:

 gbStandard

Files that are expected to contain binary data (eg .png, .jpg) should use
method names that start with:

lib/Dita/GB/Standard.pm  view on Meta::CPAN

management to ask: "Why do we have so many slightly different introductions"?

END

=pod

=encoding utf-8

=head1 Name

Dita::GB::Standard - The Gearhart-Brenan Dita Topic Naming Standard.

=head1 Synopsis

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> is a means of naming L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> topic files to enable global
collaboration through uncoordinated content sharing.

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> creates a human readable, deterministic file name which
depends solely on the content to be stored in that file. Such file names are
guaranteed to differ between files that contain differing content while being
identical for files that contain identical content by the use of an L<md5 sum|https://en.wikipedia.org/wiki/MD5> in
the file name.

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name looks like this:

  human_readable_part_derived_from_content + _ + md5_sum_of_content + extension

The human readable part from content is derived solely from the content of the
file by interpreting the file content as L<Unicode|https://en.wikipedia.org/wiki/Unicode> encoded as L<utf8|https://en.wikipedia.org/wiki/UTF-8>, then:

 - replacing instances of xml tags with underscores

 - replacing all characters other than a-z,A-Z,0-9 with underscores

 - replacing runs of underscores with a single underscore

 - removing any leading or trailing underscores

 - truncating the component if it extends beyond $nameFromStringMaximumLength characters.

The original file name for the content is not considered as part of the content
of the file and so plays no part in choosing the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name for that
content.

If the file contains a B<title> tag then only the content of the B<title> tag
is processed as described above to obtain the human readable component of the
file name. If any of the following L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> tags are found in a source file
which also contains a B<title> tag then the following codes are prefixed to
this file name as well:

  Code      Tag
  bm_       bookmap

lib/Dita/GB/Standard.pm  view on Meta::CPAN

The file extension component is obtained from:
L<https://en.wikipedia.org/wiki/List_of_filename_extensions>

Thus if a B<dita> file has content:

 <concept>
   <title>abc 𝝰𝝱𝝲</title>
   <conbody/>
 </concept>

then the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name for the file is:

  c_abc_8551cffdb92932637d952e04447783c8.dita

If the option to present the L<md5 sum|https://en.wikipedia.org/wiki/MD5> as five letter English words is chosen
then the standardized name for this content becomes:

  c_abc_Plume_VApoR_CaPER_eqUAl_qUAIL_saInT_mEdia_Irony.dita

=head2 Benefits

The file names generated by the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> can be exploited in numerous ways
to simplify the creation, conversion, management and sharing of large
repositories of documents written to the L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> standard:

=head3 Parallel Processing

Complex long running document transformations can be speeded up by running the
transformations in parallel.

The file name generated by the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> is unique when computed by
competing parallel processes so files that have the same name have the same
content and can be safely overwritten by another process without attempting to
coordinate names between processes.  Likewise files that have different names
are guarenteed to have different content and so can be written out without
checking for an existing file of that name.

Alternative systems relying on coordination between the parallel processes to
choose names to avoid collisions and reuse identical content perform ever more
badly as the number of files increases because there are ever more files to
check for matching content and names.  Coordination between parallel processes
stops the processes from running fully in parallel. Conversely, eliminating the
need for coordination between parallel processes allows each process to run
more fully in parallel.

As a consequence, the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> enables parallel L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> conversions to
scale effectively.

=head3 File Flattening

Files are automatically flattened by the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> as files with the same
content have the same name and so can safely share one global folder without
fear of name collisions or having multiple names for identical content.

=head3 Testing

The name of each file reflects only its content making it easier to write tests
for software build around the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>: it is no longer necessary to test
that the content of the file is as expected when it is sufficent just to test
the base name of the file.

One could, of course, compute the L<md5 sum|https://en.wikipedia.org/wiki/MD5> of the file easily during testing
but: the fact that one is computing such a sum at all shows just how useful
such a sum is, which implies that it should be the one and only piece of meta
data encoded in the file name.  All othermeta data should reside within the
file rather then being encoded in the file name so that said meta data is not
destroyed by renaming the file.

=head3 Mixed Multiple Conversions

When converting documents to L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> it is a standard practice to perform the
conversion in batches by source document type, perhaps B<html> files first, then
B<docbook> files, then L<word|https://en.wikipedia.org/wiki/Doc_(computing)> files. Thus leaves the problem of merging the
results into one corpus after each individual conversion.  The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>
resolves this problem by guaranteeing the uniqueness of the converted
files allowing them to be merged into one results folder without collisions.

=head3 No Relative Paths in References

If all the topic files share one global folder there is no need for complicated
path expressions in references such as:

  <image href="../../../image{200B}files/size{200B}large/aaa.png"/>

Extended path names that are repeated across many references are, in effect, a
form of boiler plate which can be avoided by applying this standard.

=head3 Relocating Dita References After Folder Restructuring

In the ideal implementation all files named with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> occupy one
global folder.  In circumstances where this is not possible, such files can
easily be moved into sub folders without fear of collisions, although, any Dita
references between such files might have to be updated.  This update is easily
performed because only the path component has to be updated and the value of
the new path can easily be found by searching for the base component of the
topic file name using a utility such as L<find|https://en.wikipedia.org/wiki/Find_(Unix)>.  For a more efficient method,
see L<Data::Edit::Xml::Xref>.

=head3 Similar Files Tend To Appear Close Together In Directory Listings.

Imagine the user has several files in different folders all starting:

  <title>License Agreement</title>

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> computes the human readable component of the name in a
consistent way using only the contents of each file.  Once the name has been
standardized, all these files can be placed in B<one> folder to get a directory
listing like:

  license_agreement_a6e3...
  license_agreement_b532...
  license_agreement_c65d...

This grouping signals that these files are potentially similar to each other
and thus might be better merged into one shareable file.

As the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> is applied to ever more such files, ever more such matches
occur.

=head3 Copying And Moving Files For Global Interoperability

Users can copy files named using the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> around from folder to folder
without fear of collisions or duplication obviating the need for the time
consuming checks and reportage otherwise required before performing such
actions.  The meta data in the L<Companion File> can also be copied in a similar
fearless manner.

If two users wish to share content: their files named using the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>
can be incorporated directly into the other user's file system without fear of
collisions or duplicating content thus promoting global content sharing and
collaboration of L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> content.

=head3 Guidization For Content Management Systems

Self constructed Content Management Systems using BitBucket, GitHub or Gitlab
that rely on guidization to differentiate files placed in these repositories
benefit immensely: the L<guid|https://en.wikipedia.org/wiki/Universally_unique_identifier> to use can be easily derived from the L<md5 sum|https://en.wikipedia.org/wiki/MD5> sum
in the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name.

=head3 No need for authors to coordinate topic file names

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> is relevant to the administration of a production document
corpus. A production corpus being a corpus of documents that is B<evolving>
over time under the control of an administrator.

If an author is developing a document from scratch, in splendid isolation,
then, initially, the author might well wish to use topic file names of their
own choice to contain their topics as this will speed their efforts.

For example, it is not uncommon for an author to create a file called:

  introduction.xml

to hold the introduction to the new document they are writing.

At some point the system administrator will wish to incorporate the topic files
comprising the new document produced by the author into the production corpus.

The chance that any of the file names that the author has chosen will conflict
with the existing names in the production corpus as generated by the
L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> is negligible. It is thus safe for the administrator to copy the
author's topic files directly into the production corpus without renaming any
of them.  Sooner or later, however, the administrator might wish to run an
automated scan of the entire production corpus to rename such recent additions
to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>, to update all the references between these files that
would otherwise be invalidated by such changes and thereby to clear the
production corpus to make it ready to receive other new documents whose topic
file names, being chosen by humans, would otherwise very likely conflict with
existing topic file names already in the production corpus.

Thus clearing the production corpus by applying the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> obviates the
need for authors to coordinate the names of the files that they choose for
their topics with those choosen by other authors allowing each author to
proceed efficiently in isolated parallelism, spending more time writing and
less time in meetings with other authors discussing their latest file naming
strategy.

=head3 Using Dita Tags To Describe Content

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> encourages L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> users to use meta data tags to describe
their documents so that content can be found by searching with L<grep|https://en.wikipedia.org/wiki/Grep> rather
than encoding file meta data in file names then searching for the required file
using L<find|https://en.wikipedia.org/wiki/Find_(Unix)>.  Such file names quickly become very long and unmanageable: on
the one hand they need spaces in them to make them readable, but on the other
hand, the spaces make such files difficult to cut and paste or use from the
L<command line|https://en.wikipedia.org/wiki/Command-line_interface>.

=head3 Cut And Paste

As there are no spaces in the files names created using the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> such
file names can be selected by a mouse double click and thus easily copied and
pasted into other documents.

Conversely, one has to use cut and paste to manipulate such file names making
it impossible to mistype such file names in other documents.

=head3 CSV files

Files named using the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> can be safely included in B<.csv> files
because they have no spaces in them!

=head3 Automatic File Versioning

Files named to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> File names change when their content changes.
So if the content of a file changes its name must change as well. Thus an
attempt to present an out-of-date version of a file produces a file name that
cannot be found.

=head3 Enhanced Command Line Processing

As file names named with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> do not have spaces in them (such as
L<zero width space|https://en.wikipedia.org/wiki/Zero-width_space>) they work well on the L<command line|https://en.wikipedia.org/wiki/Command-line_interface> and with the many
L<command line|https://en.wikipedia.org/wiki/Command-line_interface> tools that are used to manipulate such files enhancing the
productivity leverage that L<command line|https://en.wikipedia.org/wiki/Command-line_interface> has always had versus L<graphical user interface|https://en.wikipedia.org/wiki/Graphical_user_interface>
processing.

=head3 Locating Files by Their Original Names Or Other Meta-Data

Each file produced by the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> can have a L<Companion File> of the same
name but without an extension.  The L<Companion File> contains meta-data about the
file such as its original location etc. which can be searched by L<grep|https://en.wikipedia.org/wiki/Grep> or
similar.

To find such a file use L<grep|https://en.wikipedia.org/wiki/Grep> to find the L<Companion File> containing the
searched for content, paste that file name into the L<command line|https://en.wikipedia.org/wiki/Command-line_interface> after
entering any command such as B<ll> and then press B<.> followed by the L<tab|https://en.wikipedia.org/wiki/Tab_key>
key to have the L<shell|https://en.wikipedia.org/wiki/Shell_(computing)> expand it to locate the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file that
corresponds to the located L<Companion File>.  For example:

  \\grep -r 'SR-dashboard-ds.png'

  png_f940c7db293fe377e7d49c4e0c654cb2:  source => "/home/phil/r/pureStorage/docBook/download/OE_User_Guide/SRRBeta/images/screenshots/dashboard/SR-dashboard-ds.png",

  ls png_f940c7db293fe377e7d49c4e0c654cb2.png

=head3 Use with AWS Simple Storage Service

Viewing files held in L<S3|https://s3.console.aws.amazon.com/s3/home> is made much easier if they are all in one flat
folder with uniqwue base names as there is no folder structure to navigate over
a nework.  Simply type the start of the B<G> part, the Human Readdable
Component, and press enter to see the possible candidates.

=head2 Companion File

Each file named using the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> may be accompanied by a
L<Companion File> that contains meta data describing the file, said data
formatted as a L<Perl|http://www.perl.org/> data structure.

The name of the L<Companion File> is obtained by removing the extension from the
file named using the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

As the content of the companion files is in plain text, such text is easy to
search using L<grep|https://en.wikipedia.org/wiki/Grep> or other textual search tools.

A common use of the companion file is to record the orginal file name and
author of the content in question:

  {source=>q(C:/my documents/dita files/content.dita),
   author=>q(A. N. Mouse),
  }

=head2 Alternate File Names

Most operating systems allow the use of links to supply alternate names for a
file. Consequently, users who wish to impose a different file naming scheme
might care to consider using links to implement their own file naming system on
top of the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> without disrupting the integrity of the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

For example: L<Xref|https://metacpan.org/pod/Data::Edit::Xml::Xref> produces B<Oxygen Project Files> which provide a virtual
hierarchical folder view of an otherwise flat folder.

=head2 Implementation

The L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> has been implemented as a L<Perl|http://www.perl.org/> package at:

L<http://metacpan.org/pod/Dita::GB::Standard>

=head2 Binary vs Utf8

Files that are expected to contain data encoded with L<utf8|https://en.wikipedia.org/wiki/UTF-8> (eg .dita, .xml)
should use method names that start with:

 gbStandard

Files that are expected to contain binary data (eg .png, .jpg) should use
method names that start with:

lib/Dita/GB/Standard.pm  view on Meta::CPAN

Version 20190901.


The following sections describe the methods in each functional area of this
module.  For an alphabetic listing of all methods by name see L<Index|/Index>.



=head1 Make and manage utf8 files

Make and manage files that conform to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> and are coded in utf8.

=head2 gbStandardFileName($$%)

Return the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name given the content and extension of a proposed file.

     Parameter   Description
  1  $content    Content
  2  $extension  Extension
  3  %options    Various ingenious options designed by Micaela

B<Example:>


  if (1) {

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    <title>abc 𝝰𝝱𝝲</title>
    <conbody/>
  </concept>
  END
     }
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardFileName)


=head2 gbStandardCompanionFileName($)

Return the name of the L<Companion File> given a file whose name complies with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

     Parameter  Description
  1  $file      L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name

B<Example:>


  ok 𝗴𝗯𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝗖𝗼𝗺𝗽𝗮𝗻𝗶𝗼𝗻𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲(q(a/b.c)) eq q(a/b);


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardCompanionFileName)


=head2 gbStandardCompanionFileContent($)

Return the content of the L<Companion File> given a file whose name complies with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

     Parameter  Description
  1  $file      L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name

B<Example:>


  if (1) {
    my $s = qq(\0abc\1);
    my $S = q(Hello World);
    my $d = temporaryFolder;
    my $D = temporaryFolder;
    clearFolder($_, 10) for $d, $D;

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbBinaryStandardDelete($F);                                                   # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardCompanionFileContent)


=head2 gbStandardCreateFile($$$%)

Create a file in the specified B<$Folder> whose name is the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name for the specified B<$content> and return the file name,  A L<Companion File> can, optionally, be  created with the specified B<...

     Parameter   Description
  1  $Folder     Target folder or a file in that folder
  2  $content    Content of the file
  3  $extension  File extension
  4  %options    Options.

B<Example:>


lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbStandardDelete($F);                                                         # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardCreateFile)


=head2 gbStandardRename($%)

Check whether a file needs to be renamed to match the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>. Return the correct name for the file or  B<undef> if the name is already correct.

     Parameter  Description
  1  $file      File to check
  2  %options   Options

B<Example:>


  if (1) {
    my $s = q(abc 𝝰𝝱𝝲);

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbStandardDelete($F);                                                         # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardRename)


=head2 gbStandardCopyFile($%)

Copy a file to the specified B<$target> folder renaming it to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.  If no B<$Target> folder is specified then rename the file in its current folder so that it does comply with the L<GB Standar...

     Parameter  Description
  1  $source    Source file
  2  %options   Options

B<Example:>


  if (1) {
    my $s = q(abc 𝝰𝝱𝝲);

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbStandardDelete($F);                                                         # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardCopyFile)


=head2 gbStandardDelete($)

Delete a file and its companion file if there is one.

     Parameter  Description
  1  $file      File to delete

B<Example:>

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    𝗴𝗯𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝗗𝗲𝗹𝗲𝘁𝗲($F);                                                         # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbStandardDelete)


=head1 Make and manage binary files

Make and manage files that conform to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> and are in plain binary.

=head2 gbBinaryStandardFileName($$)

Return the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name given the content and extension of a proposed file.

     Parameter   Description
  1  $content    Content
  2  $extension  Extension

B<Example:>


  if (1) {
    if (useWords)
     {ok 𝗴𝗯𝗕𝗶𝗻𝗮𝗿𝘆𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲(qq(\0abc\1), q(png)) eq q(png_thInk_BUSHy_dRYER_spaCE_KNOwN_lepeR_SeNse_MaJor.png);
     }
    else
     {ok 𝗴𝗯𝗕𝗶𝗻𝗮𝗿𝘆𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲(qq(\0abc\1), q(png)) eq q(png_2786f1147a331ec6ebf60c1ba636a458.png);
     }
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardFileName)


=head2 gbBinaryStandardCompanionFileName($)

Return the name of the companion file given a file whose name complies with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

     Parameter  Description
  1  $file      L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name

B<Example:>


  ok 𝗴𝗯𝗕𝗶𝗻𝗮𝗿𝘆𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝗖𝗼𝗺𝗽𝗮𝗻𝗶𝗼𝗻𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲(q(a/b.c)) eq q(a/b);


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardCompanionFileName)


=head2 gbBinaryStandardCompanionFileContent($)

Return the content of the L<Companion File> given a file whose name complies with the binary L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

     Parameter  Description
  1  $file      L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name

B<Example:>


  if (1) {
    my $s = qq(\0abc\1);
    my $S = q(Hello World);
    my $d = temporaryFolder;
    my $D = temporaryFolder;
    clearFolder($_, 10) for $d, $D;

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbBinaryStandardDelete($F);                                                   # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardCompanionFileContent)


=head2 gbBinaryStandardCreateFile($$$$)

Create a file in the specified B<$Folder> whose name is the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name for the specified B<$content> and return the file name,  A L<Companion File> can, optionally, be  created with the specified B<...

     Parameter          Description
  1  $Folder            Target folder or a file in that folder
  2  $content           Content of the file
  3  $extension         File extension
  4  $companionContent  Contents of the companion file.

B<Example:>


lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbBinaryStandardDelete($F);                                                   # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardCreateFile)


=head2 gbBinaryStandardRename($)

Check whether a file needs to be renamed to match the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>. Return the correct name for the file or  B<undef> if the name is already correct.

     Parameter  Description
  1  $file      File to check

B<Example:>


  if (1) {
    my $s = qq(\0abc\1);
    my $S = q(Hello World);

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbBinaryStandardDelete($F);                                                   # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardRename)


=head2 gbBinaryStandardCopyFile($$)

Copy a file to the specified B<$target> folder renaming it to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.  If no B<$Target> folder is specified then rename the file in its current folder so that it does comply with the L<GB Standar...

     Parameter  Description
  1  $source    Source file
  2  $target    Target folder or a file in the target folder

B<Example:>


  if (1) {
    my $s = qq(\0abc\1);

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    gbBinaryStandardDelete($F);                                                   # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardCopyFile)


=head2 gbBinaryStandardDelete($)

Delete a file and its L<Companion File> if there is one.

     Parameter  Description
  1  $file      File to delete

B<Example:>

lib/Dita/GB/Standard.pm  view on Meta::CPAN

    𝗴𝗯𝗕𝗶𝗻𝗮𝗿𝘆𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱𝗗𝗲𝗹𝗲𝘁𝗲($F);                                                   # Delete file and its companion file
    ok !-e $F;
    ok !-e $C;

    clearFolder($_, 10) for $d, $D;
   }


This method can be imported via:

  use Dita::GB::Standard qw(gbBinaryStandardDelete)



=head1 Index


1 L<gbBinaryStandardCompanionFileContent|/gbBinaryStandardCompanionFileContent> - Return the content of the L<Companion File> given a file whose name complies with the binary L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

2 L<gbBinaryStandardCompanionFileName|/gbBinaryStandardCompanionFileName> - Return the name of the companion file given a file whose name complies with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

3 L<gbBinaryStandardCopyFile|/gbBinaryStandardCopyFile> - Copy a file to the specified B<$target> folder renaming it to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

4 L<gbBinaryStandardCreateFile|/gbBinaryStandardCreateFile> - Create a file in the specified B<$Folder> whose name is the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name for the specified B<$content> and return the file name,  A L<Comp...

5 L<gbBinaryStandardDelete|/gbBinaryStandardDelete> - Delete a file and its L<Companion File> if there is one.

6 L<gbBinaryStandardFileName|/gbBinaryStandardFileName> - Return the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name given the content and extension of a proposed file.

7 L<gbBinaryStandardRename|/gbBinaryStandardRename> - Check whether a file needs to be renamed to match the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

8 L<gbStandardCompanionFileContent|/gbStandardCompanionFileContent> - Return the content of the L<Companion File> given a file whose name complies with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

9 L<gbStandardCompanionFileName|/gbStandardCompanionFileName> - Return the name of the L<Companion File> given a file whose name complies with the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

10 L<gbStandardCopyFile|/gbStandardCopyFile> - Copy a file to the specified B<$target> folder renaming it to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.

11 L<gbStandardCreateFile|/gbStandardCreateFile> - Create a file in the specified B<$Folder> whose name is the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> name for the specified B<$content> and return the file name,  A L<Companion File>...

12 L<gbStandardDelete|/gbStandardDelete> - Delete a file and its companion file if there is one.

13 L<gbStandardFileName|/gbStandardFileName> - Return the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard> file name given the content and extension of a proposed file.

14 L<gbStandardRename|/gbStandardRename> - Check whether a file needs to be renamed to match the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.



=head1 Exports

All of the following methods can be imported via:

  use Dita::GB::Standard qw(:all);

Or individually via:

  use Dita::GB::Standard qw(<method>);



1 L<gbBinaryStandardCompanionFileContent|/gbBinaryStandardCompanionFileContent>

2 L<gbBinaryStandardCompanionFileName|/gbBinaryStandardCompanionFileName>

3 L<gbBinaryStandardCopyFile|/gbBinaryStandardCopyFile>

4 L<gbBinaryStandardCreateFile|/gbBinaryStandardCreateFile>

lib/Dita/GB/Standard.pm  view on Meta::CPAN


13 L<gbStandardFileName|/gbStandardFileName>

14 L<gbStandardRename|/gbStandardRename>

=head1 Installation

This module is written in 100% Pure Perl and, thus, it is easy to read,
comprehend, use, modify and install via B<cpan>:

  sudo cpan install Dita::GB::Standard

=head1 Author

L<philiprbrenan@gmail.com|mailto:philiprbrenan@gmail.com>

L<http://www.appaapps.com|http://www.appaapps.com>

=head1 Copyright

Copyright (c) 2016-2019 Philip R Brenan.

lib/Dita/GB/Standard.pm  view on Meta::CPAN

use strict;
use Data::Table::Text qw(:all);

makeDieConfess;

if ($^O !~ m(bsd|linux)i)
 {plan skip_all => 'Not supported';
 }

Test::More->builder->output("/dev/null")                                        # Show only errors during testing
  if ((caller(1))[0]//'Dita::GB::Standard') eq "Dita::GB::Standard";

is_deeply [hex4ToBits(q(0001))],  [0,0,0,0,0,1];
is_deeply [hex4ToBits(q(c001))],  [1,1,0,0,0,1];
is_deeply [hex4ToBits(q(c002))],  [1,1,0,0,0,2];
is_deeply [hex4ToBits(q(d010))],  [1,1,0,1,0,16];
is_deeply [hex4ToBits(q(e010))],  [1,1,1,0,0,16];
is_deeply [hex4ToBits(q(f011))],  [1,1,1,1,0,17];
is_deeply [hex4ToBits(q(8010))],  [1,0,0,0,0,16];
is_deeply [hex4ToBits(q(4011))],  [0,1,0,0,0,17];

test.pl  view on Meta::CPAN

#!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/ -I//home/phil/perl/cpan/DitaGBStandard/lib/
#-------------------------------------------------------------------------------
# Test Dita::GB::Standard
# Philip R Brenan at gmail dot com, Appa Apps Ltd, 2019
#-------------------------------------------------------------------------------

use warnings FATAL => qw(all);
use strict;
use Dita::GB::Standard;

Dita::GB::Standard->test();



( run in 0.337 second using v1.01-cache-2.11-cpan-a838e43af63 )