Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,74 @@
# Copyrights 2013-2021 by [Mark Overmeer <mark@overmeer.net>].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
# This code is part of distribution Log-Report-Optional. Meta-POD processed
# with OODoc into POD and HTML manual-pages. See README.md
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
package Log::Report::Minimal::Domain;
use vars '$VERSION';
$VERSION = '1.07';
use warnings;
use strict;
use String::Print 'oo';
sub new(@) { my $class = shift; (bless {}, $class)->init({@_}) }
sub init($)
{ my ($self, $args) = @_;
$self->{LRMD_name} = $args->{name} or Log::Report::panic();
$self;
}
#----------------
sub name() {shift->{LRMD_name}}
sub isConfigured() {shift->{LRMD_where}}
sub configure(%)
{ my ($self, %args) = @_;
my $here = $args{where} || [caller];
if(my $s = $self->{LRMD_where})
{ my $domain = $self->name;
die "only one package can contain configuration; for $domain already in $s->[0] in file $s->[1] line $s->[2]. Now also found at $here->[1] line $here->[2]\n";
}
my $where = $self->{LRMD_where} = $here;
# documented in the super-class, the more useful man-page
my $format = $args{formatter} || 'PRINTI';
$format = {} if $format eq 'PRINTI';
if(ref $format eq 'HASH')
{ my $class = delete $format->{class} || 'String::Print';
my $method = delete $format->{method} || 'sprinti';
my $sp = $class->new(%$format);
$self->{LRMD_format} = sub { $sp->$method(@_) };
}
elsif(ref $format eq 'CODE')
{ $self->{LRMD_format} = $format;
}
else
{ error __x"illegal formatter `{name}' at {fn} line {line}"
, name => $format, fn => $where->[1], line => $where->[2];
}
$self;
}
#-------------------
sub interpolate(@)
{ my ($self, $msgid, $args) = @_;
$args->{_expand} or return $msgid;
my $f = $self->{LRMD_format} || $self->configure->{LRMD_format};
$f->($msgid, $args);
}
1;

View File

@@ -0,0 +1,88 @@
=encoding utf8
=head1 NAME
Log::Report::Minimal::Domain - administer one text-domain
=head1 SYNOPSIS
use Log::Report::Minimal::Domain;
my $domain = Log::Report::Minimal::Domain->new(name => $name);
# normal usage
use Log::Report::Optional; # or Log::Report itself
my $domain = textdomain $name; # find config
textdomain $name, %configure; # set config, only once.
=head1 DESCRIPTION
Read L<Log::Report::Domain>.
=head1 METHODS
=head2 Constructors
=over 4
=item Log::Report::Minimal::Domain-E<gt>B<new>(%options)
-Option--Default
name <required>
=over 2
=item name => STRING
=back
=back
=head2 Attributes
=over 4
=item $obj-E<gt>B<configure>(%options)
-Option--Default
where <required>
=over 2
=item where => ARRAY
Specifies the location of the configuration. It is not allowed to
configure a domain on more than one location.
=back
=item $obj-E<gt>B<isConfigured>()
=item $obj-E<gt>B<name>()
=back
=head2 Action
=over 4
=item $obj-E<gt>B<interpolate>( $msgid, [$args] )
Interpolate the keys used in C<$msgid> from the values in C<$args>.
This is handled by the formatter, by default a L<String::Print|String::Print>
instance.
=back
=head1 SEE ALSO
This module is part of Log-Report-Optional distribution version 1.07,
built on January 15, 2021. Website: F<http://perl.overmeer.net/CPAN/>
=head1 LICENSE
Copyrights 2013-2021 by [Mark Overmeer <mark@overmeer.net>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>