/usr/share/perl5/Perinci/Object.pm is in libperinci-object-perl 0.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | package Perinci::Object;
use 5.010001;
use strict;
use warnings;
our $VERSION = '0.13'; # VERSION
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(rimeta risub rivar ripkg envres riresmeta);
sub rimeta {
require Perinci::Object::Metadata;
Perinci::Object::Metadata->new(@_);
}
sub risub {
require Perinci::Object::function;
Perinci::Object::function->new(@_);
}
sub rivar {
require Perinci::Object::variable;
Perinci::Object::variable->new(@_);
}
sub ripkg {
require Perinci::Object::package;
Perinci::Object::package->new(@_);
}
sub envres {
require Perinci::Object::EnvResult;
Perinci::Object::EnvResult->new(@_);
}
sub riresmeta {
require Perinci::Object::result;
Perinci::Object::result->new(@_);
}
1;
# ABSTRACT: Object-oriented interface for Rinci metadata
__END__
=pod
=encoding UTF-8
=head1 NAME
Perinci::Object - Object-oriented interface for Rinci metadata
=head1 VERSION
version 0.13
=head1 SYNOPSIS
use Perinci::Object; # automatically exports risub(), rivar(), ripkg(),
# envres(), riresmeta()
use Data::Dump; # for dd()
# OO interface to function metadata.
my $risub = risub {
v => 1.1,
summary => 'Calculate foo and bar',
"summary.alt.lang.id_ID" => 'Menghitung foo dan bar',
args => { a1 => { schema => 'int*' }, a2 => { schema => 'str' } },
features => { pure=>1 },
};
dd $risub->type, # "function"
$risub->v, # 1.0
$risub->arg('a1'), # { schema=>'int*' }
$risub->arg('a3'), # undef
$risub->feature('pure'), # 1
$risub->feature('foo'), # undef
$risub->langprop('summary'), # 'Calculate foo and bar'
$risub->langprop('summary', 'id_ID'), # 'Menghitung foo dan bar'
# setting arg and property
$risub->arg('a3', 'array'); # will actually fail for 1.0 metadata
$risub->feature('foo', 2); # ditto
# OO interface to variable metadata
my $rivar = rivar { ... };
# OO interface to package metadata
my $ripkg = ripkg { ... };
# OO interface to enveloped result
my $envres = envres [200, "OK", [1, 2, 3]];
dd $envres->is_success, # 1
$envres->status, # 200
$envres->message, # "OK"
$envres->result, # [1, 2, 3]
$envres->meta; # undef
# setting status, message, result, extra
$envres->status(404);
$envres->message('Not found');
$envres->result(undef);
$envres->meta({errno=>-100});
# OO interface to function/method result metadata
my $riresmeta = riresmeta { ... };
=head1 DESCRIPTION
L<Rinci> works using pure data structures, but sometimes it's convenient to have
an object-oriented interface (wrapper) for those data. This module provides just
that.
=head1 FUNCTIONS
=head2 rimeta $meta => OBJECT
Exported by default. A shortcut for Perinci::Object::Metadata->new($meta).
=head2 risub $meta => OBJECT
Exported by default. A shortcut for Perinci::Object::function->new($meta).
=head2 rivar $meta => OBJECT
Exported by default. A shortcut for Perinci::Object::variable->new($meta).
=head2 ripkg $meta => OBJECT
Exported by default. A shortcut for Perinci::Object::package->new($meta).
=head2 riresmeta $res => OBJECT
Exported by default. A shortcut for Perinci::Object::Result->new($res).
=head1 SEE ALSO
L<Rinci>
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/Perinci-Object>.
=head1 SOURCE
Source repository is at L<https://github.com/sharyanto/perl-Perinci-Object>.
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Object>
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|