Activator
view release on metacpan or search on metacpan
lib/Activator/DB.pm view on Meta::CPAN
816817818819820821822823824825826827828829830831832833834835836
reconn_att: <
int
>
# attempt reconnects this many times. default: 3
reconn_sleep: <
int
>
# initial sleep seconds between reconnect attempts.
# doubles every attempt. default: 1
attr:
# connection attributes. Only AutoCommit at this time
AutoCommit: 0/1
# default: 1
## You must define at least one connection alias
connections:
<conn_alias>:
user: <user>
pass: <password>
dsn:
'<DSN>'
# MySql Example: DBI:mysql:<DBNAME>:<DBHOST>
# PostgreSQL Example: DBI:Pg:dbname=<DBNAME>
# see: perldoc DBI, perldoc DBD::Pg, perldoc DBD::mysql
# for descriptions of valid DSNs
## These attributes and config are all optional, and use the default from above
attr:
AutoCommit: 0/1
config:
debug: 0/1
# only affects this connection
lib/Activator/Emailer.pm view on Meta::CPAN
6162636465666768697071727374757677787980
From
=>
'no-reply@test.com'
,
To
=>
'person@test.com'
,
Cc
=>
'other@test.com, other2@test.com'
Subject
=>
'Test Subject'
,
html_header
=>
'/path/to/html_header.tt'
,
html_body
=>
'/path/to/html_body.tt'
,
html_footer
=>
'/path/to/html_footer.tt'
,
email_wrap
=>
'/path/to/email/wrapper/template'
,
mailer_type
=>
'Gmail'
,
mailer_args
=> [
username
=>
'user@gmail.com'
,
password
=>
'123456'
],
);
$mailer
->attach(
Type
=>
'application/pdf'
,
Path
=>
'path/to/doc.pdf'
,
Filename
=>
'invoice.pdf'
,
Disposition
=>
'attachment'
$mailer
->
send
(
$tt_vars
);
The
next
section shows how to simplify this.
lib/Activator/Emailer.pm view on Meta::CPAN
84858687888990919293949596979899100101102103104As is seen in the previous section, a lot of information is needed to
send
an email. Fortunately, most of the information is reusable. You
can utilize L<Activator::Registry> to simplify creation of emails:
'Activator::Registry'
:
'Activator::Emailer'
:
From: noreply
@domain
.com
mailer_type: Gmail
# any of the send methods Email::Send supports
mailer_args:
# any of the args required by your Email::Send::<TYPE>
- username: <username>
- password: <password>
html_header: /fully/qualified/path/to/header/tt/template
html_footer: relative/path/to/footer/tt/template
html_body: relative/path/to/body/tt/template
email_wrap: /path/to/email/wrapper/template
tt_options:
INCLUDE_PATH: /path/to/tt/templates
In the simplist case, you can now
send
as such:
my
$mailer
= Activator::Emailer->new(
1011121314151617181920212223242526272829303132
$ENV
{ACT_REG_YAML_FILE} ||=
"$ENV{PWD}/t/data/DB-test.yml"
;
}
if
( ! (
$ENV
{ACT_DB_TEST_ENGINE} && (
(
$ENV
{ACT_DB_TEST_ENGINE} eq
'mysql'
&&
$ENV
{ACT_DB_TEST_USER} &&
$ENV
{ACT_DB_TEST_PASSWORD} ) ||
(
$ENV
{ACT_DB_TEST_ENGINE} eq
'Pg'
&&
$ENV
{ACT_DB_TEST_USER} ) ) ) ) {
plan
skip_all
=>
q{
TO ENABLE Activator::DB tests you must set some environment variables as such:
a) set ACT_DB_TEST_ENGINE to "mysql", then set ACT_DB_TEST_USER
and ACT_DB_TEST_PASSWORD to user/password that can 'create database'
OR
b) set ACT_DB_TEST_ENGINE to "Pg", then set ACT_DB_TEST_USER
to a user that has passwordless access to psql and can 'create database'}
}
else
{
plan
tests
=> 68;
}
use
Activator::DB;
use
Activator::Registry;
use
Activator::Exception;
my
(
$dbh
,
$db
,
$id
,
$res
,
@row
,
$rowref
,
$err
);
( run in 0.437 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )