view release on metacpan or search on metacpan
lib/Container/Buildah/Stage.pm view on Meta::CPAN
# create the tarball
my $cwd = getcwd();
$self->debug("in ".$self->get_name." stage before tar; pid=$$ cwd=$cwd product_dirs="
.join(" ", @product_dirs));
# ignore tar exit code 1 - appears to be unavoidable and meaningless when building on an overlayfs
my $nonzero = sub { my $ret=shift; if ($ret>1) {croak "tar exited with code $ret";}};
$cb->cmd({name => "tar", nonzero => $nonzero}, "/usr/bin/tar", "--create", "--bzip2",
"--preserve-permissions", "--sparse", "--file=".$tarball_out, "--directory=".$self->get_mnt, @product_dirs);
} else {
croak "product: stage->consumes was set but not an array ref";
view all matches for this distribution
view release on metacpan or search on metacpan
tests/include/pdclib/Internals.txt view on Meta::CPAN
2) implementation files for standard functions;
3) internal header files keeping complex stuff out of the standard
headers;
4) the central, platform-specific file _PDCLIB_config.h;
5) platform-specific implementation files;
6) platform-specific, optimized "overlay" implementations (optional).
The standard headers (in ./include/) only contain what they are
defined to contain. Where additional logic or macro magic is
necessary, that is deferred to the internal files. This has been done
so that the headers are actually educational as to what they provide
(as opposed to how the library does it).
There is a separate implementation file (in ./function/{header}/) for
every function defined by the standard, named {function}.c. Not only
does this avoid linking in huge amounts of unused code when you use
but a single function, it also allows the optimization overlay to work
(see below).
(The directory ./functions/_PDCLIB/ contains internal and helper
functions that are not part of the standard.)
tests/include/pdclib/Internals.txt view on Meta::CPAN
Of course, your platform might provide more efficient replacements
for the generic implementations offered by PDCLib. The math functions
are an especially "juicy" target for optimization - while PDCLib does
provide generic implementations for each of them, there are usually
FPU opcodes that do the same job, only orders of magnitude faster. For
this, you might want to create an "optimization overlay" for PDCLib.
Optimization Overlay
--------------------
The basic idea of PDCLib is to provide a generic implementation that
tests/include/pdclib/Internals.txt view on Meta::CPAN
crafted assembler or compiler build-ins. So I wanted to provide a
means to modify PDCLib to run more efficiently on a given platform,
without cluttering the main branch with tons of #ifdef statements and
"featureset #defines" that grow stale quickly.
The solution is the "optimization overlay". Every function has its
own implementation file, which makes it possible to replace them
piecemeal by copying a platform-specific overlay over the main PDCLib
branch to create a PDCLib adapted / optimized for the platform in
question. That overlay could be part of the PDCLib source tree (for
established platforms where maintainers won't bother with PDCLib), or
part of that platform's source tree (for under-development platforms
PDCLib maintainers won't bother with).
So, to use PDCLib on your given platform, you unpack PDCLib (as you
obviously have done already since you are reading this), and copy
the overlay for your platform over the PDCLib source tree structure.
Internal Dependencies
---------------------
Large parts of PDCLib (or any standard library, really) work well in isolation,
view all matches for this distribution
view release on metacpan or search on metacpan
t/titles.pl view on Meta::CPAN
package titles;
%hash = (
'So your topgit patch was merged upstream' => 'So+your+topgit+patch+was+merged+upstream',
'Yet another git+quilt Debian packaging workflow' => 'Yet+another+git=r=quilt+Debian+packaging+workflow',
'user level NetworkManager dispatcher' => 'user+level+NetworkManager+dispatcher',
'Beamer overlays in highlighted source code' => 'Beamer+overlays+in+highlighted+source+code',
'Fetching git bundles' => 'Fetching+git+bundles',
'wifi 4965agn' => 'wifi+4965agn',
'wanderlust whitelisting' => 'wanderlust+whitelisting',
'Tunnel versus MUX: a race to the git' => 'Tunnel+versus+MUX=6=+a+race+to+the+git',
'A topgit testimonial' => 'A+topgit+testimonial',
view all matches for this distribution
view release on metacpan or search on metacpan
be local to each coro (see Coro::State).
- incompatible change: for very deep reasons, cede and cede_notself
cannot return anything, so nothing will be returned.
- possibly bring back 5.10 compatibility (untested).
- work around stupid (and wrong) warning on 5.10 :(.
- overlay the saved state over the context stack. This saves
a few hundred bytes per coroutine on average and also
speeds up context switching a bit.
- further tune default stack sizes.
- (more) correctly calculate stack usage in coro_rss.
- Coro::Storable::blocking_* did not properly lock
view all matches for this distribution
view release on metacpan or search on metacpan
bin/unsnoopable.pl view on Meta::CPAN
};
$action{Import} = sub { # Import OTP
my ($dialog, $pad);
if ($NOODLEPI) {
system ('v4l2-ctl --overlay=1');
open (ZBAR, "zbarcam --nodisplay --prescale=640x480 /dev/video0 |");
$pad = <ZBAR>; chomp $pad; $pad =~ s/^QR-Code://;
system ('killall -9 zbarcam');
close ZBAR;
system ('v4l2-ctl --overlay=0');
print "$pad\n";
}
else {
$dialog = Wx::TextEntryDialog->new( $frame, "Paste pad below", "Import One-Time Pad");
return if($dialog->ShowModal == wxID_CANCEL);
bin/unsnoopable.pl view on Meta::CPAN
};
$action{Receive} = sub { # Receive a message
my ($dialog, $msg);
if ($NOODLEPI) {
system ('v4l2-ctl --overlay=1');
open (ZBAR, "zbarcam --nodisplay --prescale=640x480 /dev/video0 |");
$msg = <ZBAR>; chomp $msg; $msg =~ s/^QR-Code://;
system ('killall -9 zbarcam');
close ZBAR;
system ('v4l2-ctl --overlay=0');
print "$msg\n";
}
else {
$dialog = Wx::TextEntryDialog->new( $frame, "Enter message:", "Receive message");
return if $dialog->ShowModal == wxID_CANCEL;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/XkcdPassword/Words/EN/Roget.pm view on Meta::CPAN
overhear
overjoyed
overjump
overlaid
overlap
overlay
overleap
overliberal
overlie
overload
overlook
view all matches for this distribution
view release on metacpan or search on metacpan
ext/xxHash/xxhash.h view on Meta::CPAN
* [ a & 0xFFFFFFFF | b & 0xFFFFFFFF ],[ a >> 32 | b >> 32 ]
*
* Due to significant changes in aarch64, the fastest method for aarch64 is
* completely different than the fastest method for ARMv7-A.
*
* ARMv7-A treats D registers as unions overlaying Q registers, so modifying
* D11 will modify the high half of Q5. This is similar to how modifying AH
* will only affect bits 8-15 of AX on x86.
*
* VZIP takes two registers, and puts even lanes in one register and odd lanes
* in the other.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CtrlO/Crypt/XkcdPassword/Wordlist/eff_large.pm view on Meta::CPAN
overjoyed
overkill
overlabor
overlaid
overlap
overlay
overload
overlook
overlord
overlying
overnight
view all matches for this distribution
view release on metacpan or search on metacpan
Cdk/Cdk/Template.pm view on Meta::CPAN
# Retain the type of the object.
$self->{'Type'} = $type;
# Set up the parameters passed in.
my $plate = Cdk::checkReq ($name, "Plate", $params{'Plate'});
my $overlay = Cdk::checkReq ($name, "Overlay", $params{'Overlay'});
my $title = Cdk::checkDef ($name, "Title", $params{'Title'}, "");
my $label = Cdk::checkDef ($name, "Label", $params{'Label'}, "");
my $xpos = Cdk::checkDef ($name, "Xpos", $params{'Xpos'}, "CENTER");
my $ypos = Cdk::checkDef ($name, "Ypos", $params{'Ypos'}, "CENTER");
my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");
my $shadow = Cdk::checkDef ($name, "Shadow", $params{'Shadow'}, "FALSE");
# Create the thing.
$self->{'Me'} = Cdk::Template::New ($title, $label,
$plate, $overlay,
$xpos, $ypos,
$box, $shadow);
bless $self;
}
Cdk/Cdk/Template.pm view on Meta::CPAN
my $self = shift;
Cdk::Template::Clean ($self->{'Me'});
}
#
# This mixes the results with the overlay
#
sub mix
{
my $self = shift;
Cdk::Template::Mix ($self->{'Me'});
view all matches for this distribution
view release on metacpan or search on metacpan
=item - Prmt: mk new 'cbls' type: as a ckbx list && use in BrwsCnfg
=item - Prmt: mk new 'rdls' type: as a radio list w/ auto (*) -
=item - Mesg: mk new 'slid' type: params for all overlay text, chars, ticks,
flags, etc. && updt pmix to use... maybe register sub fields,dims...
=item - Prnt: add multi-line option where text can split on /\n/ but each new
line prints relative to starting xcrs
view all matches for this distribution
view release on metacpan or search on metacpan
t/fakelib/Curses.pm view on Meta::CPAN
isendwin newterm set_term delscreen cbreak nocbreak echo noecho
halfdelay intrflush keypad meta nodelay notimeout raw noraw qiflush
noqiflush timeout typeahead insch insstr insnstr instr innstr
def_prog_mode def_shell_mode reset_prog_mode reset_shell_mode resetty
savetty getsyx setsyx curs_set napms move clearok idlok idcok immedok
leaveok setscrreg scrollok nl nonl overlay overwrite copywin newpad
subpad prefresh pnoutrefresh pechochar refresh noutrefresh doupdate
redrawwin redrawln scr_dump scr_restore scr_init scr_set scroll scrl
slk_init slk_set slk_refresh slk_noutrefresh slk_label slk_clear
slk_restore slk_touch slk_attron slk_attrset slk_attr slk_attroff
slk_color baudrate erasechar has_ic has_il killchar longname termattrs
view all matches for this distribution
view release on metacpan or search on metacpan
t/data/fakelib/Curses.pm view on Meta::CPAN
isendwin newterm set_term delscreen cbreak nocbreak echo noecho
halfdelay intrflush keypad meta nodelay notimeout raw noraw qiflush
noqiflush timeout typeahead insch insstr insnstr instr innstr
def_prog_mode def_shell_mode reset_prog_mode reset_shell_mode resetty
savetty getsyx setsyx curs_set napms move clearok idlok idcok immedok
leaveok setscrreg scrollok nl nonl overlay overwrite copywin newpad
subpad prefresh pnoutrefresh pechochar refresh noutrefresh doupdate
redrawwin redrawln scr_dump scr_restore scr_init scr_set scroll scrl
slk_init slk_set slk_refresh slk_noutrefresh slk_label slk_clear
slk_restore slk_touch slk_attron slk_attrset slk_attr slk_attroff
slk_color baudrate erasechar has_ic has_il killchar longname termattrs
view all matches for this distribution
view release on metacpan or search on metacpan
t/fakelib/Curses.pm view on Meta::CPAN
isendwin newterm set_term delscreen cbreak nocbreak echo noecho
halfdelay intrflush keypad meta nodelay notimeout raw noraw qiflush
noqiflush timeout typeahead insch insstr insnstr instr innstr
def_prog_mode def_shell_mode reset_prog_mode reset_shell_mode resetty
savetty getsyx setsyx curs_set napms move clearok idlok idcok immedok
leaveok setscrreg scrollok nl nonl overlay overwrite copywin newpad
subpad prefresh pnoutrefresh pechochar refresh noutrefresh doupdate
redrawwin redrawln scr_dump scr_restore scr_init scr_set scroll scrl
slk_init slk_set slk_refresh slk_noutrefresh slk_label slk_clear
slk_restore slk_touch slk_attron slk_attrset slk_attr slk_attroff
slk_color baudrate erasechar has_ic has_il killchar longname termattrs
view all matches for this distribution
view release on metacpan or search on metacpan
isendwin newterm set_term delscreen cbreak nocbreak echo noecho
halfdelay intrflush keypad meta nodelay notimeout raw noraw qiflush
noqiflush timeout typeahead insch insstr insnstr instr innstr
def_prog_mode def_shell_mode reset_prog_mode reset_shell_mode resetty
savetty getsyx setsyx curs_set napms move clearok idlok idcok immedok
leaveok setscrreg scrollok nl nonl overlay overwrite copywin newpad
subpad prefresh pnoutrefresh pechochar refresh noutrefresh doupdate
redrawwin redrawln scr_dump scr_restore scr_init scr_set scroll scrl
slk_init slk_set slk_refresh slk_noutrefresh slk_label slk_clear
slk_restore slk_touch slk_attron slk_attrset slk_attr slk_attroff
slk_color baudrate erasechar has_ic has_il killchar longname termattrs
leaveok Yes
setscrreg Yes wsetscrreg
scrollok Yes
nl No
nonl No
overlay No
overwrite No
copywin No
newpad No
subpad No
prefresh No
view all matches for this distribution
view release on metacpan or search on metacpan
Chart/Plot.pm view on Meta::CPAN
# - fixed Y-axis tick problem when no grid used
#
# 0.20 Mar 10, 2001 Dean Arnold
# - added logrithmic graphs
# - added area graphs
# - added image overlays
#
# 0.10 Feb 20, 2001 Dean Arnold
# - Coded.
#
require 5.6.0;
view all matches for this distribution
view release on metacpan or search on metacpan
if (0==strcmp(word, "others")) return DBDPG_TRUE;
if (0==strcmp(word, "out")) return DBDPG_TRUE;
if (0==strcmp(word, "outer")) return DBDPG_TRUE;
if (0==strcmp(word, "over")) return DBDPG_TRUE;
if (0==strcmp(word, "overlaps")) return DBDPG_TRUE;
if (0==strcmp(word, "overlay")) return DBDPG_TRUE;
if (0==strcmp(word, "overriding")) return DBDPG_TRUE;
if (0==strcmp(word, "owned")) return DBDPG_TRUE;
if (0==strcmp(word, "owner")) return DBDPG_TRUE;
if (0==strcmp(word, "parallel")) return DBDPG_TRUE;
if (0==strcmp(word, "parser")) return DBDPG_TRUE;
view all matches for this distribution
view release on metacpan or search on metacpan
** Each name/number pair is encoded by subsequent groups of 3 or more
** integers.
**
** Each name/number pair starts with two integers which are the numeric
** value for the pair and the size of the name/number pair, respectively.
** The text name overlays one or more following integers. The text name
** is always zero-terminated.
**
** Conceptually:
**
** struct VList {
view all matches for this distribution
view release on metacpan or search on metacpan
** Each name/number pair is encoded by subsequent groups of 3 or more
** integers.
**
** Each name/number pair starts with two integers which are the numeric
** value for the pair and the size of the name/number pair, respectively.
** The text name overlays one or more following integers. The text name
** is always zero-terminated.
**
** Conceptually:
**
** struct VList {
view all matches for this distribution
view release on metacpan or search on metacpan
0.39 2014-04-19
- Added tests for sqlarrayhash in t/002_sql_functions.t
- Added tests for absarrayhash in t/002_abs_functions.t
0.38 2014-04-18
- Added prepare method as caching overlay.
0.37 2014-04-18
- Added bulk insert methods
0.36 2014-04-15
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/AuditAny/DataPoint.pm view on Meta::CPAN
=head2 context
The name of the -context- which determines at what point the value
can be computed and collected, and into which Context -object- it
will be cached (although, since Context objects overlay in a hierarchy,
lower-level contexts can automatically access the datapoint values of the
higher-level contexts (i.e. 'set' datapoints are implied in 'change'
context but not 'column' datapoints. This is just standard belongs_to vs
has_many logic based on the way contexts are interrelated, regardless of
how or if they are actually stored)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Migration/Directories.pm view on Meta::CPAN
}
return(@rv);
}
sub ls_overlay {
my($self, $dir, $overlay) = @_;
my %dir = map { $_->basename => $_ } $self->ls($dir);
$dir{$_->basename} = $_
foreach grep { !$dir{$_->basename} } $self->ls($overlay);
return map { $dir{$_} } sort keys %dir;
}
sub ls {
my($self, $dn) = @_;
lib/DBIx/Migration/Directories.pm view on Meta::CPAN
sub dir_flat_sql {
my($self, $dir) = @_;
map { $self->read_sql_file($_) } $self->ls($dir);
}
sub dir_overlay_sql {
my($self, $dir, $overlay) = @_;
map { $self->read_sql_file($_) } $self->ls_overlay($dir, $overlay);
}
sub dir_sql {
my($self, $dir) = @_;
my $d1 = "$self->{dir}/$dir";
if($self->{common_dir} && $dir ne $self->{common_dir}) {
my $d2 = "$self->{common_dir}/$dir";
if(-d $d1 && -d $d2) {
$self->dir_overlay_sql($d1, $d2);
} elsif (-d $d2) {
$self->dir_flat_sql($d2);
} else {
$self->dir_flat_sql($d1);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/NoSQL.pm view on Meta::CPAN
package DBIx::NoSQL;
our $AUTHORITY = 'cpan:YANICK';
$DBIx::NoSQL::VERSION = '0.0021';
# ABSTRACT: NoSQL-ish overlay for an SQL database
use strict;
use warnings;
use DBIx::NoSQL::Store;
lib/DBIx/NoSQL.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
DBIx::NoSQL - NoSQL-ish overlay for an SQL database
=head1 VERSION
version 0.0021
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/ResultSet.pm view on Meta::CPAN
my $old_rs = $connector->resultset('users')->search({ status => 0 });
my $new_rs = $old_rs->search({ age > 18 });
print 'Disabled adults: ' . $new_rs->count() . "\n";
Returns a new result set object that overlays the passed in where clause
on top of the old where clause, creating a new result set. The original
result set's where clause is left unmodified.
search() never executes SQL queries. You can call search() as many times
as you like and iteratively build a resultset as much as you want, but no
view all matches for this distribution
view release on metacpan or search on metacpan
timetheese/tpl/stackoverflow_homepage.html view on Meta::CPAN
</head>
<body class="home-page">
<noscript><div id="noscript-padding"></div></noscript>
<div id="notify-container"></div>
<div id="overlay-header"></div>
<div id="custom-header"></div>
<div class="container">
<div id="header">
<div id="portalLink">
view all matches for this distribution
view release on metacpan or search on metacpan
public/css/bootstrap-3/bootstrap.css.map view on Meta::CPAN
{"version":3,"sources":["bootstrap.css","less/normalize.less","less/print.less","less/glyphicons.less","less/scaffolding.less","less/mixins/vendor-prefixes.less","less/mixins/tab-focus.less","less/mixins/image.less","less/type.less","less/mixins/text...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/LiteBlog/Scaffolder/Data.pm view on Meta::CPAN
align-items: center;
background-size: cover;
background-position: center;
max-width: 100%;
border-radius: 5px;
position: relative; /* Needed for the overlay and for the meta's absolute positioning */
margin-bottom: 20px;
}
.post-header::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6); /* Black overlay to ensure text readability */
z-index: 1;
}
.post-header .header-content {
flex-grow: 1;
lib/Dancer2/Plugin/LiteBlog/Scaffolder/Data.pm view on Meta::CPAN
background: #f0f0f0; /* Light background */
color: #333; /* Darker text color for better contrast on light bg */
}
/* Override the dark overlay when no featured image */
.post-header.no-featured-image::before {
background: rgba(255, 255, 255, 0); /* Transparent overlay */
}
/* Adjust the title color for better readability on light background */
.post-header.no-featured-image .post-title {
color: #333;
view all matches for this distribution
view release on metacpan or search on metacpan
share/assets/dash_core_components/async~plotlyjs.js view on Meta::CPAN
(window.webpackJsonpdash_core_components=window.webpackJsonpdash_core_components||[]).push([[5],{685:function(t,e){!function(r){"object"==typeof e&&void 0!==t?t.exports=r():"function"==typeof define&&define.amd?define([],r):("undefined"!=typeof windo...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Annotation.pm view on Meta::CPAN
sub inflate_chains ($self) {
$self->_chain_for($_) for $self->chains_list;
return $self;
}
sub overlay_cloak ($self, $data, %opts) {
return Data::Annotation::Overlay->new(under => $data, %opts);
}
sub evaluate ($self, $chain, $data) {
$chain = $self->default_chain unless $self->has_chain_for($chain);
# cloak the input $data with an Overlay, unless it's already an
# overlay in which case it's used directly
$data = $self->overlay_cloak($data,
value_if_missing => '',
value_if_undef => '',
) unless blessed($data) && $data->isa('Data::Annotation::Overlay');
my @call_sequence;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Overlay.pm view on Meta::CPAN
# Data::Dumper lazy loaded when debugging
our $VERSION = '0.54';
$VERSION = eval $VERSION; ## no critic
our @EXPORT = qw(overlay);
our @EXPORT_OK = qw(overlay overlay_all compose combine_with);
=head1 NAME
Data::Overlay - merge/overlay data with composable changes
=head1 VERSION
Data::Overlay version 0.54 - ALPHA, no compatibility promises, seriously
lib/Data/Overlay.pm view on Meta::CPAN
#!perl -s
#line 31
use strict; use warnings;
use Data::Overlay qw(overlay compose);
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
my $data_structure = {
a => 123,
lib/Data/Overlay.pm view on Meta::CPAN
},
);
# apply %changes to $data_structure (read-only ok),
# returning a new data structure sharing unchanged data with the old
my $new_data_structure = overlay($data_structure, \%changes);
# Note sharing shown by Dumper
print Dumper($data_structure, \%changes, $new_data_structure);
__END__
lib/Data/Overlay.pm view on Meta::CPAN
=head1 DESCRIPTION
=head2 Basic Idea
The overlay functions can be used to apply a group of changes
(also called an overlay) to a data structure, non-destructively,
returning a shallow-ish copy with the changes applied.
"Shallow-ish" meaning shallow copies at each level along
the path of the deeper changes.
$result = overlay($original, $overlay);
The algorithm walks the overlay structure, either taking
values from it, or when nothing has changed, retaining the
values of the original data structure. This means that the
only the overlay fully traversed.
When the overlay is doesn't use any special Data::Overlay
keys (ones starting with "="), then the result will be
the merger of the original and the overlay, with the overlay
taking precedence. In particular, only hashes will really
be merged, somewhat like C<< %new = (%defaults, %options) >>,
but recursively. This means that array refs, scalars, code,
etc. will be replace whatever is in the original, regardless
of the original type (so an array in the overlay will take
precedence over an array, hash or scalar in the original).
That's why it's not called Data::Underlay.
Any different merging behaviour needs to be marked with
special keys in the overlay called "actions". These start
with an "=" sign. (Double it in the overlay to have an actual
leading "=" in the result). The actions are described below,
but they combine the original and overlay in various ways,
pushing/unshifting arrays, only overwriting false or undefined,
up to providing ability to write your own combining callback.
=head2 Reference Sharing
Data::Overlay tries to minimize copying and so will try
to share references between the new structure and the old structure
and overlay. This means that changing any of these is likely
to produce unintended consequences. This sharing is only
practical when the data structures are either read-only or
cloned immediately after overlaying (Cloner not included).
=head1 GLOSSARY
overlay
v : put something on top of something else
n : layer put on top of something else
$ds, $old_ds, $new_ds - arbitrary, nested Perl data-structures
lib/Data/Overlay.pm view on Meta::CPAN
return reftype($maybe_ref) && reftype($maybe_ref) eq $type;
}
=head1 INTERFACE
=head2 overlay
$new_ds = overlay($old_ds, $overlay);
Apply an overlay to $old_ds, returning $new_ds as the result.
$old_ds is unchanged. $new_ds may share references to parts
of $old_ds and $overlay (see L<Reference Sharing>). If this isn't desired
then clone $new_ds.
=cut
sub overlay {
my ($ds, $overlay, $conf) = @_;
$conf ||= $default_conf;
if (_isreftype(HASH => $overlay)) {
# trivial case: overlay is {}
if (!keys %$overlay) { # empty overlay
return $ds; # leave $ds alone
}
# = is action (== is key with leading = "escaped")
my ($overlay_keys, $actions, $escaped_keys) =
part { /^(==?)/ && length $1 } keys %$overlay;
# part might leave undefs
$_ ||= [] for ($overlay_keys, $actions, $escaped_keys);
# 0-level $ds copy for actions that operate on $new_ds as a whole
# ($new_ds need not be a HASH here)
my $new_ds = $ds; # don't use $ds anymore, $new_ds instead
# apply each action in order to $new_ds, sequentially
# (note that some items really need to nest inner overlays
# to be useful, eg. config applies only in a dynamic scope
# to children under "data", not to peers)
for my $action_key (_sort_actions($actions, $conf)) {
my ($action) = ($action_key =~ /^=(.*)/);
my $callback = $conf->{action_map}{$action};
die "No action '$action' in action_map" unless $callback;
$new_ds = $callback->($new_ds, $overlay->{$action_key}, $conf);
}
# return if there are only actions, no plain keys
# ( important for overlaying scalars, eg. a: 1 +++ a: =defor 1 )
return $new_ds unless @$overlay_keys || @$escaped_keys;
# There are non-action keys in overlay, so insist on a $new_ds hash
# (Shallow copy $new_ds in case it is a reference to $ds)
if (_isreftype(HASH => $new_ds)) {
$new_ds = { %$new_ds }; # shallow copy
} else {
$new_ds = {}; # $new_ds is not a HASH ($ds wasn't), must become one
}
# apply overlay_keys to $new_ds
for my $key (@$overlay_keys) {
$new_ds->{$key} =
overlay($new_ds->{$key}, $overlay->{$key}, $conf);
}
# apply any escaped_keys in overlay to $new_ds
for my $escaped_key (@$escaped_keys) {
my ($actual_key) = ($escaped_key =~ /^=(=.*)/);
$new_ds->{$actual_key} =
overlay($new_ds->{$actual_key}, $overlay->{$escaped_key}, $conf);
}
return $new_ds;
} else {
# all scalars, blessed and non-HASH overlay elements are 'overwrite'
# (by default, you could intercept all and do other things...)
my $callback = $conf->{action_map}{overwrite};
die "No action 'overwrite' in action_map" unless $callback;
return $callback->($ds, $overlay, $conf);
}
confess "A return is missing somewhere";
}
=head2 overlay_all
$new_ds = overlay_all($old_ds, $overlay1, $overlay2, ...);
Apply several overlays to $old_ds, returning $new_ds as the result.
They are logically applied left to right, that is $overlay1,
then overlay2, etc. (Internally C<compose> is used, see next)
=cut
sub overlay_all {
my ($ds, @overlays) = @_;
return overlay($ds, compose(@overlays));
}
=head2 compose
$combined_overlay = compose($overlay1, $overlay2, ..);
Produce an overlay that has the combined effect of applying
$overlay1 then $overlay2, etc.
=cut
sub compose {
my (@overlays) = @_;
# rubbish dumb merger XXX
return { '=seq' => \@overlays };
}
=head2 combine_with
$combiner_sub = combine_with { $a && $b };
my $conf = { action_map => {
and => $combiner_sub
} };
my $new = overlay($this, $that, $conf);
Utility to build simple overlay actions. For example, the included
"or" is just:
combine_with { $a || $b};
$a is the old_ds parameter, $b is the overlay parameter.
@_ contains the rest of the arguments.
=cut
#$action_map{defor} = combine_with { $a // $b};
sub combine_with (&@) { ## no critic
my ($code) = shift;
return sub {
local ($a) = shift; # $old_ds
local ($b) = shift; # $overlay
return $code->(@_); # $conf (remainder of args in @_)
};
}
=head2 Actions
lib/Data/Overlay.pm view on Meta::CPAN
=item config
=cut
$action_map{config} = sub {
my ($old_ds, $overlay, $old_conf) = @_;
#my $new_conf = overlay($old_conf, $overlay->{conf}, $old_conf);
# do we really want a config here XXX?
my $new_conf = overlay($old_conf, $overlay->{conf}); # eat dogfood #1
# wrap all actions with debug if needed
if (!defined $old_conf->{debug}
&& $new_conf->{debug} ) {
# XXX overlay action_map, eat dogfood #2
my $old_action_map = $new_conf->{action_map};
my $new_action_map;
my @actions = keys %$old_action_map;
if ($new_conf->{debug_actions}) {
lib/Data/Overlay.pm view on Meta::CPAN
_wrap_debug($action, $old_action_map->{$action});
}
$new_conf->{action_map} = $new_action_map;
}
return overlay($old_ds, $overlay->{data}, $new_conf);
};
=item overwrite
"Overwrite" the old location with the value of the overwrite key.
This is the default action for non-HASH overlay elements.
(The actual action used in this implicit case and also
the explicit case is $conf->{action_map}{overwrite},
so it can be overriden).
You can also use C<overwrite> explicitly, to overlay an empty
hash (which would otherwise be treated as a keyless, no-op overlay):
overlay(undef, {}); # -> undef
overlay(undef, {'=overwrite'=>{}}); # -> {}
=cut
$action_map{overwrite} = sub {
my ($old_ds, $overlay, $conf) = @_;
return $overlay;
};
=item defaults
=cut
$action_map{defaults} = sub {
my ($old_ds, $overlay, $conf) = @_;
if ( _isreftype(HASH => $old_ds)
&& _isreftype(HASH => $overlay) ) {
my %new_ds = %$old_ds; # shallow copy
for (keys %$overlay) {
$new_ds{$_} //= $overlay->{$_};
}
return \%new_ds;
} else {
return $old_ds // $overlay; # only HASHes have defaults
}
};
=item delete
=cut
$action_map{delete} = sub {
my ($old_ds, $overlay, $conf) = @_;
if ( _isreftype(HASH => $old_ds)
&& _isreftype(HASH => $overlay)) {
# overlay is a set of keys to "delete"
my %new_ds = %$old_ds;
delete $new_ds{$_} for (keys %$old_ds);
return \%new_ds;
} elsif ( _isreftype(ARRAY => $old_ds)
&& _isreftype(ARRAY => $overlay)) {
# overlay is a list of indices to "delete"
my @new_ds = @$old_ds;
delete $new_ds[$_] for (@$old_ds);
return \@new_ds;
} else {
warn "Container mismatch (ew XXX)";
return overlay($old_ds, $overlay, $conf);
}
};
=item defor
Defined or (//) is used to combine the original and overlay
=cut
$action_map{defor} = combine_with { $a // $b};
lib/Data/Overlay.pm view on Meta::CPAN
=item push
=cut
$action_map{push} = sub {
my ($old_ds, $overlay) = @_;
# flatten 1 level of ARRAY
my @overlay_array = _isreftype(ARRAY => $overlay)
? @$overlay : $overlay;
if (_isreftype(ARRAY => $old_ds)) {
return [ @$old_ds, @overlay_array ];
} else {
return [ $old_ds, @overlay_array ]; # one elem array
}
};
=item unshift
=cut
$action_map{unshift} = sub {
my ($old_ds, $overlay) = @_;
# flatten 1 level of ARRAY
my @overlay_array = _isreftype(ARRAY => $overlay)
? @$overlay : $overlay;
if (_isreftype(ARRAY => $old_ds)) {
return [ @overlay_array, @$old_ds ];
} else {
return [ @overlay_array, $old_ds ]; # one elem array
}
};
=item pop
=cut
$action_map{pop} = sub {
my ($old_ds, $overlay) = @_;
if (_isreftype(ARRAY => $old_ds)) {
if (_isreftype(ARRAY => $overlay)) {
# if pop's arg is ARRAY, use it's size
# as the number of items to pop
# (for symmetry with push)
my $pop_size = @$overlay;
return [ @{$old_ds}[0..$#$old_ds-$pop_size] ];
} else {
return [ @{$old_ds}[0..$#$old_ds-1] ];
}
} else {
lib/Data/Overlay.pm view on Meta::CPAN
=item shift
=cut
$action_map{shift} = sub {
my ($old_ds, $overlay) = @_;
if (_isreftype(ARRAY => $old_ds)) {
if (_isreftype(ARRAY => $overlay)) {
# if pop's arg is ARRAY, use it's size
# as the number of items to pop
# (for symmetry with push)
my $shift_size = @$overlay;
return [ @{$old_ds}[$shift_size..$#$old_ds] ];
} else {
return [ @{$old_ds}[1..$#$old_ds] ];
}
} else {
lib/Data/Overlay.pm view on Meta::CPAN
}
=cut
$action_map{run} = sub {
my ($old_ds, $overlay) = @_;
return $overlay->{code}->($old_ds, @{ $overlay->{args} || [] });
};
=item foreach
Apply one overlay to all elements of an array or values of a hash
(or just a scalar). Often useful with =run if the overlay is
a function of the original value.
=cut
# XXX each with (k,v) or [i,...]
$action_map{foreach} = sub {
my ($old_ds, $overlay, $conf) = @_;
if (_isreftype(ARRAY => $old_ds)) {
return [
map { overlay($_, $overlay, $conf) } @$old_ds
];
} elsif (_isreftype(HASH => $old_ds)) {
return {
map {
$_ => overlay($old_ds->{$_}, $overlay, $conf)
} keys %$old_ds
};
} else {
return overlay($old_ds, $overlay, $conf);
}
};
=item seq
Apply in sequence an array of overlays.
=cut
$action_map{seq} = sub {
my ($old_ds, $overlay, $conf) = @_;
# XXX reftype $overlay
my $ds = $old_ds;
for my $ol (@$overlay) {
$ds = overlay($ds, $ol, $conf);
}
return $ds;
};
=back
=cut
for my $action (keys %action_map) {
# debuggable names for callbacks (not the used perl names)
subname "$action-overlay", $action_map{$action};
# XXX
warn "$action not in \@action_order"
if ! grep { $action eq $_ } @action_order;
}
sub _wrap_debug {
my ($action_name, $inner_sub) = @_;
my $s = subname "$action_name-debug", sub {
my ($old_ds, $overlay, $conf) = @_;
my $debug = max($conf->{debug},
( ref($conf->{debug_actions})
&& $conf->{debug_actions}{$action_name} ));
if ($debug) {
warn "Calling $action_name $inner_sub\n";
warn " with ", _dt($overlay), "\n" if $debug >= 1;
warn " conf ", _dt({map { "$_" } %$conf}), "\n" if $debug >= 2;
cluck " CALL STACK" if $debug >= 3;
}
my $result = $inner_sub->($old_ds, $overlay, $conf);
if ($debug) {
warn " Back from $action_name\n";
warn " got ", _dt($result), "\n" if $debug >= 2;
}
return $result;
lib/Data/Overlay.pm view on Meta::CPAN
+/-/*/++/--/x/%/**/./<</>>
| & ^ ~ masks boolean logic
conditionals? comparison?
deref?
invert apply inverted
swap overlay and ds roles
splitting one ds val into multiple new_ds?
regex matching and extraction
pack/unpack
const?
Objects?
lib/Data/Overlay.pm view on Meta::CPAN
Some made up use-cases.
=head2 Configuration Data Merging
overlay_all($defaults, $host_conf, $app_conf, $user_conf, $cmd_line_conf);
=head2 List of Undoable Edits
Use the memory sharing to keep a sequence of persistent data structures.
"Persistent" in the functional programming sense, you can
access (read-only) old and new versions.
=head2 Circular References in Overlays
There is no protection against reference cycles in overlays.
L<Devel::Cycle> or L<Data::Structure::Util> may help.
=head2 Unsharing Data with Clone
If you don't want any sharing of data between the result and
source or overlay, then use a clone.
Either L<Storable>'s dclone or L<Clone>
$new_clone = dclone(overlay($old, $overlay));
=head2 Escaping "=" Keys
Rmap
lib/Data/Overlay.pm view on Meta::CPAN
Uses special characters to indicate the action performed. Also permits
local config overrides and extensions.
=back
Potential overlay builders, modules that could be used to build
overlays for data:
=over
=item * L<CGI::Expand>
Build nested hashes from a flat path hash:
use CGI::Expand qw(expand_hash);
my $overlay = expand_hash({"a.b.c"=>1,"a.b.d"=>[2,3]})
# = {'a' => {'b' => {'c' => 1,'d' => [1,2,3]}}};
L<Hash::Flatten> also has an unflatten function.
=back
lib/Data/Overlay.pm view on Meta::CPAN
but there's nothing particularly concurrent about Data::Overlay.
Also, patches and operations have more context and are invertible.
=head1 KEYWORDS
Merge, edit, overlay, clone, modify, transform, memory sharing, COW,
operational transform, patch.
So an SEO expert walks into a bar, tavern, pub...
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
README
lib/Data/Pack.pm
t/00-compile.t
t/000-report-versions.t
t/01_misc.t
t/02_hash_overlay.t
t/author-critic.t
t/perlcriticrc
t/release-check-changes.t
t/release-dist-manifest.t
t/release-distmeta.t
view all matches for this distribution