NAME
Venus - Standard Library
ABSTRACT
Standard Library for Perl 5
VERSION
4.15
SYNOPSIS
DESCRIPTION
This library provides an object-orientation framework and extendible standard library for Perl 5 with classes which wrap most native Perl data types. Venus has a simple modular architecture, robust library of classes, methods, and roles, supports pure-Perl autoboxing, advanced exception handling, "true" and "false" functions, package introspection, command-line options parsing, and more. This package will always automatically exports true
and false
keyword functions (unless existing routines of the same name already exist in the calling package or its parents), otherwise exports keyword functions as requested at import. This library requires Perl 5.18+
.
CAPABILITIES
The following is a short list of capabilities:
Perl 5.18.0+
Zero Dependencies
Fast Object-Orientation
Robust Standard Library
Intuitive Value Classes
Pure Perl Autoboxing
Convenient Utility Classes
Simple Package Reflection
Flexible Exception Handling
Composable Standards
Pluggable (no monkeypatching)
Proxyable Methods
Type Assertions
Type Coercions
Value Casting
Boolean Values
Complete Documentation
Complete Test Coverage
FUNCTIONS
This package provides the following functions:
args
args(arrayref
$value
, string | coderef
$code
, any
@args
) (any)
The args function builds and returns a Venus::Args object, or dispatches to the coderef or method provided.
Since 3.10
array
array(arrayref | hashref
$value
, string | coderef
$code
, any
@args
) (any)
The array function builds and returns a Venus::Array object, or dispatches to the coderef or method provided.
Since 2.55
arrayref
arrayref(any
@args
) (arrayref)
The arrayref function takes a list of arguments and returns a arrayref.
Since 3.10
assert
assert(any
$data
, string
$expr
) (any)
The assert function builds a Venus::Assert object and returns the result of a "validate" in Venus::Assert operation.
Since 2.40
async
async(coderef
$code
, any
@args
) (Venus::Future)
The async function accepts a callback and executes it asynchronously via "future" in Venus::Process. This function returns a Venus::Future object which can be fulfilled via "wait" in Venus::Future.
Since 3.40
atom
atom(any
$value
) (Venus::Atom)
The atom function builds and returns a Venus::Atom object.
Since 3.55
await
await(Venus::Future
$future
, number
$timeout
) (any)
The await function accepts a Venus::Future object and eventually returns a value (or values) for it. The value(s) returned are the return values or emissions from the asychronous callback executed with "async" which produced the process object.
Since 3.40
bool
bool(any
$value
) (Venus::Boolean)
The bool function builds and returns a Venus::Boolean object.
Since 2.55
box
box(any
$data
) (Venus::Box)
The box function returns a Venus::Box object for the argument provided.
Since 2.32
call
call(string | object | coderef
$data
, any
@args
) (any)
The call function dispatches function and method calls to a package and returns the result.
Since 2.32
- call example 1
-
package
main;
require
Digest::SHA;
my
$result
= call(\
'Digest::SHA'
,
'new'
);
# bless(do{\(my $o = '...')}, 'digest::sha')
- call example 2
-
package
main;
require
Digest::SHA;
my
$result
= call(
'Digest::SHA'
,
'sha1_hex'
);
# "da39a3ee5e6b4b0d3255bfef95601890afd80709"
- call example 3
-
package
main;
require
Venus::Hash;
my
$result
= call(
sub
{
'Venus::Hash'
->new(
@_
)}, {1..4});
# bless({value => {1..4}}, 'Venus::Hash')
- call example 4
-
package
main;
require
Venus::Box;
my
$result
= call(Venus::Box->new(
value
=> {}),
'merge'
, {1..4});
# bless({value => bless({value => {1..4}}, 'Venus::Hash')}, 'Venus::Box')
cast
cast(any
$data
, string
$type
) (object)
The cast function returns the argument provided as an object, promoting native Perl data types to data type objects. The optional second argument can be the name of the type for the object to cast to explicitly.
Since 1.40
catch
catch
(coderef
$block
) (Venus::Error, any)
The catch function executes the code block trapping errors and returning the caught exception in scalar context, and also returning the result as a second argument in list context.
Since 0.01
caught
caught(object
$error
, string | tuple[string, string]
$identity
, coderef
$block
) (any)
The caught function evaluates the exception object provided and validates its identity and name (if provided) then executes the code block provided returning the result of the callback. If no callback is provided this function returns the exception object on success and undef
on failure.
Since 1.95
chain
chain(string | object | coderef
$self
, string | within[arrayref, string]
@args
) (any)
The chain function chains function and method calls to a package (and return values) and returns the result.
Since 2.32
check
check(any
$data
, string
$expr
) (boolean)
The check function builds a Venus::Assert object and returns the result of a "check" in Venus::Assert operation.
Since 2.40
clargs
clargs(arrayref
$args
, arrayref
$spec
) (Venus::Args, Venus::Opts, Venus::Vars)
The clargs function accepts a single arrayref of Getopt::Long specs, or an arrayref of arguments followed by an arrayref of Getopt::Long specs, and returns a three element list of Venus::Args, Venus::Opts, and Venus::Vars objects. If only a single arrayref is provided, the arguments will be taken from @ARGV
.
Since 3.10
cli
cli(arrayref
$args
) (Venus::Cli)
The cli function builds and returns a Venus::Cli object.
Since 2.55
clone
clone(
ref
$value
) (
ref
)
The clone function uses "dclone" in Storable to perform a deep clone of the reference provided and returns a copy.
Since 3.55
code
code(coderef
$value
, string | coderef
$code
, any
@args
) (any)
The code function builds and returns a Venus::Code object, or dispatches to the coderef or method provided.
Since 2.55
config
config(hashref
$value
, string | coderef
$code
, any
@args
) (any)
The config function builds and returns a Venus::Config object, or dispatches to the coderef or method provided.
Since 2.55
container
container(hashref
$value
, string | coderef
$code
, any
@args
) (any)
The container function builds and returns a Venus::Container object, or dispatches to the coderef or method provided.
Since 3.20
cop
cop(string | object | coderef
$self
, string
$name
) (coderef)
The cop function attempts to curry the given subroutine on the object or class and if successful returns a closure.
Since 2.32
data
data(string
$value
, string | coderef
$code
, any
@args
) (any)
The data function builds and returns a Venus::Data object, or dispatches to the coderef or method provided.
Since 2.55
date
date(number
$value
, string | coderef
$code
, any
@args
) (any)
The date function builds and returns a Venus::Date object, or dispatches to the coderef or method provided.
Since 2.40
docs
docs(any
@args
) (any)
The docs function builds a Venus::Data object using "docs" in Venus::Data for the current file, i.e. "__FILE__" in perlfunc or script, i.e. $0
, and returns the result of a "string" in Venus::Data operation using the arguments provided.
Since 3.30
enum
enum(arrayref | hashref
$value
) (Venus::Enum)
The enum function builds and returns a Venus::Enum object.
Since 3.55
error
error(maybe[hashref]
$args
) (Venus::Error)
The error function throws a Venus::Error exception object using the exception object arguments provided.
Since 0.01
false
false() (boolean)
The false function returns a falsy boolean value which is designed to be practically indistinguishable from the conventional numerical 0
value.
Since 0.01
fault
fault(string
$args
) (Venus::Fault)
The fault function throws a Venus::Fault exception object and represents a system failure, and isn't meant to be caught.
Since 1.80
float
float(string
$value
, string | coderef
$code
, any
@args
) (any)
The float function builds and returns a Venus::Float object, or dispatches to the coderef or method provided.
Since 2.55
future
future(coderef
$code
) (Venus::Future)
The future function builds and returns a Venus::Future object.
Since 3.55
gather
gather(any
$value
, coderef
$callback
) (any)
The gather function builds a Venus::Gather object, passing it and the value provided to the callback provided, and returns the return value from "result" in Venus::Gather.
Since 2.50
hash
hash(hashref
$value
, string | coderef
$code
, any
@args
) (any)
The hash function builds and returns a Venus::Hash object, or dispatches to the coderef or method provided.
Since 2.55
hashref
hashref(any
@args
) (hashref)
The hashref function takes a list of arguments and returns a hashref.
Since 3.10
is_bool
is_bool(any
$arg
) (boolean)
The is_bool function returns "true" if the value provided is a boolean value, not merely truthy, and "false" otherwise.
Since 3.18
is_false
is_false(any
$data
) (boolean)
The is_false function accepts a scalar value and returns true if the value is falsy.
Since 3.04
is_true
is_true(any
$data
) (boolean)
The is_true function accepts a scalar value and returns true if the value is truthy.
Since 3.04
json
json(string
$call
, any
$data
) (any)
The json function builds a Venus::Json object and will either "decode" in Venus::Json or "encode" in Venus::Json based on the argument provided and returns the result.
Since 2.40
list
list(any
@args
) (any)
The list function accepts a list of values and flattens any arrayrefs, returning a list of scalars.
Since 3.04
load
load(any
$name
) (Venus::Space)
The load function loads the package provided and returns a Venus::Space object.
Since 2.32
log
log
(any
@args
) (Venus::Log)
The log function prints the arguments provided to STDOUT, stringifying complex values, and returns a Venus::Log object. If the first argument is a log level name, e.g. debug
, error
, fatal
, info
, trace
, or warn
, it will be used when emitting the event. The desired log level is specified by the VENUS_LOG_LEVEL
environment variable and defaults to trace
.
Since 2.40
make
make(string
$package
, any
@args
) (any)
The make function "calls" the new
routine on the invocant and returns the result which should be a package string or an object.
Since 2.32
match
match(any
$value
, coderef
$callback
) (any)
The match function builds a Venus::Match object, passing it and the value provided to the callback provided, and returns the return value from "result" in Venus::Match.
Since 2.50
merge
merge(any
@args
) (any)
The merge function returns a value which is a merger of all of the arguments provided.
Since 2.32
meta
meta(string
$value
, string | coderef
$code
, any
@args
) (any)
The meta function builds and returns a Venus::Meta object, or dispatches to the coderef or method provided.
Since 2.55
name
name(string
$value
, string | coderef
$code
, any
@args
) (any)
The name function builds and returns a Venus::Name object, or dispatches to the coderef or method provided.
Since 2.55
number
number(Num
$value
, string | coderef
$code
, any
@args
) (any)
The number function builds and returns a Venus::Number object, or dispatches to the coderef or method provided.
Since 2.55
opts
opts(arrayref
$value
, string | coderef
$code
, any
@args
) (any)
The opts function builds and returns a Venus::Opts object, or dispatches to the coderef or method provided.
Since 2.55
pairs
pairs(any
$data
) (arrayref)
The pairs function accepts an arrayref or hashref and returns an arrayref of arrayrefs holding keys (or indices) and values. The function returns an empty arrayref for all other values provided. Returns a list in list context.
Since 3.04
path
path(string
$value
, string | coderef
$code
, any
@args
) (any)
The path function builds and returns a Venus::Path object, or dispatches to the coderef or method provided.
Since 2.55
perl
perl(string
$call
, any
$data
) (any)
The perl function builds a Venus::Dump object and will either "decode" in Venus::Dump or "encode" in Venus::Dump based on the argument provided and returns the result.
Since 2.40
process
process(string | coderef
$code
, any
@args
) (any)
The process function builds and returns a Venus::Process object, or dispatches to the coderef or method provided.
Since 2.55
proto
proto(hashref
$value
, string | coderef
$code
, any
@args
) (any)
The proto function builds and returns a Venus::Prototype object, or dispatches to the coderef or method provided.
Since 2.55
puts
puts(any
@args
) (arrayref)
The puts function select values from within the underlying data structure using "path" in Venus::Array or "path" in Venus::Hash, optionally assigning the value to the preceeding scalar reference and returns all the values selected.
Since 3.20
raise
raise(string
$class
| tuple[string, string]
$class
, maybe[hashref]
$args
) (Venus::Error)
The raise function generates and throws a named exception object derived from Venus::Error, or provided base class, using the exception object arguments provided.
Since 0.01
random
random(string | coderef
$code
, any
@args
) (any)
The random function builds and returns a Venus::Random object, or dispatches to the coderef or method provided.
Since 2.55
range
range(number | string
@args
) (arrayref)
The range function returns the result of a "range" in Venus::Array operation.
Since 3.20
regexp
regexp(string
$value
, string | coderef
$code
, any
@args
) (any)
The regexp function builds and returns a Venus::Regexp object, or dispatches to the coderef or method provided.
Since 2.55
render
render(string
$data
, hashref
$args
) (string)
The render function accepts a string as a template and renders it using Venus::Template, and returns the result.
Since 3.04
replace
replace(arrayref
$value
, string | coderef
$code
, any
@args
) (any)
The replace function builds and returns a Venus::Replace object, or dispatches to the coderef or method provided.
Since 2.55
resolve
resolve(hashref
$value
, any
@args
) (any)
The resolve function builds and returns an object via "resolve" in Venus::Container.
Since 3.30
roll
roll(string
$name
, any
@args
) (any)
The roll function takes a list of arguments, assuming the first argument is invokable, and reorders the list such that the routine name provided comes after the invocant (i.e. the 1st argument), creating a list acceptable to the "call" function.
Since 2.32
schema
schema(string
$value
, string | coderef
$code
, any
@args
) (any)
The schema function builds and returns a Venus::Schema object, or dispatches to the coderef or method provided.
Since 2.55
search
search(arrayref
$value
, string | coderef
$code
, any
@args
) (any)
The search function builds and returns a Venus::Search object, or dispatches to the coderef or method provided.
Since 2.55
set
set(arrayref
$value
) (Venus::Set)
The set function returns a Venus::Set object for the arrayref provided.
Since 4.11
space
space(any
$name
) (Venus::Space)
The space function returns a Venus::Space object for the package provided.
Since 2.32
string
string(string
$value
, string | coderef
$code
, any
@args
) (any)
The string function builds and returns a Venus::String object, or dispatches to the coderef or method provided.
Since 2.55
syscall
syscall
(number | string
@args
) (any)
The syscall function perlforms system call, i.e. a "qx" in perlfunc operation, and returns true
if the command succeeds, otherwise returns false
. In list context, returns the output of the operation and the exit code.
Since 3.04
template
template(string
$value
, string | coderef
$code
, any
@args
) (any)
The template function builds and returns a Venus::Template object, or dispatches to the coderef or method provided.
Since 2.55
test
test(string
$value
, string | coderef
$code
, any
@args
) (any)
The test function builds and returns a Venus::Test object, or dispatches to the coderef or method provided.
Since 2.55
text
text(any
@args
) (any)
The text function builds a Venus::Data object using "text" in Venus::Data for the current file, i.e. "__FILE__" in perlfunc or script, i.e. $0
, and returns the result of a "string" in Venus::Data operation using the arguments provided.
Since 3.30
then
then(string | object | coderef
$self
, any
@args
) (any)
The then function proxies the call request to the "call" function and returns the result as a list, prepended with the invocant.
Since 2.32
throw
throw(string | hashref
$value
, string | coderef
$code
, any
@args
) (any)
The throw function builds and returns a Venus::Throw object, or dispatches to the coderef or method provided.
Since 2.55
true
true() (boolean)
The true function returns a truthy boolean value which is designed to be practically indistinguishable from the conventional numerical 1
value.
Since 0.01
try
try
(any
$data
, string | coderef
$code
, any
@args
) (any)
The try function builds and returns a Venus::Try object, or dispatches to the coderef or method provided.
Since 2.55
type
type(any
$data
, string | coderef
$code
, any
@args
) (any)
The type function builds and returns a Venus::Type object, or dispatches to the coderef or method provided.
Since 2.55
unpack
unpack
(any
@args
) (Venus::Unpack)
The unpack function builds and returns a Venus::Unpack object.
Since 2.40
vars
vars(hashref
$value
, string | coderef
$code
, any
@args
) (any)
The vars function builds and returns a Venus::Vars object, or dispatches to the coderef or method provided.
Since 2.55
venus
venus(string
$name
, any
@args
) (any)
The venus function build a Venus package via the "chain" function based on the name provided and returns an instance of that package.
Since 2.40
work
work(coderef
$callback
) (Venus::Process)
The work function builds a Venus::Process object, forks the current process using the callback provided via the "work" in Venus::Process operation, and returns an instance of Venus::Process representing the current process.
Since 2.40
wrap
wrap(string
$data
, string
$name
) (coderef)
The wrap function installs a wrapper function in the calling package which when called either returns the package string if no arguments are provided, or calls "make" on the package with whatever arguments are provided and returns the result. Unless an alias is provided as a second argument, special characters are stripped from the package to create the function name.
Since 2.32
yaml
yaml(string
$call
, any
$data
) (any)
The yaml function builds a Venus::Yaml object and will either "decode" in Venus::Yaml or "encode" in Venus::Yaml based on the argument provided and returns the result.
Since 2.40
FEATURES
This package provides the following features:
- venus-args
-
This library contains a Venus::Args class which provides methods for accessing
@ARGS
items.
- venus-array
-
This library contains a Venus::Array class which provides methods for manipulating array data.
- venus-assert
-
This library contains a Venus::Assert class which provides a mechanism for asserting type constraints and coercion.
- venus-boolean
-
This library contains a Venus::Boolean class which provides a representation for boolean values.
- venus-box
-
This library contains a Venus::Box class which provides a pure Perl boxing mechanism.
- venus-class
-
This library contains a Venus::Class class which provides a class builder.
- venus-cli
-
This library contains a Venus::Cli class which provides a superclass for creating CLIs.
- venus-code
-
This library contains a Venus::Code class which provides methods for manipulating subroutines.
- venus-config
-
This library contains a Venus::Config class which provides methods for loading Perl, YAML, and JSON configuration data.
- venus-data
-
This library contains a Venus::Data class which provides methods for extracting
DATA
sections and POD block.
- venus-date
-
This library contains a Venus::Date class which provides methods for formatting, parsing, and manipulating dates.
- venus-dump
-
This library contains a Venus::Dump class which provides methods for reading and writing dumped Perl data.
- venus-error
-
This library contains a Venus::Error class which represents a context-aware error (exception object).
- venus-false
-
This library contains a Venus::False class which provides the global
false
value.
- venus-fault
-
This library contains a Venus::Fault class which represents a generic system error (exception object).
- venus-float
-
This library contains a Venus::Float class which provides methods for manipulating float data.
- venus-gather
-
This library contains a Venus::Gather class which provides an object-oriented interface for complex pattern matching operations on collections of data, e.g. array references.
- venus-hash
-
This library contains a Venus::Hash class which provides methods for manipulating hash data.
- venus-json
-
This library contains a Venus::Json class which provides methods for reading and writing JSON data.
- venus-log
-
This library contains a Venus::Log class which provides methods for logging information using various log levels.
- venus-match
-
This library contains a Venus::Match class which provides an object-oriented interface for complex pattern matching operations on scalar values.
- venus-meta
-
This library contains a Venus::Meta class which provides configuration information for Venus derived classes.
- venus-mixin
-
This library contains a Venus::Mixin class which provides a mixin builder.
- venus-name
-
This library contains a Venus::Name class which provides methods for parsing and formatting package namespaces.
- venus-number
-
This library contains a Venus::Number class which provides methods for manipulating number data.
- venus-opts
-
This library contains a Venus::Opts class which provides methods for handling command-line arguments.
- venus-path
-
This library contains a Venus::Path class which provides methods for working with file system paths.
- venus-process
-
This library contains a Venus::Process class which provides methods for handling and forking processes.
- venus-prototype
-
This library contains a Venus::Prototype class which provides a simple construct for enabling prototype-base programming.
- venus-random
-
This library contains a Venus::Random class which provides an object-oriented interface for Perl's pseudo-random number generator.
- venus-regexp
-
This library contains a Venus::Regexp class which provides methods for manipulating regexp data.
- venus-replace
-
This library contains a Venus::Replace class which provides methods for manipulating regexp replacement data.
- venus-run
-
This library contains a Venus::Run class which provides a base class for providing a command execution system for creating CLIs (command-line interfaces).
- venus-scalar
-
This library contains a Venus::Scalar class which provides methods for manipulating scalar data.
- venus-search
-
This library contains a Venus::Search class which provides methods for manipulating regexp search data.
- venus-space
-
This library contains a Venus::Space class which provides methods for parsing and manipulating package namespaces.
- venus-string
-
This library contains a Venus::String class which provides methods for manipulating string data.
- venus-task
-
This library contains a Venus::Task class which provides a base class for creating CLIs (command-line interfaces).
- venus-template
-
This library contains a Venus::Template class which provides a templating system, and methods for rendering template.
- venus-test
-
This library contains a Venus::Test class which aims to provide a standard for documenting Venus derived software projects.
- venus-throw
-
This library contains a Venus::Throw class which provides a mechanism for generating and raising error objects.
- venus-true
-
This library contains a Venus::True class which provides the global
true
value.
- venus-try
-
This library contains a Venus::Try class which provides an object-oriented interface for performing complex try/catch operations.
- venus-type
-
This library contains a Venus::Type class which provides methods for casting native data types to objects.
- venus-undef
-
This library contains a Venus::Undef class which provides methods for manipulating undef data.
- venus-unpack
-
This library contains a Venus::Unpack class which provides methods for validating, coercing, and otherwise operating on lists of arguments.
- venus-vars
-
This library contains a Venus::Vars class which provides methods for accessing
%ENV
items.
- venus-yaml
-
This library contains a Venus::Yaml class which provides methods for reading and writing YAML data.
AUTHORS
Awncorp, awncorp@cpan.org
LICENSE
Copyright (C) 2022, Awncorp, awncorp@cpan.org
.
This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.