| 1 | package Venus; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 6 | ▶ | use 5.018; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 6 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | # VERSION | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 6 | our $VERSION = '1.00'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # AUTHORITY | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 6 | our $AUTHORITY = 'cpan:AWNCORP'; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # IMPORTS | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | sub import { | ||||||||||||||||||||
| 19 | 15 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 15 | my $target = caller; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 15 | my %seen; | |||||||||||||||||||
| 26 | 15 | for my $name (grep !$seen{$_}++, @args, 'true', 'false') { | |||||||||||||||||||
| 27 | 43 | ▶ | *{"${target}::${name}"} = $self->can($name) if !$target->can($name); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 15 | return $self; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | # FUNCTIONS | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | sub catch (&) { | ||||||||||||||||||||
| 36 | 4 | ▶ | my ($data) = @_; | ||||||||||||||||||
|
Subroutine
catch: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 4 | my $error; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 4 | require Venus::Try; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 4 | my @result = Venus::Try->new($data)->error(\$error)->result; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 4 | ▶ | return wantarray ? ($error ? ($error, undef) : ($error, @result)) : $error; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | sub error (;$) { | ||||||||||||||||||||
| 48 | 6 | ▶ | my ($data) = @_; | ||||||||||||||||||
|
Subroutine
error: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 6 | ▶ | $data //= {}; | ||||||||||||||||||
|
Condition100%2/2
$data //= {}
MC/DC100%1/1
$data //= {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||
| 51 | 6 | ▶ | $data->{context} //= (caller(1))[3]; | ||||||||||||||||||
|
Condition33%1/3
$data->{"context"} //= (caller 1)[3]
MC/DC0%0/2
$data->{"context"} //= (caller 1)[3]
$data->{"context"}
(caller 1)[3]
Truth table33%1/3
A //= B
A= $data->{"context"}B= (caller 1)[3]
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 6 | require Venus::Throw; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 6 | return Venus::Throw->new->error($data); | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | sub false () { | ||||||||||||||||||||
| 59 | 10 | ▶ | require Venus::Boolean; | ||||||||||||||||||
|
Subroutine
false: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 10 | return Venus::Boolean::FALSE(); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | sub raise ($;$) { | ||||||||||||||||||||
| 65 | 4 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||
|
Subroutine
raise: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 4 | ▶ | ($self, my $parent) = (@$self) if (ref($self) eq 'ARRAY'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 4 | ▶ | $data //= {}; | ||||||||||||||||||
|
Condition100%2/2
$data //= {}
MC/DC100%1/1
$data //= {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||
| 70 | 4 | ▶ | $data->{context} //= (caller(1))[3]; | ||||||||||||||||||
|
Condition33%1/3
$data->{"context"} //= (caller 1)[3]
MC/DC0%0/2
$data->{"context"} //= (caller 1)[3]
$data->{"context"}
(caller 1)[3]
Truth table33%1/3
A //= B
A= $data->{"context"}B= (caller 1)[3]
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 4 | ▶ | $parent = 'Venus::Error' if !$parent; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 4 | require Venus::Throw; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 4 | return Venus::Throw->new(package => $self, parent => $parent)->error($data); | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | sub true () { | ||||||||||||||||||||
| 80 | 11 | ▶ | require Venus::Boolean; | ||||||||||||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 11 | return Venus::Boolean::TRUE(); | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 6 | 1; | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | =head1 NAME | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | Venus - OO Library | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =head1 ABSTRACT | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | OO Standard Library for Perl 5 | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =cut | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =head1 VERSION | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 1.00 | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head1 SYNOPSIS | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | package main; | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | use Venus qw( | ||||||||||||||||||||
| 111 | catch | ||||||||||||||||||||
| 112 | error | ||||||||||||||||||||
| 113 | raise | ||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | # error handling | ||||||||||||||||||||
| 117 | my ($error, $result) = catch { | ||||||||||||||||||||
| 118 | error; | ||||||||||||||||||||
| 119 | }; | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | # boolean keywords | ||||||||||||||||||||
| 122 | if ($result and $result eq false) { | ||||||||||||||||||||
| 123 | true; | ||||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | # raise exceptions | ||||||||||||||||||||
| 127 | if (false) { | ||||||||||||||||||||
| 128 | raise 'MyApp::Error'; | ||||||||||||||||||||
| 129 | } | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | # and much more! | ||||||||||||||||||||
| 132 | true ne false; | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =cut | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | =head1 DESCRIPTION | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | This library provides an object-orientation framework and extendible standard | ||||||||||||||||||||
| 139 | library for Perl 5, built on top of the L<Mars> architecture with classes which | ||||||||||||||||||||
| 140 | wrap most native Perl data types. Venus has a simple modular architecture, | ||||||||||||||||||||
| 141 | robust library of classes, methods, and roles, supports pure-Perl autoboxing, | ||||||||||||||||||||
| 142 | advanced exception handling, "true" and "false" functions, package | ||||||||||||||||||||
| 143 | introspection, command-line options parsing, and more. This package will always | ||||||||||||||||||||
| 144 | automatically exports C<true> and C<false> keyword functions (unless existing | ||||||||||||||||||||
| 145 | routines of the same name already exist in the calling package or its parents), | ||||||||||||||||||||
| 146 | otherwise exports keyword functions as requested at import. This library | ||||||||||||||||||||
| 147 | requires Perl C<5.18+>. | ||||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | =head1 FUNCTIONS | ||||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | This package provides the following functions: | ||||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | =head2 catch | ||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | catch(CodeRef $block) (Error, Any) | ||||||||||||||||||||
| 160 | |||||||||||||||||||||
| 161 | The catch function executes the code block trapping errors and returning the | ||||||||||||||||||||
| 162 | caught exception in scalar context, and also returning the result as a second | ||||||||||||||||||||
| 163 | argument in list context. | ||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | I<Since C<0.01>> | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | =over 4 | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | =item catch example 1 | ||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | package main; | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | use Venus 'catch'; | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | my $error = catch {die}; | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | $error; | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | # 'Died at ...' | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | =back | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | =over 4 | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | =item catch example 2 | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | package main; | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | use Venus 'catch'; | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | my ($error, $result) = catch {error}; | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | $error; | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | # Venus::Error | ||||||||||||||||||||
| 196 | |||||||||||||||||||||
| 197 | =back | ||||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | =over 4 | ||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | =item catch example 3 | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | package main; | ||||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | use Venus 'catch'; | ||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | my ($error, $result) = catch {true}; | ||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | $result; | ||||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | # 1 | ||||||||||||||||||||
| 212 | |||||||||||||||||||||
| 213 | =back | ||||||||||||||||||||
| 214 | |||||||||||||||||||||
| 215 | =cut | ||||||||||||||||||||
| 216 | |||||||||||||||||||||
| 217 | =head2 error | ||||||||||||||||||||
| 218 | |||||||||||||||||||||
| 219 | error(Maybe[HashRef] $args) (Error) | ||||||||||||||||||||
| 220 | |||||||||||||||||||||
| 221 | The error function throws a L<Venus::Error> exception object using the | ||||||||||||||||||||
| 222 | exception object arguments provided. | ||||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | I<Since C<0.01>> | ||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | =over 4 | ||||||||||||||||||||
| 227 | |||||||||||||||||||||
| 228 | =item error example 1 | ||||||||||||||||||||
| 229 | |||||||||||||||||||||
| 230 | package main; | ||||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | use Venus 'error'; | ||||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | my $error = error; | ||||||||||||||||||||
| 235 | |||||||||||||||||||||
| 236 | # bless({...}, 'Venus::Error') | ||||||||||||||||||||
| 237 | |||||||||||||||||||||
| 238 | =back | ||||||||||||||||||||
| 239 | |||||||||||||||||||||
| 240 | =over 4 | ||||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | =item error example 2 | ||||||||||||||||||||
| 243 | |||||||||||||||||||||
| 244 | package main; | ||||||||||||||||||||
| 245 | |||||||||||||||||||||
| 246 | use Venus 'error'; | ||||||||||||||||||||
| 247 | |||||||||||||||||||||
| 248 | my $error = error { | ||||||||||||||||||||
| 249 | message => 'Something failed!', | ||||||||||||||||||||
| 250 | }; | ||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | # bless({message => 'Something failed!', ...}, 'Venus::Error') | ||||||||||||||||||||
| 253 | |||||||||||||||||||||
| 254 | =back | ||||||||||||||||||||
| 255 | |||||||||||||||||||||
| 256 | =cut | ||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | =head2 false | ||||||||||||||||||||
| 259 | |||||||||||||||||||||
| 260 | false() (Bool) | ||||||||||||||||||||
| 261 | |||||||||||||||||||||
| 262 | The false function returns a falsy boolean value which is designed to be | ||||||||||||||||||||
| 263 | practically indistinguishable from the conventional numerical C<0> value. | ||||||||||||||||||||
| 264 | |||||||||||||||||||||
| 265 | I<Since C<0.01>> | ||||||||||||||||||||
| 266 | |||||||||||||||||||||
| 267 | =over 4 | ||||||||||||||||||||
| 268 | |||||||||||||||||||||
| 269 | =item false example 1 | ||||||||||||||||||||
| 270 | |||||||||||||||||||||
| 271 | package main; | ||||||||||||||||||||
| 272 | |||||||||||||||||||||
| 273 | use Venus; | ||||||||||||||||||||
| 274 | |||||||||||||||||||||
| 275 | my $false = false; | ||||||||||||||||||||
| 276 | |||||||||||||||||||||
| 277 | # 0 | ||||||||||||||||||||
| 278 | |||||||||||||||||||||
| 279 | =back | ||||||||||||||||||||
| 280 | |||||||||||||||||||||
| 281 | =over 4 | ||||||||||||||||||||
| 282 | |||||||||||||||||||||
| 283 | =item false example 2 | ||||||||||||||||||||
| 284 | |||||||||||||||||||||
| 285 | package main; | ||||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | use Venus; | ||||||||||||||||||||
| 288 | |||||||||||||||||||||
| 289 | my $true = !false; | ||||||||||||||||||||
| 290 | |||||||||||||||||||||
| 291 | # 1 | ||||||||||||||||||||
| 292 | |||||||||||||||||||||
| 293 | =back | ||||||||||||||||||||
| 294 | |||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||
| 296 | |||||||||||||||||||||
| 297 | =head2 raise | ||||||||||||||||||||
| 298 | |||||||||||||||||||||
| 299 | raise(Str $class | Tuple[Str, Str] $class, Maybe[HashRef] $args) (Error) | ||||||||||||||||||||
| 300 | |||||||||||||||||||||
| 301 | The raise function generates and throws a named exception object derived from | ||||||||||||||||||||
| 302 | L<Venus::Error>, or provided base class, using the exception object arguments | ||||||||||||||||||||
| 303 | provided. | ||||||||||||||||||||
| 304 | |||||||||||||||||||||
| 305 | I<Since C<0.01>> | ||||||||||||||||||||
| 306 | |||||||||||||||||||||
| 307 | =over 4 | ||||||||||||||||||||
| 308 | |||||||||||||||||||||
| 309 | =item raise example 1 | ||||||||||||||||||||
| 310 | |||||||||||||||||||||
| 311 | package main; | ||||||||||||||||||||
| 312 | |||||||||||||||||||||
| 313 | use Venus 'raise'; | ||||||||||||||||||||
| 314 | |||||||||||||||||||||
| 315 | my $error = raise 'MyApp::Error'; | ||||||||||||||||||||
| 316 | |||||||||||||||||||||
| 317 | # bless({...}, 'MyApp::Error') | ||||||||||||||||||||
| 318 | |||||||||||||||||||||
| 319 | =back | ||||||||||||||||||||
| 320 | |||||||||||||||||||||
| 321 | =over 4 | ||||||||||||||||||||
| 322 | |||||||||||||||||||||
| 323 | =item raise example 2 | ||||||||||||||||||||
| 324 | |||||||||||||||||||||
| 325 | package main; | ||||||||||||||||||||
| 326 | |||||||||||||||||||||
| 327 | use Venus 'raise'; | ||||||||||||||||||||
| 328 | |||||||||||||||||||||
| 329 | my $error = raise ['MyApp::Error', 'Venus::Error']; | ||||||||||||||||||||
| 330 | |||||||||||||||||||||
| 331 | # bless({...}, 'MyApp::Error') | ||||||||||||||||||||
| 332 | |||||||||||||||||||||
| 333 | =back | ||||||||||||||||||||
| 334 | |||||||||||||||||||||
| 335 | =over 4 | ||||||||||||||||||||
| 336 | |||||||||||||||||||||
| 337 | =item raise example 3 | ||||||||||||||||||||
| 338 | |||||||||||||||||||||
| 339 | package main; | ||||||||||||||||||||
| 340 | |||||||||||||||||||||
| 341 | use Venus 'raise'; | ||||||||||||||||||||
| 342 | |||||||||||||||||||||
| 343 | my $error = raise ['MyApp::Error', 'Venus::Error'], { | ||||||||||||||||||||
| 344 | message => 'Something failed!', | ||||||||||||||||||||
| 345 | }; | ||||||||||||||||||||
| 346 | |||||||||||||||||||||
| 347 | # bless({message => 'Something failed!', ...}, 'MyApp::Error') | ||||||||||||||||||||
| 348 | |||||||||||||||||||||
| 349 | =back | ||||||||||||||||||||
| 350 | |||||||||||||||||||||
| 351 | =cut | ||||||||||||||||||||
| 352 | |||||||||||||||||||||
| 353 | =head2 true | ||||||||||||||||||||
| 354 | |||||||||||||||||||||
| 355 | true() (Bool) | ||||||||||||||||||||
| 356 | |||||||||||||||||||||
| 357 | The true function returns a truthy boolean value which is designed to be | ||||||||||||||||||||
| 358 | practically indistinguishable from the conventional numerical C<1> value. | ||||||||||||||||||||
| 359 | |||||||||||||||||||||
| 360 | I<Since C<0.01>> | ||||||||||||||||||||
| 361 | |||||||||||||||||||||
| 362 | =over 4 | ||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | =item true example 1 | ||||||||||||||||||||
| 365 | |||||||||||||||||||||
| 366 | package main; | ||||||||||||||||||||
| 367 | |||||||||||||||||||||
| 368 | use Venus; | ||||||||||||||||||||
| 369 | |||||||||||||||||||||
| 370 | my $true = true; | ||||||||||||||||||||
| 371 | |||||||||||||||||||||
| 372 | # 1 | ||||||||||||||||||||
| 373 | |||||||||||||||||||||
| 374 | =back | ||||||||||||||||||||
| 375 | |||||||||||||||||||||
| 376 | =over 4 | ||||||||||||||||||||
| 377 | |||||||||||||||||||||
| 378 | =item true example 2 | ||||||||||||||||||||
| 379 | |||||||||||||||||||||
| 380 | package main; | ||||||||||||||||||||
| 381 | |||||||||||||||||||||
| 382 | use Venus; | ||||||||||||||||||||
| 383 | |||||||||||||||||||||
| 384 | my $false = !true; | ||||||||||||||||||||
| 385 | |||||||||||||||||||||
| 386 | # 0 | ||||||||||||||||||||
| 387 | |||||||||||||||||||||
| 388 | =back | ||||||||||||||||||||
| 389 | |||||||||||||||||||||
| 390 | =cut | ||||||||||||||||||||
| 391 | |||||||||||||||||||||
| 392 | =head1 FEATURES | ||||||||||||||||||||
| 393 | |||||||||||||||||||||
| 394 | This package provides the following features: | ||||||||||||||||||||
| 395 | |||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||
| 397 | |||||||||||||||||||||
| 398 | =over 4 | ||||||||||||||||||||
| 399 | |||||||||||||||||||||
| 400 | =item standard-library | ||||||||||||||||||||
| 401 | |||||||||||||||||||||
| 402 | This library provides a Perl object-oriented standard library with value | ||||||||||||||||||||
| 403 | classes and consistently named methods. | ||||||||||||||||||||
| 404 | |||||||||||||||||||||
| 405 | B<example 1> | ||||||||||||||||||||
| 406 | |||||||||||||||||||||
| 407 | package main; | ||||||||||||||||||||
| 408 | |||||||||||||||||||||
| 409 | use Venus::Array; | ||||||||||||||||||||
| 410 | |||||||||||||||||||||
| 411 | my $array = Venus::Array->new([1..4]); | ||||||||||||||||||||
| 412 | |||||||||||||||||||||
| 413 | # $array->all(sub{ $_ > 0 }); | ||||||||||||||||||||
| 414 | # $array->any(sub{ $_ > 0 }); | ||||||||||||||||||||
| 415 | # $array->each(sub{ $_ > 0 }); | ||||||||||||||||||||
| 416 | # $array->grep(sub{ $_ > 0 }); | ||||||||||||||||||||
| 417 | # $array->map(sub{ $_ > 0 }); | ||||||||||||||||||||
| 418 | # $array->none(sub{ $_ < 0 }); | ||||||||||||||||||||
| 419 | # $array->one(sub{ $_ == 0 }); | ||||||||||||||||||||
| 420 | # $array->random; | ||||||||||||||||||||
| 421 | |||||||||||||||||||||
| 422 | use Venus::Hash; | ||||||||||||||||||||
| 423 | |||||||||||||||||||||
| 424 | my $hash = Venus::Hash->new({1..8}); | ||||||||||||||||||||
| 425 | |||||||||||||||||||||
| 426 | # $hash->all(sub{ $_ > 0 }); | ||||||||||||||||||||
| 427 | # $hash->any(sub{ $_ > 0 }); | ||||||||||||||||||||
| 428 | # $hash->each(sub{ $_ > 0 }); | ||||||||||||||||||||
| 429 | # $hash->grep(sub{ $_ > 0 }); | ||||||||||||||||||||
| 430 | # $hash->map(sub{ $_ > 0 }); | ||||||||||||||||||||
| 431 | # $hash->none(sub{ $_ < 0 }); | ||||||||||||||||||||
| 432 | # $hash->one(sub{ $_ == 0 }); | ||||||||||||||||||||
| 433 | # $hash->random; | ||||||||||||||||||||
| 434 | |||||||||||||||||||||
| 435 | $array->count == $hash->count; | ||||||||||||||||||||
| 436 | |||||||||||||||||||||
| 437 | # 1 | ||||||||||||||||||||
| 438 | |||||||||||||||||||||
| 439 | =back | ||||||||||||||||||||
| 440 | |||||||||||||||||||||
| 441 | =over 4 | ||||||||||||||||||||
| 442 | |||||||||||||||||||||
| 443 | =item value-classes | ||||||||||||||||||||
| 444 | |||||||||||||||||||||
| 445 | This library provides value classes which wrap native Perl data types and | ||||||||||||||||||||
| 446 | provides methods for operating their values. | ||||||||||||||||||||
| 447 | |||||||||||||||||||||
| 448 | B<example 1> | ||||||||||||||||||||
| 449 | |||||||||||||||||||||
| 450 | package main; | ||||||||||||||||||||
| 451 | |||||||||||||||||||||
| 452 | use Venus::Array; | ||||||||||||||||||||
| 453 | |||||||||||||||||||||
| 454 | my $array = Venus::Array->new; | ||||||||||||||||||||
| 455 | |||||||||||||||||||||
| 456 | # bless({...}, 'Venus::Array') | ||||||||||||||||||||
| 457 | |||||||||||||||||||||
| 458 | B<example 2> | ||||||||||||||||||||
| 459 | |||||||||||||||||||||
| 460 | package main; | ||||||||||||||||||||
| 461 | |||||||||||||||||||||
| 462 | use Venus::Boolean; | ||||||||||||||||||||
| 463 | |||||||||||||||||||||
| 464 | my $boolean = Venus::Boolean->new; | ||||||||||||||||||||
| 465 | |||||||||||||||||||||
| 466 | # bless({...}, 'Venus::Boolean') | ||||||||||||||||||||
| 467 | |||||||||||||||||||||
| 468 | B<example 3> | ||||||||||||||||||||
| 469 | |||||||||||||||||||||
| 470 | package main; | ||||||||||||||||||||
| 471 | |||||||||||||||||||||
| 472 | use Venus::Code; | ||||||||||||||||||||
| 473 | |||||||||||||||||||||
| 474 | my $code = Venus::Code->new; | ||||||||||||||||||||
| 475 | |||||||||||||||||||||
| 476 | # bless({...}, 'Venus::Code') | ||||||||||||||||||||
| 477 | |||||||||||||||||||||
| 478 | B<example 4> | ||||||||||||||||||||
| 479 | |||||||||||||||||||||
| 480 | package main; | ||||||||||||||||||||
| 481 | |||||||||||||||||||||
| 482 | use Venus::Float; | ||||||||||||||||||||
| 483 | |||||||||||||||||||||
| 484 | my $float = Venus::Float->new; | ||||||||||||||||||||
| 485 | |||||||||||||||||||||
| 486 | # bless({...}, 'Venus::Float') | ||||||||||||||||||||
| 487 | |||||||||||||||||||||
| 488 | B<example 5> | ||||||||||||||||||||
| 489 | |||||||||||||||||||||
| 490 | package main; | ||||||||||||||||||||
| 491 | |||||||||||||||||||||
| 492 | use Venus::Hash; | ||||||||||||||||||||
| 493 | |||||||||||||||||||||
| 494 | my $hash = Venus::Hash->new; | ||||||||||||||||||||
| 495 | |||||||||||||||||||||
| 496 | # bless({...}, 'Venus::Hash') | ||||||||||||||||||||
| 497 | |||||||||||||||||||||
| 498 | B<example 6> | ||||||||||||||||||||
| 499 | |||||||||||||||||||||
| 500 | package main; | ||||||||||||||||||||
| 501 | |||||||||||||||||||||
| 502 | use Venus::Number; | ||||||||||||||||||||
| 503 | |||||||||||||||||||||
| 504 | my $number = Venus::Number->new; | ||||||||||||||||||||
| 505 | |||||||||||||||||||||
| 506 | # bless({...}, 'Venus::Number') | ||||||||||||||||||||
| 507 | |||||||||||||||||||||
| 508 | B<example 7> | ||||||||||||||||||||
| 509 | |||||||||||||||||||||
| 510 | package main; | ||||||||||||||||||||
| 511 | |||||||||||||||||||||
| 512 | use Venus::Regexp; | ||||||||||||||||||||
| 513 | |||||||||||||||||||||
| 514 | my $regexp = Venus::Regexp->new; | ||||||||||||||||||||
| 515 | |||||||||||||||||||||
| 516 | # bless({...}, 'Venus::Regexp') | ||||||||||||||||||||
| 517 | |||||||||||||||||||||
| 518 | B<example 8> | ||||||||||||||||||||
| 519 | |||||||||||||||||||||
| 520 | package main; | ||||||||||||||||||||
| 521 | |||||||||||||||||||||
| 522 | use Venus::Scalar; | ||||||||||||||||||||
| 523 | |||||||||||||||||||||
| 524 | my $scalar = Venus::Scalar->new; | ||||||||||||||||||||
| 525 | |||||||||||||||||||||
| 526 | # bless({...}, 'Venus::Scalar') | ||||||||||||||||||||
| 527 | |||||||||||||||||||||
| 528 | B<example 9> | ||||||||||||||||||||
| 529 | |||||||||||||||||||||
| 530 | package main; | ||||||||||||||||||||
| 531 | |||||||||||||||||||||
| 532 | use Venus::String; | ||||||||||||||||||||
| 533 | |||||||||||||||||||||
| 534 | my $string = Venus::String->new; | ||||||||||||||||||||
| 535 | |||||||||||||||||||||
| 536 | # bless({...}, 'Venus::String') | ||||||||||||||||||||
| 537 | |||||||||||||||||||||
| 538 | B<example 10> | ||||||||||||||||||||
| 539 | |||||||||||||||||||||
| 540 | package main; | ||||||||||||||||||||
| 541 | |||||||||||||||||||||
| 542 | use Venus::Undef; | ||||||||||||||||||||
| 543 | |||||||||||||||||||||
| 544 | my $undef = Venus::Undef->new; | ||||||||||||||||||||
| 545 | |||||||||||||||||||||
| 546 | # bless({...}, 'Venus::Undef') | ||||||||||||||||||||
| 547 | |||||||||||||||||||||
| 548 | =back | ||||||||||||||||||||
| 549 | |||||||||||||||||||||
| 550 | =over 4 | ||||||||||||||||||||
| 551 | |||||||||||||||||||||
| 552 | =item builtin-autoboxing | ||||||||||||||||||||
| 553 | |||||||||||||||||||||
| 554 | This library provides opt-in pure Perl autoboxing allowing you to chain methods | ||||||||||||||||||||
| 555 | calls across objects and values. | ||||||||||||||||||||
| 556 | |||||||||||||||||||||
| 557 | B<example 1> | ||||||||||||||||||||
| 558 | |||||||||||||||||||||
| 559 | package main; | ||||||||||||||||||||
| 560 | |||||||||||||||||||||
| 561 | use Venus::String; | ||||||||||||||||||||
| 562 | |||||||||||||||||||||
| 563 | my $string = Venus::String->new('hello, world'); | ||||||||||||||||||||
| 564 | |||||||||||||||||||||
| 565 | $string->box->split(', ')->join(' ')->titlecase->unbox->get; | ||||||||||||||||||||
| 566 | |||||||||||||||||||||
| 567 | # Hello World | ||||||||||||||||||||
| 568 | |||||||||||||||||||||
| 569 | =back | ||||||||||||||||||||
| 570 | |||||||||||||||||||||
| 571 | =over 4 | ||||||||||||||||||||
| 572 | |||||||||||||||||||||
| 573 | =item utility-classes | ||||||||||||||||||||
| 574 | |||||||||||||||||||||
| 575 | This library provides serveral essential utility classes for performing common | ||||||||||||||||||||
| 576 | programming tasks. | ||||||||||||||||||||
| 577 | |||||||||||||||||||||
| 578 | B<example 1> | ||||||||||||||||||||
| 579 | |||||||||||||||||||||
| 580 | package main; | ||||||||||||||||||||
| 581 | |||||||||||||||||||||
| 582 | use Venus::Args; | ||||||||||||||||||||
| 583 | |||||||||||||||||||||
| 584 | my $args = Venus::Args->new; | ||||||||||||||||||||
| 585 | |||||||||||||||||||||
| 586 | # bless({...}, 'Venus::Args') | ||||||||||||||||||||
| 587 | |||||||||||||||||||||
| 588 | B<example 2> | ||||||||||||||||||||
| 589 | |||||||||||||||||||||
| 590 | package main; | ||||||||||||||||||||
| 591 | |||||||||||||||||||||
| 592 | use Venus::Box; | ||||||||||||||||||||
| 593 | |||||||||||||||||||||
| 594 | my $box = Venus::Box->new; | ||||||||||||||||||||
| 595 | |||||||||||||||||||||
| 596 | # bless({...}, 'Venus::Box') | ||||||||||||||||||||
| 597 | |||||||||||||||||||||
| 598 | B<example 3> | ||||||||||||||||||||
| 599 | |||||||||||||||||||||
| 600 | package main; | ||||||||||||||||||||
| 601 | |||||||||||||||||||||
| 602 | use Venus::Data; | ||||||||||||||||||||
| 603 | |||||||||||||||||||||
| 604 | my $docs = Venus::Data->new->docs; | ||||||||||||||||||||
| 605 | |||||||||||||||||||||
| 606 | # bless({...}, 'Venus::Data') | ||||||||||||||||||||
| 607 | |||||||||||||||||||||
| 608 | B<example 4> | ||||||||||||||||||||
| 609 | |||||||||||||||||||||
| 610 | package main; | ||||||||||||||||||||
| 611 | |||||||||||||||||||||
| 612 | use Venus::Date; | ||||||||||||||||||||
| 613 | |||||||||||||||||||||
| 614 | my $date = Venus::Date->new; | ||||||||||||||||||||
| 615 | |||||||||||||||||||||
| 616 | # bless({...}, 'Venus::Date') | ||||||||||||||||||||
| 617 | |||||||||||||||||||||
| 618 | B<example 5> | ||||||||||||||||||||
| 619 | |||||||||||||||||||||
| 620 | package main; | ||||||||||||||||||||
| 621 | |||||||||||||||||||||
| 622 | use Venus::Error; | ||||||||||||||||||||
| 623 | |||||||||||||||||||||
| 624 | my $error = Venus::Error->new; | ||||||||||||||||||||
| 625 | |||||||||||||||||||||
| 626 | # bless({...}, 'Venus::Error') | ||||||||||||||||||||
| 627 | |||||||||||||||||||||
| 628 | B<example 6> | ||||||||||||||||||||
| 629 | |||||||||||||||||||||
| 630 | package main; | ||||||||||||||||||||
| 631 | |||||||||||||||||||||
| 632 | use Venus::Json; | ||||||||||||||||||||
| 633 | |||||||||||||||||||||
| 634 | my $json = Venus::Json->new; | ||||||||||||||||||||
| 635 | |||||||||||||||||||||
| 636 | # bless({...}, 'Venus::Json') | ||||||||||||||||||||
| 637 | |||||||||||||||||||||
| 638 | B<example 7> | ||||||||||||||||||||
| 639 | |||||||||||||||||||||
| 640 | package main; | ||||||||||||||||||||
| 641 | |||||||||||||||||||||
| 642 | use Venus::Name; | ||||||||||||||||||||
| 643 | |||||||||||||||||||||
| 644 | my $name = Venus::Name->new; | ||||||||||||||||||||
| 645 | |||||||||||||||||||||
| 646 | # bless({...}, 'Venus::Name') | ||||||||||||||||||||
| 647 | |||||||||||||||||||||
| 648 | B<example 8> | ||||||||||||||||||||
| 649 | |||||||||||||||||||||
| 650 | package main; | ||||||||||||||||||||
| 651 | |||||||||||||||||||||
| 652 | use Venus::Opts; | ||||||||||||||||||||
| 653 | |||||||||||||||||||||
| 654 | my $opts = Venus::Opts->new; | ||||||||||||||||||||
| 655 | |||||||||||||||||||||
| 656 | # bless({...}, 'Venus::Opts') | ||||||||||||||||||||
| 657 | |||||||||||||||||||||
| 658 | B<example 9> | ||||||||||||||||||||
| 659 | |||||||||||||||||||||
| 660 | package main; | ||||||||||||||||||||
| 661 | |||||||||||||||||||||
| 662 | use Venus::Path; | ||||||||||||||||||||
| 663 | |||||||||||||||||||||
| 664 | my $path = Venus::Path->new; | ||||||||||||||||||||
| 665 | |||||||||||||||||||||
| 666 | # bless({...}, 'Venus::Path') | ||||||||||||||||||||
| 667 | |||||||||||||||||||||
| 668 | B<example 10> | ||||||||||||||||||||
| 669 | |||||||||||||||||||||
| 670 | package main; | ||||||||||||||||||||
| 671 | |||||||||||||||||||||
| 672 | use Venus::Data; | ||||||||||||||||||||
| 673 | |||||||||||||||||||||
| 674 | my $text = Venus::Data->new->text; | ||||||||||||||||||||
| 675 | |||||||||||||||||||||
| 676 | # bless({...}, 'Venus::Data') | ||||||||||||||||||||
| 677 | |||||||||||||||||||||
| 678 | B<example 11> | ||||||||||||||||||||
| 679 | |||||||||||||||||||||
| 680 | package main; | ||||||||||||||||||||
| 681 | |||||||||||||||||||||
| 682 | use Venus::Space; | ||||||||||||||||||||
| 683 | |||||||||||||||||||||
| 684 | my $space = Venus::Space->new; | ||||||||||||||||||||
| 685 | |||||||||||||||||||||
| 686 | # bless({...}, 'Venus::Space') | ||||||||||||||||||||
| 687 | |||||||||||||||||||||
| 688 | B<example 12> | ||||||||||||||||||||
| 689 | |||||||||||||||||||||
| 690 | package main; | ||||||||||||||||||||
| 691 | |||||||||||||||||||||
| 692 | use Venus::Throw; | ||||||||||||||||||||
| 693 | |||||||||||||||||||||
| 694 | my $throw = Venus::Throw->new; | ||||||||||||||||||||
| 695 | |||||||||||||||||||||
| 696 | # bless({...}, 'Venus::Throw') | ||||||||||||||||||||
| 697 | |||||||||||||||||||||
| 698 | B<example 13> | ||||||||||||||||||||
| 699 | |||||||||||||||||||||
| 700 | package main; | ||||||||||||||||||||
| 701 | |||||||||||||||||||||
| 702 | use Venus::Try; | ||||||||||||||||||||
| 703 | |||||||||||||||||||||
| 704 | my $try = Venus::Try->new; | ||||||||||||||||||||
| 705 | |||||||||||||||||||||
| 706 | # bless({...}, 'Venus::Try') | ||||||||||||||||||||
| 707 | |||||||||||||||||||||
| 708 | B<example 14> | ||||||||||||||||||||
| 709 | |||||||||||||||||||||
| 710 | package main; | ||||||||||||||||||||
| 711 | |||||||||||||||||||||
| 712 | use Venus::Type; | ||||||||||||||||||||
| 713 | |||||||||||||||||||||
| 714 | my $type = Venus::Type->new; | ||||||||||||||||||||
| 715 | |||||||||||||||||||||
| 716 | # bless({...}, 'Venus::Type') | ||||||||||||||||||||
| 717 | |||||||||||||||||||||
| 718 | B<example 15> | ||||||||||||||||||||
| 719 | |||||||||||||||||||||
| 720 | package main; | ||||||||||||||||||||
| 721 | |||||||||||||||||||||
| 722 | use Venus::Vars; | ||||||||||||||||||||
| 723 | |||||||||||||||||||||
| 724 | my $vars = Venus::Vars->new; | ||||||||||||||||||||
| 725 | |||||||||||||||||||||
| 726 | # bless({...}, 'Venus::Vars') | ||||||||||||||||||||
| 727 | |||||||||||||||||||||
| 728 | B<example 16> | ||||||||||||||||||||
| 729 | |||||||||||||||||||||
| 730 | package main; | ||||||||||||||||||||
| 731 | |||||||||||||||||||||
| 732 | use Venus::Match; | ||||||||||||||||||||
| 733 | |||||||||||||||||||||
| 734 | my $match = Venus::Match->new; | ||||||||||||||||||||
| 735 | |||||||||||||||||||||
| 736 | # bless({...}, 'Venus::Match') | ||||||||||||||||||||
| 737 | |||||||||||||||||||||
| 738 | B<example 17> | ||||||||||||||||||||
| 739 | |||||||||||||||||||||
| 740 | package main; | ||||||||||||||||||||
| 741 | |||||||||||||||||||||
| 742 | use Venus::Process; | ||||||||||||||||||||
| 743 | |||||||||||||||||||||
| 744 | my $process = Venus::Process->new; | ||||||||||||||||||||
| 745 | |||||||||||||||||||||
| 746 | # bless({...}, 'Venus::Process') | ||||||||||||||||||||
| 747 | |||||||||||||||||||||
| 748 | B<example 18> | ||||||||||||||||||||
| 749 | |||||||||||||||||||||
| 750 | package main; | ||||||||||||||||||||
| 751 | |||||||||||||||||||||
| 752 | use Venus::Template; | ||||||||||||||||||||
| 753 | |||||||||||||||||||||
| 754 | my $template = Venus::Template->new; | ||||||||||||||||||||
| 755 | |||||||||||||||||||||
| 756 | # bless({...}, 'Venus::Template') | ||||||||||||||||||||
| 757 | |||||||||||||||||||||
| 758 | B<example 19> | ||||||||||||||||||||
| 759 | |||||||||||||||||||||
| 760 | package main; | ||||||||||||||||||||
| 761 | |||||||||||||||||||||
| 762 | use Venus::Yaml; | ||||||||||||||||||||
| 763 | |||||||||||||||||||||
| 764 | my $yaml = Venus::Yaml->new; | ||||||||||||||||||||
| 765 | |||||||||||||||||||||
| 766 | # bless({...}, 'Venus::Yaml') | ||||||||||||||||||||
| 767 | |||||||||||||||||||||
| 768 | =back | ||||||||||||||||||||
| 769 | |||||||||||||||||||||
| 770 | =over 4 | ||||||||||||||||||||
| 771 | |||||||||||||||||||||
| 772 | =item package-reflection | ||||||||||||||||||||
| 773 | |||||||||||||||||||||
| 774 | This library provides a package reflection class, L<Venus::Space>, which can be | ||||||||||||||||||||
| 775 | used to perform meta-programming on package spaces. | ||||||||||||||||||||
| 776 | |||||||||||||||||||||
| 777 | B<example 1> | ||||||||||||||||||||
| 778 | |||||||||||||||||||||
| 779 | package main; | ||||||||||||||||||||
| 780 | |||||||||||||||||||||
| 781 | use Venus::Space; | ||||||||||||||||||||
| 782 | |||||||||||||||||||||
| 783 | my $space = Venus::Space->new('Venus'); | ||||||||||||||||||||
| 784 | |||||||||||||||||||||
| 785 | $space->do('tryload')->routines; | ||||||||||||||||||||
| 786 | |||||||||||||||||||||
| 787 | # [...] | ||||||||||||||||||||
| 788 | |||||||||||||||||||||
| 789 | =back | ||||||||||||||||||||
| 790 | |||||||||||||||||||||
| 791 | =over 4 | ||||||||||||||||||||
| 792 | |||||||||||||||||||||
| 793 | =item exception-handling | ||||||||||||||||||||
| 794 | |||||||||||||||||||||
| 795 | This library provides a framework for raising, i.e. generating and throwing, | ||||||||||||||||||||
| 796 | exception objects and catching them. | ||||||||||||||||||||
| 797 | |||||||||||||||||||||
| 798 | B<example 1> | ||||||||||||||||||||
| 799 | |||||||||||||||||||||
| 800 | package MyApp; | ||||||||||||||||||||
| 801 | |||||||||||||||||||||
| 802 | use Venus::Class; | ||||||||||||||||||||
| 803 | |||||||||||||||||||||
| 804 | with 'Venus::Role::Throwable'; | ||||||||||||||||||||
| 805 | with 'Venus::Role::Catchable'; | ||||||||||||||||||||
| 806 | |||||||||||||||||||||
| 807 | sub execute { | ||||||||||||||||||||
| 808 | my ($self) = @_; | ||||||||||||||||||||
| 809 | |||||||||||||||||||||
| 810 | $self->throw->error; | ||||||||||||||||||||
| 811 | } | ||||||||||||||||||||
| 812 | |||||||||||||||||||||
| 813 | package main; | ||||||||||||||||||||
| 814 | |||||||||||||||||||||
| 815 | my $myapp = MyApp->new; | ||||||||||||||||||||
| 816 | |||||||||||||||||||||
| 817 | my $error = $myapp->catch('execute'); | ||||||||||||||||||||
| 818 | |||||||||||||||||||||
| 819 | # bless({...}, 'MyApp::Error'); | ||||||||||||||||||||
| 820 | |||||||||||||||||||||
| 821 | =back | ||||||||||||||||||||
| 822 | |||||||||||||||||||||
| 823 | =over 4 | ||||||||||||||||||||
| 824 | |||||||||||||||||||||
| 825 | =item composable-standards | ||||||||||||||||||||
| 826 | |||||||||||||||||||||
| 827 | This library provides a library of composable roles which can be used to extend | ||||||||||||||||||||
| 828 | core behaviors to custom objects. | ||||||||||||||||||||
| 829 | |||||||||||||||||||||
| 830 | B<example 1> | ||||||||||||||||||||
| 831 | |||||||||||||||||||||
| 832 | package MyApp; | ||||||||||||||||||||
| 833 | |||||||||||||||||||||
| 834 | use Venus::Class; | ||||||||||||||||||||
| 835 | |||||||||||||||||||||
| 836 | with 'Venus::Role::Dumpable'; | ||||||||||||||||||||
| 837 | with 'Venus::Role::Stashable'; | ||||||||||||||||||||
| 838 | |||||||||||||||||||||
| 839 | package main; | ||||||||||||||||||||
| 840 | |||||||||||||||||||||
| 841 | my $myapp = MyApp->new; | ||||||||||||||||||||
| 842 | |||||||||||||||||||||
| 843 | $myapp->stash(greeting => 'hello world'); | ||||||||||||||||||||
| 844 | |||||||||||||||||||||
| 845 | $myapp->dump('stash'); | ||||||||||||||||||||
| 846 | |||||||||||||||||||||
| 847 | # '{"greeting" => "hello world"}' | ||||||||||||||||||||
| 848 | |||||||||||||||||||||
| 849 | =back | ||||||||||||||||||||
| 850 | |||||||||||||||||||||
| 851 | =over 4 | ||||||||||||||||||||
| 852 | |||||||||||||||||||||
| 853 | =item pluggable-library | ||||||||||||||||||||
| 854 | |||||||||||||||||||||
| 855 | This library provides a mechanism for extending the standard library, i.e. | ||||||||||||||||||||
| 856 | value classes, using plugins which can be automatically discovered and invoked. | ||||||||||||||||||||
| 857 | (no monkey-patching necessary) | ||||||||||||||||||||
| 858 | |||||||||||||||||||||
| 859 | B<example 1> | ||||||||||||||||||||
| 860 | |||||||||||||||||||||
| 861 | package Venus::String::Plugin::Base64; | ||||||||||||||||||||
| 862 | |||||||||||||||||||||
| 863 | sub new { | ||||||||||||||||||||
| 864 | return bless {}; | ||||||||||||||||||||
| 865 | } | ||||||||||||||||||||
| 866 | |||||||||||||||||||||
| 867 | sub execute { | ||||||||||||||||||||
| 868 | my ($self, $string, @args) = @_; | ||||||||||||||||||||
| 869 | |||||||||||||||||||||
| 870 | require MIME::Base64; | ||||||||||||||||||||
| 871 | |||||||||||||||||||||
| 872 | return MIME::Base64::encode_base64($string->value); | ||||||||||||||||||||
| 873 | } | ||||||||||||||||||||
| 874 | |||||||||||||||||||||
| 875 | package main; | ||||||||||||||||||||
| 876 | |||||||||||||||||||||
| 877 | use Venus::String; | ||||||||||||||||||||
| 878 | |||||||||||||||||||||
| 879 | my $string = Venus::String->new('hello, world'); | ||||||||||||||||||||
| 880 | |||||||||||||||||||||
| 881 | $string->base64; | ||||||||||||||||||||
| 882 | |||||||||||||||||||||
| 883 | # "aGVsbG8sIHdvcmxk\n" | ||||||||||||||||||||
| 884 | |||||||||||||||||||||
| 885 | =back | ||||||||||||||||||||
| 886 | |||||||||||||||||||||
| 887 | =over 4 | ||||||||||||||||||||
| 888 | |||||||||||||||||||||
| 889 | =item template-system | ||||||||||||||||||||
| 890 | |||||||||||||||||||||
| 891 | This library provides a minimalistic templating system. | ||||||||||||||||||||
| 892 | |||||||||||||||||||||
| 893 | B<example 1> | ||||||||||||||||||||
| 894 | |||||||||||||||||||||
| 895 | package main; | ||||||||||||||||||||
| 896 | |||||||||||||||||||||
| 897 | use Venus::Template; | ||||||||||||||||||||
| 898 | |||||||||||||||||||||
| 899 | my $template = Venus::Template->new(q( | ||||||||||||||||||||
| 900 | {{ if user.name }} | ||||||||||||||||||||
| 901 | Welcome, {{ user.name }}! | ||||||||||||||||||||
| 902 | {{ else user.name }} | ||||||||||||||||||||
| 903 | Welcome, friend! | ||||||||||||||||||||
| 904 | {{ end user.name }} | ||||||||||||||||||||
| 905 | )); | ||||||||||||||||||||
| 906 | |||||||||||||||||||||
| 907 | $template->render; | ||||||||||||||||||||
| 908 | |||||||||||||||||||||
| 909 | # "Welcome, friend!" | ||||||||||||||||||||
| 910 | |||||||||||||||||||||
| 911 | =back | ||||||||||||||||||||
| 912 | |||||||||||||||||||||
| 913 | =head1 AUTHORS | ||||||||||||||||||||
| 914 | |||||||||||||||||||||
| 915 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||
| 916 | |||||||||||||||||||||
| 917 | =cut | ||||||||||||||||||||