Activator

 view release on metacpan or  search on metacpan

lib/Activator/DB.pm  view on Meta::CPAN

816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
      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

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
     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

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
As 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(

t/DB.t  view on Meta::CPAN

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    $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;
}
 
my ($dbh, $db, $id, $res, @row, $rowref, $err);



( run in 0.437 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )