view release on metacpan or search on metacpan
lib/BusyBird/Filter.pm view on Meta::CPAN
=back
=head1 EXPORTABLE FUNCTIONS
You can import any of the functions below. None of them is exported by default.
Import C<":all"> to import all functions at once.
=head2 $filter = filter_each($func)
Creates a synchronous status filter that modifies each of the statuses destructively.
C<$func> is a subroutine reference that takes a single status.
For each status, C<$func> is called like
$func->($status)
C<$func> is supposed to modify the given C<$status> destructively.
The result of the C<$filter> is the list of modified statuses.
Return value from C<$func> is ignored.
=head2 $filter = filter_map($func)
Creates a synchronous status filter that maps each of the statuses.
This is similar to Perl's built-in C<map()> function.
C<$func> is a subroutine reference that takes a single status.
For each status, C<$func> is called like
@mapped_statuses = $func->($status)
C<$func> is supposed to return a list of statuses.
The result of the C<$filter> is all statuses collected from the C<$func>.
Note that the C<$status> given to C<$func> is a deep clone of the original status.
Even if you modify C<$status> in C<$func>, the original status is intact.
=head2 $filter = filter_grep($func)
Creates a synchronous status filter that picks up statuses by C<$func>
This is simalar to Perl's built-in C<grep()> function.
C<$func> is a subroutine reference that is called for each input status.
C<$func> is called in scalar context as in:
$result = $func->($status)
If C<$result> is true, that C<$status> is passed to the next.
If C<$result> is false, the C<$status> is filtered out.
lib/BusyBird/Filter/Twitter.pm view on Meta::CPAN
This results in double HTML-escapes.
The transformation changes the status's text length.
C<"indices"> fields in the status's L<Twitter Entities|https://dev.twitter.com/docs/platform-objects/entities> are
adjusted appropriately.
The transformation is applied recursively to the status's C<retweeted_status>, if any.
=head1 :filter TAG FUNCTIONS
These functions generate a synchronous status filter corresponding to the C<trans_twitter_*> functions.
All filters are non-destructive. That is, they won't modify input statuses. Transformation is done to their clones.
=head2 $filter = filter_twitter_all([$api_url])
=head2 $filter = filter_twitter_search_status()
=head2 $filter = filter_twitter_status_id([$api_url])
=head2 $filter = filter_twitter_unescape()
lib/BusyBird/Manual/Tutorial.pod view on Meta::CPAN
=back
After that, you can see the imported feed items (in this case, Perl modules recently uploaded) on L<BusyBird>.
Try repeating the command above.
You will see that L<BusyBird> only accepts the new statuses that are not yet in L<BusyBird>'s timeline.
In a L<BusyBird> timeline, all statuses must have unique C<id> field.
If you input a status that is already in the timeline, that status is ignored.
This means you can repeat the above command without worrying about duplicate statuses.
Register the command with C<cron>, then the L<BusyBird> timeline is automatically synchronized to
the latest state of the feed.
=head2 Import Statuses from Twitter
Next, let's import statuses (tweets) from L<Twitter|https://twitter.com/> and view them on L<BusyBird>.
That's a bit more tricky than importing feeds because it requires authentication.
To import tweets from Twitter via its API, you have to get the B<tokens> first. Here is how to get the tokens.
lib/BusyBird/StatusStorage.pm view on Meta::CPAN
=item C<timeline> => TIMELINE_NAME (mandatory)
Specifies the name of the timeline.
If the name includes Unicode characters, it must be a character string (decoded string), not a binary string (encoded string).
=back
These methods are all in callback-style, that is,
the results are not returned but given to the callback functions.
This allows for both synchronous and asynchronous implementations.
=head1 GUIDELINE
This section describes guideline of the interface.
Implementations are recommended to follow the guideline, but they are
allowed not to follow it if their own rule is clearly documented.
lib/BusyBird/StatusStorage/Memory.pm view on Meta::CPAN
This module is an implementation of L<BusyBird::StatusStorage>.
This storage stores all statuses in the process memory.
The stored statuses can be saved to a file in JSON format.
The saved statuses can be loaded from the file.
This storage is rather for testing purposes.
If you want a light-weight in-memory status storage,
I recommend L<BusyBird::StatusStorage::SQLite>.
This storage is synchronous, i.e., all operations block the thread
and the callback is called before the method returns.
This module uses L<BusyBird::Log> for logging.
=head1 CAVEATS
=over
=item *
lib/BusyBird/StatusStorage/SQLite.pm view on Meta::CPAN
busybird->set_config(
default_status_storage => $storage
);
=head1 DESCRIPTION
This is an implementation of L<BusyBird::StatusStorage> interface.
It stores statuses in an SQLite database.
This storage is synchronous, i.e., all operations block the thread
and the callback is called before the method returns.
=head1 CLASS METHOD
=head2 $storage = BusyBird::StatusStorage::SQLite->new(%args)
The constructor.
Fields in C<%args> are:
lib/BusyBird/Timeline.pm view on Meta::CPAN
A timeline's statuses are actually saved in a L<BusyBird::StatusStorage> object.
When you create a timeline via C<new()> method, you have to specify a L<BusyBird::StatusStorage> object explicitly.
=head2 Callback-Style Methods
Some methods of L<BusyBird::Timeline> are callback-style, that is,
their results are not returned but given to the callback function you specify.
It depends on the underlying L<BusyBird::StatusStorage> object
whether the callback-style methods are synchronous or asynchronous.
L<BusyBird::StatusStorage::SQLite>, for example, is synchronous.
If the status storage is synchronous, the callback is always called before the method returns.
If the status storage is asynchronous, it is possible for the method to return without calling the callback.
The callback will be called at a certain point later.
To handle callback-style methods, I recommend C<future_of()> function in L<BusyBird::Util>.
C<future_of()> function transforms callback-style methods into Future-style methods.
=head1 CLASS METHODS
=head2 $timeline = BusyBird::Timeline->new(%args)
Creates a new timeline.
lib/BusyBird/Timeline.pm view on Meta::CPAN
In failure, C<$error> is a truthy value describing the error.
=back
=head2 $timeline->add_filter($filter, [$is_async])
Add a status filter to the C<$timeline>.
C<$filter> is a subroutine reference that is called upon added statuses.
C<$is_async> specifies whether the C<$filter> is synchronous or asynchronous.
L<BusyBird::Filter> may help you create common status filters.
B<< Synchronous Filter >>
If C<$is_async> is false, C<$filter> is a synchronous filter. It is called like
$result_arrayref = $filter->($arrayref_of_statuses);
where C<$arrayref_of_statuses> is an array-ref of statuses that is injected to the filter.
C<$filter> must return an array-ref of statuses (C<$result_arrayref>), which is going to be passed to the next filter
(or the status storage if there is no next filter).
C<$result_arrayref> may be either C<$arrayref_of_statuses> or a new array-ref.
If C<$filter> returns anything other than an array-ref,
a warning is logged and C<$arrayref_of_statuses> is passed to the next.
B<< Asynchronous Filter >>
If C<$is_async> is true, C<$filter> is a asynchronous filter. It is called like
$filter->($arrayref_of_statuses, $done);
where C<$done> is a subroutine reference that C<$filter> is supposed to call when it completes its task.
C<$filter> must pass the result array-ref of statuses to the C<$done> callback.
$done->($result_arrayref)
B<< Examples >>
## Synchronous filter
$timeline->add_filter(sub {
my ($statuses) = @_;
return [ grep { some_predicate($_) } @$statuses ];
});
## Asynchronous filter
$timeline->add_filter(sub {
my ($statuses, $done) = @_;
some_async_processing(
statuses => $statuses,
callback => sub {
my ($results) = @_;
$done->($results);
}
);
}, 1);
=head2 $timeline->add_filter_async($filter)
Add an asynchronous status filter. This is equivalent to C<< $timeline->add_filter($filter, 1) >>.
=head2 $timeline->set_config($key1 => $value1, $key2 => $value2, ...)
Sets config parameters to the C<$timeline>.
C<$key1>, C<$key2>, ... are the keys for the config parameters, and
C<$value1>, C<$value2>, ... are the values for them.
See L<BusyBird::Manual::Config> for the list of config parameters.
share/www/static/jquery.js view on Meta::CPAN
jQuery.ready.promise = function( obj ) {
if ( !readyList ) {
readyList = jQuery.Deferred();
// Catch cases where $(document).ready() is called after the browser event has already occurred.
// we once tried to use readyState "interactive" here, but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( jQuery.ready );
// Standards-based browsers support DOMContentLoaded
} else if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", completed, false );
share/www/static/jquery.js view on Meta::CPAN
}
return markFunction(function( seed, results, context, xml ) {
var temp, i, elem,
preMap = [],
postMap = [],
preexisting = results.length,
// Get initial elements from seed or context
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
// Prefilter to get matcher input, preserving a map for seed-results synchronization
matcherIn = preFilter && ( seed || !selector ) ?
condense( elems, preMap, preFilter, context, xml ) :
elems,
matcherOut = matcher ?
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
// ...intermediate processing is necessary
[] :
share/www/static/jquery.js view on Meta::CPAN
i = matcherOut.length;
while ( i-- ) {
if ( (elem = matcherOut[i]) ) {
// Restore matcherIn since elem is not yet a final match
temp.push( (matcherIn[i] = elem) );
}
}
postFinder( null, (matcherOut = []), temp, xml );
}
// Move matched elements from seed to results to keep them synchronized
i = matcherOut.length;
while ( i-- ) {
if ( (elem = matcherOut[i]) &&
(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
seed[temp] = !(results[temp] = elem);
}
}
}
share/www/static/jquery.js view on Meta::CPAN
tween.unit = unit;
tween.start = start;
// If a +=/-= token was provided, we're doing a relative animation
tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
}
return tween;
}]
};
// Animations created synchronously will run synchronously
function createFxNow() {
setTimeout(function() {
fxNow = undefined;
});
return ( fxNow = jQuery.now() );
}
function createTweens( animation, props ) {
jQuery.each( props, function( prop, value ) {
var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
share/www/static/q.js view on Meta::CPAN
// If the object is already a Promise, return it directly. This enables
// the resolve function to both be used to created references from objects,
// but to tolerably coerce non-promises to promises.
if (isPromise(value)) {
return value;
}
// In order to break infinite recursion or loops between `then` and
// `resolve`, it is necessary to attempt to extract fulfilled values
// out of foreign promise implementations before attempting to wrap
// them as unresolved promises. It is my hope that other
// implementations will implement `valueOf` to synchronously extract
// the fulfillment value from their fulfilled promises. If the
// other promise library does not implement `valueOf`, the
// implementations on primordial prototypes are harmless.
value = valueOf(value);
// assimilate thenables, CommonJS/Promises/A+
if (isPromiseAlike(value)) {
return coerce(value);
} else {
return fulfill(value);
}
share/www/static/q.js view on Meta::CPAN
function spread(promise, fulfilled, rejected) {
return when(promise, function (valuesOrPromises) {
return all(valuesOrPromises).then(function (values) {
return fulfilled.apply(void 0, values);
}, rejected);
}, rejected);
}
/**
* The async function is a decorator for generator functions, turning
* them into asynchronous generators. This presently only works in
* Firefox/Spidermonkey, however, this code does not cause syntax
* errors in older engines. This code should continue to work and
* will in fact improve over time as the language improves.
*
* Decorates a generator function such that:
* - it may yield promises
* - execution will continue when that promise is fulfilled
* - the value of the yield expression will be the fulfilled value
* - it returns a promise for the return value (when the generator
* stops iterating)
share/www/static/q.js view on Meta::CPAN
* - if an error is thrown in the generator, it propagates through
* every following yield until it is caught, or until it escapes
* the generator function altogether, and is translated into a
* rejection for the promise returned by the decorated generator.
* - in present implementations of generators, when a generator
* function is complete, it throws ``StopIteration``, ``return`` is
* a syntax error in the presence of ``yield``, so there is no
* observable return value. There is a proposal[1] to add support
* for ``return``, which would permit the value to be carried by a
* ``StopIteration`` instance, in which case it would fulfill the
* promise returned by the asynchronous generator. This can be
* emulated today by throwing StopIteration explicitly with a value
* property.
*
* [1]: http://wiki.ecmascript.org/doku.php?id=strawman:async_functions#reference_implementation
*
*/
Q.async = async;
function async(makeGenerator) {
return function () {
// when verb is "send", arg is a value
share/www/static/q.js view on Meta::CPAN
return when(result, callback, errback);
}
var generator = makeGenerator.apply(this, arguments);
var callback = continuer.bind(continuer, "send");
var errback = continuer.bind(continuer, "throw");
return callback();
};
}
/**
* Throws a ReturnValue exception to stop an asynchronous generator.
* Only useful presently in Firefox/SpiderMonkey since generators are
* implemented.
* @param value the return value for the surrounding generator
* @throws ReturnValue exception with the value.
* @example
* Q.async(function () {
* var foo = yield getFooPromise();
* var bar = yield getBarPromise();
* Q.return(foo + bar);
* })
t/testlib/StatusStorage/AEDelayed.pm view on Meta::CPAN
1;
=pod
=head1 NAME
testlib::StatusStorage::AEDelayed - StatusStorage wrapper for delayed operation based on AnyEvent
=head1 DESCRIPTION
This is a StatusStorage wrapper just for testing asynchronous operations.
=head1 CLASS METHODS
=head2 $storage = testlib::StatusStorage::AEDelayed->new(%args)
C<%args> includes:
=over
=item C<backend> => STATUS_STORAGE
xt/js/qunit.js view on Meta::CPAN
QUnit.reset();
config.current = undefined;
},
queue: function() {
var bad,
test = this;
synchronize(function() {
test.init();
});
function run() {
// each of these can by async
synchronize(function() {
test.setup();
});
synchronize(function() {
test.run();
});
synchronize(function() {
test.teardown();
});
synchronize(function() {
test.finish();
});
}
// `bad` initialized at top of scope
// defer when previous test run passed, if storage is available
bad = QUnit.config.reorder && defined.sessionStorage &&
+sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName );
if ( bad ) {
run();
} else {
synchronize( run, true );
}
}
};
// Root QUnit object.
// `QUnit` initialized at top of scope
QUnit = {
// call on start of module test to prepend name to all tests
module: function( name, testEnvironment ) {
xt/js/qunit.js view on Meta::CPAN
case '<':
return '<';
case '>':
return '>';
case '&':
return '&';
}
});
}
function synchronize( callback, last ) {
config.queue.push( callback );
if ( config.autorun && !config.blocking ) {
process( last );
}
}
function process( last ) {
function next() {
process( last );
xt/js/sinon.js view on Meta::CPAN
this.callArgAts.push(-1);
this.callbackArguments.push(slice.call(arguments, 2));
this.callbackContexts.push(context);
this.callArgProps.push(prop);
return this;
}
};
// create asynchronous versions of callsArg* and yields* methods
for (var method in proto) {
// need to avoid creating anotherasync versions of the newly added async methods
if (proto.hasOwnProperty(method) &&
method.match(/^(callsArg|yields|thenYields$)/) &&
!method.match(/Async/)) {
proto[method + 'Async'] = (function (syncFnName) {
return function () {
this.callbackAsync = true;
return this[syncFnName].apply(this, arguments);
};
xt/js/sinon.js view on Meta::CPAN
}
/**
* @depend fake_xml_http_request.js
*/
/*jslint eqeqeq: false, onevar: false, regexp: false, plusplus: false*/
/*global module, require, window*/
/**
* The Sinon "server" mimics a web server that receives requests from
* sinon.FakeXMLHttpRequest and provides an API to respond to those requests,
* both synchronously and asynchronously. To respond synchronuously, canned
* answers have to be provided upfront.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
* Copyright (c) 2010-2013 Christian Johansen
*/
if (typeof sinon == "undefined") {
var sinon = {};