#!/perl
for
my
$lib
(
'Maildir::Lite'
,
'MIME::Entity'
,
'Wubot::Logger'
,
'Wubot::Reactor::Maildir'
) {
eval
"use $lib"
;
plan
skip_all
=>
"Failed to load $lib for this test case"
if
$@;
}
plan
'no_plan'
;
my
$tempdir
= tempdir(
"/tmp/tmpdir-XXXXXXXXXX"
,
CLEANUP
=> 1 );
ok(
my
$maildir
= Wubot::Reactor::Maildir->new(),
"Creating new maildir reactor object"
);
{
my
$testmessage1
= {
body
=>
'this is the test body'
,
key
=>
'TestCase-test1'
,
lastupdate
=>
time
- 60*60*24,
plugin
=>
'Wubot::Plugin::RSS'
,
subject
=>
'this is the subject'
,
};
ok(
$maildir
->react(
$testmessage1
, {
path
=>
$tempdir
} ),
"Delivering first test message to Maildir"
);
}
{
my
$body
=
<<'BODY';
<img
Partly cloudy. Isolated showers ending. Patchy fog
developing. Lows around 30. Southeast wind to 10 mph.
<br />
<a
BODY
my
$testmessage1
= {
body
=>
$body
,
key
=>
'TestCase-test1'
,
lastupdate
=>
time
- 60*60*24,
plugin
=>
'Wubot::Plugin::RSS'
,
subject
=>
'this is the subject'
,
};
ok(
$maildir
->react(
$testmessage1
, {
path
=>
$tempdir
} ),
"Delivering first test message to Maildir"
);
}
{
my
$body
=
<<'BODY';
time taken by requests, and last week I found myself looking for the same kind
of profiling ability for memory usage. A quick look around made me discover
exactly what I'm looking for. So... say <em>hi</em> to <code>Catalyst::Plugin::MemoryUsage</code>. </p>
<p>The plugin is fairly simple, and (or so I hope) provides a good example of how
plugins can wiggle themselves at the different points of a request's
lifecycle. </p>
<h2>Writing the Plugin</h2>
<p>This plugin is all about capturing memory usage. To do that, I decided
<code>memory_usage</code> attribute to the application's context object:</p>
<pre class="brush: Perl">
package Catalyst::Plugin::MemoryUsage;
use strict;
use warnings;
use namespace::autoclean;
use Moose::Role;
use Memory::Usage;
has memory_usage => (
is => 'rw',
default => sub { Memory::Usage->new },
);
</pre>
<p>Behavior-wise, I wanted to mirror what the time profiler
already does: sets a baseline when the request begins, records a milestone
for each private action that is hit, and reports the results when the
processing of the request is done. </p>
BODY
my
$testmessage1
= {
body
=>
$body
,
key
=>
'TestCase-test1'
,
lastupdate
=>
time
- 60*60*24,
plugin
=>
'Wubot::Plugin::RSS'
,
subject
=>
'this is the subject'
,
};
ok(
$maildir
->react(
$testmessage1
, {
path
=>
$tempdir
} ),
"Delivering first test message to Maildir"
);
}