[SCM] UNNAMED PROJECT branch, master, updated. 0.30-36-ge9706d8

Niels Thykier nthykier-guest at alioth.debian.org
Mon Jul 5 11:06:49 UTC 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "UNNAMED PROJECT".

The branch, master has been updated
       via  e9706d86cd90eb12dfb126be605fb594ba492415 (commit)
      from  22825ac5128c2990ba900ee7d29a097a64db0cc7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e9706d86cd90eb12dfb126be605fb594ba492415
Author: Niels Thykier <niels at thykier.net>
Date:   Mon Jul 5 13:06:00 2010 +0200

    Added documentation for the new modules and fixed two minor issues.

-----------------------------------------------------------------------

Summary of changes:
 Java.pm            |   34 ++++++++++++++++
 Manifest.pm        |  102 ++++++++++++++++++++++++++++++++++++++++++++++++
 ManifestSection.pm |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 245 insertions(+), 1 deletions(-)

diff --git a/Java.pm b/Java.pm
index 9f201e8..a77eccb 100644
--- a/Java.pm
+++ b/Java.pm
@@ -62,6 +62,35 @@ not required to be files) and should not be used on a directory.
 
 Furthermore all entries must be given with absolute path.
 
+=item parse_manifest_fd($fd, $filename)
+
+Parses a manifest from B<$fd>, which must be a readable filehandle,
+and returns a
+L<Debian::Javahelper::Manifest|Debian::Javahelper::Manifest>.
+
+B<$filename> is only used to report parsing errors and should be
+something that identifies the source of B<$fd>.
+
+=item write_manifest_fd($manifest, $fd, $filename)
+
+Writes B<$manifest> to the writable filehandle B<$fd>. B<$manifest>
+must be a
+L<Debian::Javahelper::Manifest|Debian::Javahelper::Manifest>.
+
+B<$filename> is only used to report errors and should be something
+that identifies B<$fd>.
+
+=item write_manifest_section_fd($section, $fd, $filename)
+
+Writes B<$section> to the writable filehandle B<$fd>. B<$section>
+must be a
+L<Debian::Javahelper::ManifestSection|Debian::Javahelper::ManifestSection>.
+
+B<$filename> is only used to report errors and should be something
+that identifies B<$fd>.
+
+NB: Helper - Not exported.
+
 =item slurp_file($file)
 
 Reads all lines in B<$file> and returns them as a list.
