view release on metacpan or search on metacpan
lib/DDG/Test/Spice.pm view on Meta::CPAN
alt_to_test('DDG::Spice::My::Spice', [qw(alt1 alt2 alt3)]);
This would check for the following:
callbacks 'ddg_spice_my_alt[123]'
paths '/js/spice/my/alt[123]/'
=head1 AUTHOR
DuckDuckGo <open@duckduckgo.com>
view all matches for this distribution
view release on metacpan or search on metacpan
demo/lib/DJabberd/Plugin/Demo.pm view on Meta::CPAN
### initialize a logger
our $logger = DJabberd::Log->get_logger();
### register our plugin. we don't need to do any actions now, but we're
### registering two hooks to be called on certain events. Hooks are implemented
### using callbacks. To see which hooks are available, read 'DJabberd::HookDocs'.
### To see how callbacks work, see 'DJabberd::Callback'.
sub register {
my($self, $vhost) = @_;
### when the client asks for the roster, call this hook first. This allows
### us to manipulate the roster before the client sees it.
demo/lib/DJabberd/Plugin/Demo.pm view on Meta::CPAN
### Update the roster to add the bot (as described in $ritem) to the
### client (as described in $jid). Will call callback $rs_cb when done.
$rs->addupdate_roster_item( $rs_cb, $jid, $ritem );
### callbacks have the possiblity to stop the callback chain from
### continuing, by either throwing an error or telling the callback
### mechanism it is done. In our case, we want the chain to continue.
### See DJabberd::HookDocs for details on this.
$cb->decline;
}
view all matches for this distribution
view release on metacpan or search on metacpan
sundown/examples/sundown.c view on Meta::CPAN
{
struct buf *ib, *ob;
int ret;
FILE *in = stdin;
struct sd_callbacks callbacks;
struct html_renderopt options;
struct sd_markdown *markdown;
/* opening the file if given from the command line */
if (argc > 1) {
sundown/examples/sundown.c view on Meta::CPAN
fclose(in);
/* performing markdown parsing */
ob = bufnew(OUTPUT_UNIT);
sdhtml_renderer(&callbacks, &options, 0);
markdown = sd_markdown_new(0, 16, &callbacks, &options);
sd_markdown_render(ob, ib->data, ib->size, markdown);
sd_markdown_free(markdown);
/* writing the result to stdout */
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DR/Tarantool/AsyncClient.pm view on Meta::CPAN
}
=head1 Worker methods
All methods accept callbacks which are invoked with the following arguments:
=over
=item status
view all matches for this distribution
view release on metacpan or search on metacpan
CAB/Queue/Server.pm view on Meta::CPAN
## $cli_or_undef = $qs->accept($timeout_secs)
## + accept incoming client connections with optional timeout
## + INHERITED from DTA::CAB::Socket
## $rc = $qs->handleClient($cli)
## $rc = $qs->handleClient($cli, %callbacks)
## + handle a single client request
## + INHERITED from DTA::CAB::Socket
##--------------------------------------------------------------
## Server Methods: Request Handling
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Daemon/Shutdown.pm view on Meta::CPAN
# Validate the config file
%params = validate_with(
params => \%params,
spec => {
config => {
callbacks => {
'File exists' => sub { -f shift }
},
default => '/etc/sdd.conf',
},
},
lib/Daemon/Shutdown.pm view on Meta::CPAN
%params = validate_with(
params => \%params,
spec => {
log_file => {
default => '/var/log/sdd.log',
callbacks => {
'Log file is writable' => sub {
my $filepath = shift;
if ( -f $filepath ) {
return -w $filepath;
} else {
lib/Daemon/Shutdown.pm view on Meta::CPAN
regex => qr/^[1|0]$/,
},
shutdown_binary => {
default => '/sbin/poweroff',
type => SCALAR,
callbacks => {
'Shutdown binary exists' => sub {
-x shift();
},
},
},
view all matches for this distribution
view release on metacpan or search on metacpan
- Documentation improvements. (debug-ito++)
- use Exporter in Daiku.pm instead of manually writing import(). (debug-ito++)
1.001 2014-05-11T12:39:01Z
- pass argv to merged task callbacks
(Shoichi Kaji)
- support multiple suffix rule
(Shoichi Kaji)
- support coredef src in suffix rule
(Songmu)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Daizu/Util.pm view on Meta::CPAN
my $parser = XML::LibXML->new;
$parser->expand_xinclude(1);
my @included_file;
my $input_callbacks = XML::LibXML::InputCallback->new;
$input_callbacks->register_callbacks([
\&_match_uri,
sub { _open_uri($db, $wc_id, \@included_file, @_) },
\&_read_uri,
\&_close_uri,
]);
$parser->input_callbacks($input_callbacks);
my $root = $doc->documentElement;
$root->setAttribute('xml:base' => 'daizu:///' . url_encode($path))
unless $root->hasAttribute('xml:base');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Async.pm view on Meta::CPAN
EV::loop
=head1 PROBLEMS
In the callbacks (for example of the timer in the C<SYNOPSIS>), you cannot use
many of the normal Dancer keywords such as template, redirect, etc. This is due
to Dancer accessing Dancer::SharedData, which is not available later on. If
anyone has a good idea on how to solve this problem, suggestions/patches are
very welcome.
view all matches for this distribution
view release on metacpan or search on metacpan
0.99_10 2016-02-06T09:36:21+01:00 (77f07bf => abeltje)
- (abeltje, Sat, 6 Feb 2016 09:36:21 +0100) Autocommit for distribution
Dancer::Plugin::RPC 0.99_10 (test)
- (Larion Garaczi, Tue, 22 Mar 2016 13:58:55 +0100) Handle unhandled
exceptions in callbacks
- Runtime exceptions in the 'callback' functions were not caught. Now
we
- handle them the same way as runtime exceptions in the actual
methods.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/SimpleCRUD.pm view on Meta::CPAN
##Return results as a downloaded file, instead of generating the HTML table.
return _return_downloadable_query($args, $sth, params->{format});
}
my @custom_callbacks = ();
for my $custom_col_spec (@{ $args->{custom_columns} || [] } ) {
push @custom_callbacks, {
column=>$custom_col_spec->{name},
transform=> ($custom_col_spec->{transform} or sub { return shift;}),
};
}
my $table = HTML::Table::FromDatabase->new(
-sth => $sth,
-border => 1,
-callbacks => [
{
column => 'actions',
transform => sub {
my $id = shift;
my $action_links;
lib/Dancer/Plugin/SimpleCRUD.pm view on Meta::CPAN
}
}
return $action_links;
},
},
@custom_callbacks,
],
-rename_headers => \%columns_sort_options,
-html => 'escape',
-class => $table_class,
);
view all matches for this distribution
view release on metacpan or search on metacpan
carton.lock view on Meta::CPAN
"version" : "1.1902"
},
"B::Hooks::OP::Check" : {
"dist" : "B-Hooks-OP-Check-0.19",
"mymeta" : {
"abstract" : "Wrap OP check callbacks",
"author" : [
"Florian Ragwitz <rafl@debian.org>"
],
"dynamic_config" : 0,
"generated_by" : "Module::Install version 1.01, CPAN::Meta::Converter version 2.120921",
view all matches for this distribution
view release on metacpan or search on metacpan
public/javascripts/typeahead/typeahead-0.11.1.bundle.js view on Meta::CPAN
if (!cb) {
return this;
}
types = types.split(splitter);
cb = context ? bindContext(cb, context) : cb;
this._callbacks = this._callbacks || {};
while (type = types.shift()) {
this._callbacks[type] = this._callbacks[type] || {
sync: [],
async: []
};
this._callbacks[type][method].push(cb);
}
return this;
}
function onAsync(types, cb, context) {
return on.call(this, "async", types, cb, context);
public/javascripts/typeahead/typeahead-0.11.1.bundle.js view on Meta::CPAN
function onSync(types, cb, context) {
return on.call(this, "sync", types, cb, context);
}
function off(types) {
var type;
if (!this._callbacks) {
return this;
}
types = types.split(splitter);
while (type = types.shift()) {
delete this._callbacks[type];
}
return this;
}
function trigger(types) {
var type, callbacks, args, syncFlush, asyncFlush;
if (!this._callbacks) {
return this;
}
types = types.split(splitter);
args = [].slice.call(arguments, 1);
while ((type = types.shift()) && (callbacks = this._callbacks[type])) {
syncFlush = getFlush(callbacks.sync, this, [ type ].concat(args));
asyncFlush = getFlush(callbacks.async, this, [ type ].concat(args));
syncFlush() && nextTick(asyncFlush);
}
return this;
}
function getFlush(callbacks, context, args) {
return flush;
function flush() {
var cancelled;
for (var i = 0, len = callbacks.length; !cancelled && i < len; i += 1) {
cancelled = callbacks[i].apply(context, args) === false;
}
return !cancelled;
}
}
function getNextTick() {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer.pm view on Meta::CPAN
if ( $options{'streaming'} ) {
# handle streaming
$resp->streamed( sub {
my ( $status, $headers ) = @_;
my %callbacks = defined $options{'callbacks'} ?
%{ $options{'callbacks'} } :
();
return sub {
my $respond = shift;
exists $callbacks{'override'}
and return $callbacks{'override'}->( $respond, $resp );
# get respond callback and set headers, get writer in return
my $writer = $respond->( [
$status,
$headers,
] );
# get content from original response
my $content = $resp->content;
exists $callbacks{'around'}
and return $callbacks{'around'}->( $writer, $content );
if ( ref $content ) {
my $bytes = $options{'bytes'} || '43008'; # 42K (dams)
my $buf;
while ( ( my $read = sysread $content, $buf, $bytes ) != 0 ) {
if ( exists $callbacks{'around_content'} ) {
$callbacks{'around_content'}->( $writer, $buf );
} else {
$writer->write($buf);
}
}
} else {
lib/Dancer.pm view on Meta::CPAN
get '/download/:file' => sub {
send_file( params->{file}, streaming => 1 );
}
You can control what happens using callbacks.
First, C<around_content> allows you to get the writer object and the chunk of
content read, and then decide what to do with each chunk:
get '/download/:file' => sub {
send_file(
params->{file},
streaming => 1,
callbacks => {
around_content => sub {
my ( $writer, $chunk ) = @_;
$writer->write("* $chunk");
},
},
lib/Dancer.pm view on Meta::CPAN
get '/download/:file' => sub {
send_file(
params->{file},
streaming => 1,
callbacks => {
around => sub {
my ( $writer, $content ) = @_;
# we know it's a text file, so we'll just stream
# line by line
lib/Dancer.pm view on Meta::CPAN
get '/download/:file' => sub {
send_file(
params->{file},
streaming => 1,
callbacks => {
override => sub {
my ( $respond, $response ) = @_;
my $writer = $respond->( [ $newstatus, $newheaders ] );
$writer->write("some line");
view all matches for this distribution
view release on metacpan or search on metacpan
[BUG FIXES]
* Incorrect call to user_password from app not plugin
(Andrew Beverly, GH #53).
* Avoid memory leaks in BUILD by passing weakened ref to plugin into
add_route callbacks (Peter Mottram).
* Call $app->session instead of $app->app->session in _post_login_route
(Peter Mottram).
[MISC]
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/JobScheduler/Client/TheSchwartz.pm view on Meta::CPAN
if ( $self->config->{'databases'} ) {
my $databases = $self->config->{'databases'};
foreach my $key ( keys %{$databases} ) {
my $database = $databases->{$key};
if ( $database->{'dbh_callback'} ) {
my $e = q{Invalid config. } . q{databases->%s has item dbh_callback; database specific callbacks not supported};
$log->errorf( $e, $key );
croak sprintf $e, $key;
}
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Multilang.pm view on Meta::CPAN
The default language that will be used when plugin can't guess desired one (or when desired one is not managed)
=item C<no_lang_prefix> (optional)
Do not add the language path to the route if it has this prefix. Useful for Google or Facebook authentication callbacks.
no_lang_prefix: /auth
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Swagger2.pm view on Meta::CPAN
=over
=item * C<url>: URL to passed to L<Swagger2> module
=item * C<controller_factory>: custom callback generator/finder that returns callbacks to routes
=item * C<validate_spec>: boolish value (default: true) telling if Swagger2 file shall be validated by official Swagger specification
=item * C<validate_requests>: boolish value (default: same as C<validate_spec>) telling if HTTP requests shall be validated by loaded specification (needs C<validate_spec> to be true)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/WebSocket.pm view on Meta::CPAN
=back
=head1 PLUGIN KEYWORDS
In the various callbacks, the connection object C<$conn>
is a L<Plack::App::WebSocket::Connection> object
augmented with the L<Dancer2::Plugin::WebSocket::Connection> role.
=head2 websocket_on_open sub { ... }
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Session/Cookie.pm view on Meta::CPAN
L<Plack::Middleware::Session::Cookie> -- MAC only
=item *
L<Plack::Middleware::Session::SerializedCookie> -- really just a framework and you provide the guts with callbacks
=item *
L<Dancer2::Core::Role::SessionFactory> -- documentation of the base package, some more attributes to configure the cookie
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Danga/Socket/AnyEvent.pm view on Meta::CPAN
# by default we keep running, unless a postloop callback (either per-object
# or global) cancels it
my $keep_running = 1;
# per-object post-loop-callbacks
for my $plc (values %PLCMap) {
$keep_running &&= $plc->(\%DescriptorMap, \%OtherFds);
}
# now we're at the very end, call callback if defined
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Danga/Socket/Callback.pm view on Meta::CPAN
Love the fact that Perlbal, Mogilefs, and friends all run fast because of
Danga::Socket, but despise it because you need to subclass it every time?
Well, here's a module for all you lazy people.
Danga::Socket::Callback is a thin wrapper arond Danga::Socket that allows
you to set callbacks to be called at various events. This allows you to
define multiple Danga::Socket-based sockets without defining multiple
classes:
my $first = Danga::Socket::Callback->new(
hadle => $sock1,
lib/Danga/Socket/Callback.pm view on Meta::CPAN
=head2 event_err
=head2 event_hup
Implements each method available from Danga::Socket. If the corresponding
callbacks are available, then calls the callback. Each callback receives
the Danga::Socket::Callback object.
For event_write, if no callback is available, then the default event_write
method from Danga::Socket is called.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Danga/Socket.pm view on Meta::CPAN
provides the basic framework for event-driven asynchronous IO,
designed to be fast. Danga::Socket is both a base class for objects,
and an event loop.
Callers subclass Danga::Socket. Danga::Socket's constructor registers
itself with the Danga::Socket event loop, and invokes callbacks on the
object for readability, writability, errors, and other conditions.
Because Danga::Socket uses the "fields" module, your subclasses must
too.
lib/Danga/Socket.pm view on Meta::CPAN
# by default we keep running, unless a postloop callback (either per-object
# or global) cancels it
my $keep_running = 1;
# per-object post-loop-callbacks
for my $plc (values %PLCMap) {
$keep_running &&= $plc->(\%DescriptorMap, \%OtherFds);
}
# now we're at the very end, call callback if defined
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dash.pm view on Meta::CPAN
default => sub { [] } );
has _layout => ( is => 'rw',
default => sub { {} } );
has _callbacks => ( is => 'rw',
default => sub { {} } );
has _rendered_scripts => ( is => 'rw',
default => "" );
lib/Dash.pm view on Meta::CPAN
# TODO check_callback
# TODO Callback map
my $output = $callback{Output};
my $callback_id = $self->_create_callback_id($output);
my $callbacks = $self->_callbacks;
$callbacks->{$callback_id} = \%callback;
return $self;
}
my $no_update;
my $internal_no_update = bless( \$no_update, 'Dash::Internal::NoUpdate' );
lib/Dash.pm view on Meta::CPAN
}
sub _dependencies {
my $self = shift;
my $dependencies = [];
for my $callback ( values %{ $self->_callbacks } ) {
my $rendered_callback = { clientside_function => JSON::null };
my $states = [];
for my $state ( @{ $callback->{State} } ) {
my $rendered_state = { id => $state->{component_id},
property => $state->{component_property}
lib/Dash.pm view on Meta::CPAN
sub _update_component {
my $self = shift;
my $request = shift;
if ( scalar( values %{ $self->_callbacks } ) > 0 ) {
my $callbacks = $self->_search_callback( $request->{'output'} );
if ( scalar @$callbacks > 1 ) {
die 'Not implemented multiple callbacks';
} elsif ( scalar @$callbacks == 1 ) {
my $callback = $callbacks->[0];
my @callback_arguments = ();
my $callback_context = {};
for my $callback_input ( @{ $callback->{Inputs} } ) {
my ( $component_id, $component_property ) = @{$callback_input}{qw(component_id component_property)};
for my $change_input ( @{ $request->{inputs} } ) {
lib/Dash.pm view on Meta::CPAN
} else {
return { response => "There is no matching callback" };
}
} else {
return { response => "There is no registered callbacks" };
}
return { response => "Internal error" };
}
sub _search_callback {
my $self = shift;
my $output = shift;
my $callbacks = $self->_callbacks;
my @matching_callbacks = ( $callbacks->{$output} );
return \@matching_callbacks;
}
sub _rendered_stylesheets {
return '';
}
lib/Dash.pm view on Meta::CPAN
in a callback will trigger that callback, and the output returned by the callback will update the property of
the component declared as output.
=back
So to make a Dash app you just need to setup the layout and the callbacks. The basic skeleton will be:
my $app = Dash->new(app_name => 'My Perl Dash App');
$app->layout(...);
$app->callback(...);
$app->run_server();
lib/Dash.pm view on Meta::CPAN
$app->layout(Div('This is a simple div', id => 'my-div'));
=head1 Callbacks
Callbacks are the reactive part of the web app. They listen to changes in properties of components and get fired by those changes.
The output of the callbacks can update properties for other componentes (or different properties for the same components) and
potentially firing other callbacks. So your app is "reacting" to changes. These properties that fire changes and the properties
that get updated are dependencies of the callback, they are the "links" between components and callbacks.
Every component that is expected to fire a callback must have a unique id property.
To define a callback is necessary at least:
=over 4
=item Inputs
The component property (or components properties) which fire the callback on every change. The values of this properties are inputs for the callbacks
=item Output
The component (or components) whose property (or properties) get updated
lib/Dash.pm view on Meta::CPAN
}
);
=head2 Dependencies
Dependencies "link" components and callbacks. Every callback dependency has the following attributes:
=over 4
=item component_id
lib/Dash.pm view on Meta::CPAN
=item * Main package and class for apps is Dash
=item * Component suites will use Perl package convention, I mean: dash_html_components will be Dash::Html::Components
=item * Instead of decorators we'll use plain old callbacks
=item * Callback context is available as the last parameter of the callback but without the response part
=item * Instead of Flask we'll be using L<Mojolicious> (Maybe in the future L<Dancer2>)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DashProfiler/Core.pm view on Meta::CPAN
A reference to a hash containing default formatting arguments for the profile_as_text() method.
=head3 extra_info
Can be used to attach any extra information to the profiler core object. That can be useful sometimes in callbacks.
=cut
sub new {
my ($class, $profile_name, $opt_params) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Annotated.pm view on Meta::CPAN
=cut
our $VERSION = '0.2';
my $callbacks = {
key_does_not_exist => sub {},
index_does_not_exist => sub {},
retrieve_index_from_non_array => sub {},
retrieve_key_from_non_hash => sub {},
};
lib/Data/Annotated.pm view on Meta::CPAN
=cut
sub cat_annotation {
my ($self, $data) = @_;
my $dp = Data::Path->new($data, $callbacks);
my @paths = grep { $dp->get($_) } keys(%$self);
return map { $self->get_annotation($_) } @paths;
}
=head2 get_annotation($path);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Beacon.pm view on Meta::CPAN
while ( $beacon->nextlink ) {
my ($source, $label, $description, $target) = $beacon->link;
...
}
Or by push parsing with handler callbacks:
my $beacon = beacon( $file );
$beacon->parse( 'link' => \link_handler );
$errors = $beacon->errors;
view all matches for this distribution
view release on metacpan or search on metacpan
Data::CGIForm - CGI Paramater Validation
========================================
Data::CGIForm is a library for managing and testing the data sent
from a CGI form. It provides filtering, testing callbacks, support
for multiple values, and other features.
See the POD documentation in CGIForm.pm for more information.
INSTALLATION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Censor.pm view on Meta::CPAN
sensitive_fields => [ qw(card_number password) ],
# Specify text to replace their values with:
replacement => '(Sensitive data hidden)',
# Or specify callbacks for each field name which return the "censored"
# value - in this case, masking a card number (PAN) to show only the
# last four digits:
replacement_callbacks => {
card_number => sub {
my $pan = shift;
return "x" x (length($pan) - 4) . substr($pan, -4, 4);
},
},
lib/Data/Censor.pm view on Meta::CPAN
against each key to see if it's considered sensitive.
=item replacement
The string to replace each value with. Any censoring callback provided in
C<replacement_callbacks> which matches this key will take precedence over this
straightforward value.
=item replacement_callbacks
A hashref of key => sub {...}, where each key is a column name to match, and the
coderef takes the uncensored value and returns the censored value, letting you
for instance mask a card number but leave the last 4 digits visible.
If you provide both C<replacement> and C<replacement_callbacks>, any callback
defined which matches the key being considered takes precedence.
=back
=cut
lib/Data/Censor.pm view on Meta::CPAN
cvv cvv2 ccv
)
};
}
if ( is_hashref $args{replacement_callbacks} ) {
$self->{replacement_callbacks} = $args{replacement_callbacks};
}
if ( exists $args{replacement} ) {
$self->{replacement} = $args{replacement};
} else {
$self->{replacement} = 'Hidden (looks potentially sensitive)';
lib/Data/Censor.pm view on Meta::CPAN
( $self->{is_sensitive_field}
&& $self->{is_sensitive_field}{ lc $key } )
or ( $self->{censor_regex} && $key =~ $self->{censor_regex} );
# OK, censor this
if ( $self->{replacement_callbacks}{ lc $key } ) {
$data->{$key} = $self->{replacement_callbacks}{ lc $key }->(
$data->{$key}
);
$censored++;
} else {
$data->{$key} = $self->{replacement};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Chronicle.pm view on Meta::CPAN
$subscriber->subscribe("category1", "name2", sub { print 'Hello World' });
=head2 L<Data::Chronicle::Subscriber/unsubscribe>
Given a category, name, clears the callbacks associated with the specified category and name.
$subscriber->unsubscribe("category1", "name2");
=head1 EXAMPLES
view all matches for this distribution