summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2007-05-23 20:50:56 +0000
committerNorbert Preining <preining@logic.at>2007-05-23 20:50:56 +0000
commit598d91543920cea47df4d65b6983fc379577e36b (patch)
tree1f30c67ee3199f539bee22ce1339d65cc0078eaa
parentd68cf35c515f7cd28c2c312697619f9998b491b4 (diff)
better TLSRC perl modules, should be quite useable by now
git-svn-id: svn://tug.org/texlive/trunk@4348 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--new-infra/TLSRC.pm137
-rw-r--r--new-infra/test.pl8
2 files changed, 100 insertions, 45 deletions
diff --git a/new-infra/TLSRC.pm b/new-infra/TLSRC.pm
index 01a1ae6e209..90dd4c5a155 100644
--- a/new-infra/TLSRC.pm
+++ b/new-infra/TLSRC.pm
@@ -8,14 +8,21 @@
package TLSRC;
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(from_file new);
-@EXPORT_OK = qw(from_file new);
-
sub new {
my $class = shift;
- my $self = {};
+ my %params = @_;
+ my $self = {
+ name => $params{'name'},
+ shortdesc => $params{'shortdesc'},
+ longdesc => $params{'longdesc'},
+ catalogue => $params{'catalogue'},
+ runpatterns => $params{'runpatterns'},
+ srcpatterns => $params{'srcpatterns'},
+ docpatterns => $params{'docpatterns'},
+ binpatterns => $params{'binpatterns'},
+ executes => $params{'executes'},
+ depends => $params{'depends'},
+ };
bless $self, $class;
return $self;
}
@@ -106,72 +113,114 @@ sub from_file {
}
}
}
- $self->{'name'} = "$name";
- $self->{'catalogue'} = $catalogue ne "" ? "$catalogue" : "$name";
- if ($shortdesc ne "") {
- $self->{'shortdesc'} = "$shortdesc";
- }
- if ($longdesc ne "") {
- $self->{'longdesc'} = "$longdesc";
- }
- if ($#srcpatterns >= 0) {
- $self->{'srcpatterns'} = [ @srcpatterns ];
- }
- if ($#runpatterns >= 0) {
- $self->{'runpatterns'} = [ @runpatterns ];
- }
- if ($#binpatterns >= 0) {
- $self->{'binpatterns'} = [ @binpatterns ];
- }
- if ($#docpatterns >= 0) {
- $self->{'docpatterns'} = [ @docpatterns ];
- }
- if ($#executes >= 0) {
- $self->{'executes'} = [ @executes ];
- }
- if ($#depends>= 0) {
- $self->{'depends'} = [ @depends ];
- }
+ $self->name("$name");
+ $self->catalogue($catalogue ne "" ? "$catalogue" : "$name");
+ $self->shortdesc("$shortdesc") if ($shortdesc ne "");
+ $self->longdesc("$longdesc") if ($longdesc ne "");
+ $self->srcpatterns(@srcpatterns) if ($#srcpatterns >= 0);
+ $self->runpatterns(@runpatterns) if ($#runpatterns >= 0);
+ $self->binpatterns(@binpatterns) if ($#binpatterns >= 0);
+ $self->docpatterns(@docpatterns) if ($#docpatterns >= 0);
+ $self->executes(@executes) if ($#executes >= 0);
+ $self->depends(@depends) if ($#depends >= 0);
}
-sub display {
+sub writeout {
my $self = shift;
- print "name $self->{'name'}\n";
- print "catalogue $self->{'catalogue'}\n";
- defined($self->{'shortdesc'}) && print "shortdesc $self->{'shortdesc'}\n";
- defined($self->{'longdesc'}) && print "longdesc $self->{'longdesc'}\n";
+ my $fd = (@_ ? $_[0] : STDOUT);
+ print $fd "name ", $self->name, "\n";
+ print $fd "catalogue $self->{'catalogue'}\n";
+ defined($self->{'shortdesc'}) && print $fd "shortdesc $self->{'shortdesc'}\n";
+ defined($self->{'longdesc'}) && print $fd "longdesc $self->{'longdesc'}\n";
if (defined($self->{'depends'})) {
foreach (@{$self->{'depends'}}) {
- print "depend $_\n";
+ print $fd "depend $_\n";
}
}
if (defined($self->{'executes'})) {
foreach (@{$self->{'executes'}}) {
- print "execute $_\n";
+ print $fd "execute $_\n";
}
}
if (defined($self->{'srcpatterns'})) {
foreach (@{$self->{'srcpatterns'}}) {
- print "srcpattern $_\n";
+ print $fd "srcpattern $_\n";
}
}
- if (defined($self->{'runatterns'})) {
+ if (defined($self->{'runpatterns'})) {
foreach (@{$self->{'runpatterns'}}) {
- print "runpattern $_\n";
+ print $fd "runpattern $_\n";
}
}
if (defined($self->{'docpatterns'})) {
foreach (@{$self->{'docpatterns'}}) {
- print "docpattern $_\n";
+ print $fd "docpattern $_\n";
}
}
if (defined($self->{'binpatterns'})) {
foreach (@{$self->{'binpatterns'}}) {
- print "binpattern $_\n";
+ print $fd "binpattern $_\n";
}
}
+ # print final empty line
+ print $fd "\n";
}
+#
+# member access functions
+#
+sub name {
+ my $self = shift;
+ if (@_) { $self->{'name'} = shift }
+ return $self->{'name'};
+}
+sub shortdesc {
+ my $self = shift;
+ if (@_) { $self->{'shortdesc'} = shift }
+ return $self->{'shortdesc'};
+}
+sub longdesc {
+ my $self = shift;
+ if (@_) { $self->{'longdesc'} = shift }
+ return $self->{'longdesc'};
+}
+sub catalogue {
+ my $self = shift;
+ if (@_) { $self->{'catalogue'} = shift }
+ return $self->{'catalogue'};
+}
+sub srcpatterns {
+ my $self = shift;
+ if (@_) { @{ $self->{'srcpatterns'} } = @_ }
+ return @{ $self->{'srcpatterns'} };
+}
+sub docpatterns {
+ my $self = shift;
+ if (@_) { @{ $self->{'docpatterns'} } = @_ }
+ return @{ $self->{'docpatterns'} };
+}
+sub binpatterns {
+ my $self = shift;
+ if (@_) { @{ $self->{'binpatterns'} } = @_ }
+ return @{ $self->{'binpatterns'} };
+}
+sub depends {
+ my $self = shift;
+ if (@_) { @{ $self->{'depends'} } = @_ }
+ return @{ $self->{'depends'} };
+}
+sub runpatterns {
+ my $self = shift;
+ if (@_) { @{ $self->{'runpatterns'} } = @_ }
+ return @{ $self->{'runpatterns'} };
+}
+sub executes {
+ my $self = shift;
+ if (@_) { @{ $self->{'executes'} } = @_ }
+ return @{ $self->{'executes'} };
+}
+
+
1;
### Local Variables:
diff --git a/new-infra/test.pl b/new-infra/test.pl
index c33c7767d0f..8a2db80660b 100644
--- a/new-infra/test.pl
+++ b/new-infra/test.pl
@@ -6,4 +6,10 @@ use TLSRC;
my $tlsrc = new TLSRC;
$tlsrc->from_file("tlsrc/foo.tlsrc");
-$tlsrc->display();
+$tlsrc->writeout();
+
+my $tl = TLSRC->new( 'name' => "foobar",
+ 'shortdesc' => "The foobar packages",
+ 'catalogue' => "foobarcatalogue",
+ 'depends' => [ 1, 2, 3 ] );
+$tl->writeout(\*STDERR);