@@ -210,6 +239,11 @@ sub write_manifest_fd{
 1;
 __END__
 
+=head1 SEE ALSO
+
+L<Debian::Javahelper::Manifest(3)>
+L<Debian::Javahelper::ManifestSection(3)>
+
 =head1 AUTHOR
 
 Niels Thykier <niels at thykier.net>
diff --git a/Manifest.pm b/Manifest.pm
index 8eb4bb7..29ece66 100644
--- a/Manifest.pm
+++ b/Manifest.pm
@@ -1,5 +1,11 @@
 package Debian::Javahelper::Manifest;
 
+=head1 NAME
+
+Debian::Javahelper::Manifest - Javahelper representation of a Jar Manifest
+
+=cut
+
 use strict;
 use warnings;
 
@@ -8,9 +14,86 @@ use base qw(Exporter);
 # pass it on to others.
 our @EXPORT = qw(MAIN_SECTION);
 
+=head1 SYNOPSIS
+
+ use Debian::Javahelper::Java;
+ 
+ my $manifest = ...;
+ my $main_sec = $manifest->get_section(MAIN_SECTION);
+ # Create if it does not exist.
+ my $file_sec = $manifest->get_section("java/lang/Object.class", 1);
+
+=head1 DESCRIPTION
+
+This module is used to represent a Java Manifest.
+
+=head2 Constants
+
+=over 4
+
+=item MAIN_SECTION
+
+A constant denoting the main section of the manifest.
+
+Exported by default.
+
+=back
+
+=head2 Methods
+
+=over 4
+
+=item Debian::Javahelper::Manifest->new()
+
+Creates a new manifest. It will only contain the main section with the
+Manifest-Version attribute.
+
+=item $manifest->get_section($name[, $create])
+
+Returns the section denoted by B<$name>. If this section does not
+exist, then it will either return B<undef> or (if B<$create> is a
+truth-value) create a new empty section with that name.
+
+Use the MAIN_SECTION constant to access the main section of the
+manifest.
+
+=item $manifest->get_sections()
+
+Returns a list of all sections in B<$manifest>. The main section will
+always be the first in the list, but the remaining sections can come
+in any order (and this order can change in later invocations).
+
+Modifying the list will not change which sections are present in
+B<$manifest>, but modifying a section in this list will also update
+the section in the manifest.
+
+=item $manifest->merge($other)
+
+Merge all entries in B<$other> into B<$manifest>. All sections in
+B<$other> will be added to B<$manifest> if they are not already
+present.
+
+If an attribute in a given section is only present in one of the two
+manifests, then that attribute and its value will be in B<$manifest>
+after merge returns.
+
+If the attribute in a given section is present in both manifests, then
+the value from B<$other> will be used.
+
+This can be used to make a deep copy a manifest:
+
+ my $copy = Debian::Javahelper::Manifest->new();
+ $copy->merge($orig);
+
+=back
+
+=cut
+
 sub new {
     my $type = shift;
     my $this = bless({}, $type);
+    # create the main section
+    $this->get_section(MAIN_SECTION, 1);
     return $this;
 }
 
@@ -51,3 +134,22 @@ sub merge {
 }
 
 1;
+
+=head1 SEE ALSO
+
+L<Debian::Javahelper::Java(3)> - had parse/write methods for manifests.
+L<Debian::Javahelper::ManifestSection(3)> - for how sections are handled.
+
+=head1 AUTHOR
+
+Niels Thykier <niels at thykier.net>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2010 by Niels Thykier
+
+This module is free software; you may redistribute it and/or modify
+it under the terms of GNU GPL 2.
+
+=cut
+
diff --git a/ManifestSection.pm b/ManifestSection.pm
index d2c350f..c7dda4e 100644
--- a/ManifestSection.pm
+++ b/ManifestSection.pm
@@ -1,5 +1,12 @@
 package Debian::Javahelper::ManifestSection;
 
+=head1 NAME
+
+Debian::Javahelper::ManifestSection - Javahelper representation of a section in a Jar Manifest
+
+=cut
+
+
 use strict;
 use warnings;
 use base qw(Exporter);
@@ -9,6 +16,89 @@ use constant {
     MAIN_SECTION => 'MAIN'
 };
 
+=head1 SYNOPSIS
+
+ use Debian::Javahelper::Manifest;
+ 
+ my $main_sec = $manifest->get_section(MAIN_SECTION, 1);
+ # set the Main-Class attribute
+ $main_sec->set_value('Main-Class', 'org.site.app.AppStarter');
+ # read the classpath entry - may return undef if the attribute does not exist.
+ my $cp = $main_sec->get_value('Class-Path');
+ # same as above except $cp will be '' if the attribute does not exist.
+ $cp = $main_sec->get_value('Class-Path',  1);
+ # returns a list of [$name, $value] pairs - note $name will be in the original
+ # case.
+ my @att = $main_sec->get_values();
+
+=head1 DESCRIPTION
+
+This module is used to represent a Section in a Java Manifest.
+
+=head2 Constants
+
+=over 4
+
+=item MAIN_SECTION
+
+A constant denoting the main section of the manifest.
+
+Exported by default.
+
+=back
+
+=head2 Methods
+
+=over 4
+
+=item Debian::Javahelper::ManifestSection->new($name)
+
+Creates a new section - if B<$name> is MAIN_SECTION, then it will set
+"Manifest-Version" otherwise it will set "Name" to B<$name>.
+
+Generally you should not need to use this directly! The
+L<Debian::Javahelper::Manifest|Manifest> will create sections as they
+are needed. There is no support for creating a section and then adding
+it to a manifest after wards.
+
+=item $section->set_value($attr, $value)
+
+Sets the value of B<$attr> to B<$value>. If B<$attr> did not exist in
+this section then it will be created. B<$value> may not contain
+newlines.
+
+Note: B<$attr> exists if an attribute matches B<$attr> ignoring the
+case of the two. When B<$attr> is created, the original case will be
+stored for later (for writing). Later updates to B<$attr> will not
+affect the original case.
+
+Warning: "Name" attributes cannot span over multiple lines, it will give
+an error during write if it is too long.
+
+=item $section->get_value($attr[, $empty])
+
+Returns the value of B<$attr>, long values are merged into a single
+line. B<$attr> is looked up case-insensitively.
+
+Returns B<undef> if B<$attr> is not present in the section, unless
+B<$empty> is a truth-value. In this case it will return ''.
+
+=item $section->get_values()
+
+Returns all the values in the section in a list of [$attr, $value]
+pairs. "Manifest-Version" and "Name" will appear first in this list if
+they appear in this section, the remaining attributes appears in any
+order and this order may change.
+
+Modifying the list or the pairs will I<not> affect the attributes in
+the section.
+
+Note: The B<$attr> part will be the original case of the attribute.
+
+=back
+
+=cut
+
 sub new{
     my $type = shift;
     my $name = shift;
@@ -25,6 +115,7 @@ sub set_value {
     my $this = shift;
     my $name = shift;
     my $value = shift;
+    die("Value for $name contains new-lines,") if($value =~ m/[\r]|[\n]/o);
     # Store the name with the original case for later.
     $this->{lc($name)} = [$name, $value];
     1;
@@ -54,9 +145,26 @@ sub get_values {
     while( my ($name, $val) = each(%$this)){
 	# we already got these
 	next if($name eq 'manifest-version' or $name eq 'name');
-	push(@values, $val);
+	push(@values, [$val->[0], $val->[1]]);
     }
     return @values;
 }
 
 1;
+
+=head1 SEE ALSO
+
+L<Debian::Javahelper::Manifest(3)> - for how to obtain a section.
+
+=head1 AUTHOR
+
+Niels Thykier <niels at thykier.net>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2010 by Niels Thykier
+
+This module is free software; you may redistribute it and/or modify
+it under the terms of GNU GPL 2.
+
+=cut


hooks/post-receive
-- 
UNNAMED PROJECT



More information about the pkg-java-commits mailing list