Changeset 574


Ignore:
Timestamp:
Feb 15, 2011, 6:53:53 PM (10 years ago)
Author:
zerodeux
Message:

Starting BearMail::Backend spec (at least), POD and new() bootstrapped - see #22

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bearmail/lib/BearMail/Backend.pm

    r519 r574  
    11package BearMail::Backend;
    22
    3 # Copyright (C) 2009 Bearstech - http://bearstech.com/
    4 #
    5 # This program is free software: you can redistribute it and/or modify
    6 # it under the terms of the GNU General Public License as published by
    7 # the Free Software Foundation, either version 3 of the License, or
    8 # (at your option) any later version.
    9 #
    10 # This program is distributed in the hope that it will be useful,
    11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13 # GNU General Public License for more details.
    14 #
    15 # You should have received a copy of the GNU General Public License
    16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     3=pod
    174
    18 use BearMail::Backend::Files;
     5=head1 NAME
    196
    20 # Should be selected by some config file
    21 sub backend {
    22   my $backend = shift;
     7BearMail::Backend - Bearmail core class
    238
    24   if ($backend eq 'Files') {
    25     return BearMail::Backend::Files->new(mailmap => shift @_);
    26   }
    279
    28   die "Unknown backend '$backend', check or set the 'backend' param in your bearmail.conf file";
    29 }
     10=head1 SYNOPSIS
     11
     12    use BearMail::Backend;
     13   
     14    my $bb = BearMail::Backend->new();
     15    $bb->login('root');
     16   
     17    my @domains = $bb->get_domains(search => '*bear*', range => [0, 9]);
     18    my @account = $bb->get_account(search => '*@bearstech.com', range => [30, 39]);
     19
     20    ...
     21
     22
     23=head1 DESCRIPTION
     24
     25C<BearMail::Backend> is at the core of the Bearmail infrastructure. It connects
     26to whatever 'backend' implements your email services and let you query and
     27configure it.
     28
     29For instance C<BearMail::Backend::Files> can configure a Postfix+Dovecot setup
     30with only the help of the filesystem. It works and scales very well up to
     31a few thousands accounts, and is adminsys friendly (you can version control
     32everything, trivially analyze, backup and fix things, etc.)
     33
     34For large scale and stable behaviour wrt. massive end users hitting the web
     35interface, you might prefer the C<BearMail::Backend::SQL> interface.
     36
     37TODO: describe account, targets, autorization model.
     38
     39
     40=head1 METHODS
     41
     42=head2 new
     43
     44The constructor C<new> connects to an existing backend. It will first search
     45for a global configuration file (see C<BearMail::Config>) and use its
     46content to select a type of backend and optionnally configure it.
     47
     48    my $bb = BearMail::Backend->new(
     49        config  => BearMail::Config->new->load('mymail.cfg'),
     50        backend => BearMail::Backend::Files->new
     51    );
     52
     53Optionnal parameters are :
     54
     55=item * config
     56
     57C<BearMail::Backend> will create a C<BearMail::Config> object with no specific
     58parameters. If you want to provide a different configuration (eg. load the
     59configuration from a different file than the one hardwired in
     60C<BearMail::Config>), you may provide your own config object here.
     61
     62You may also pass an undef value; in this case you will have to explictly
     63create other needed ressources for the backend.
     64
     65=item * backend
     66
     67Normally C<BearMail::Backend> will select and configure a backend using the
     68'backend' configuration parameter. If you have no configuration or want
     69to explicitly pass the backend, provide a C<BearMail::Backend> here.
     70
     71=back
     72
     73If the backend initialization failed for some reason, it will carp and
     74this constructor will return C<undef>.
     75
     76
     77=head1 SUPPORT
     78
     79Bugs should be reported via the Trac tool at
     80
     81L<http://forge.bearstech.com/trac/newticket>
     82
     83=head1 AUTHORS
     84
     85=head1 SEE ALSO
     86
     87L<BearMail>
     88
     89=head1 COPYRIGHT
     90
     91Copyright (C) 2009,2010 Bearstech - http://bearstech.com/
     92
     93This program is free software: you can redistribute it and/or modify
     94it under the terms of the GNU General Public License as published by
     95the Free Software Foundation, either version 3 of the License, or
     96(at your option) any later version.
     97
     98This program is distributed in the hope that it will be useful,
     99but WITHOUT ANY WARRANTY; without even the implied warranty of
     100MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     101GNU General Public License for more details.
     102
     103You should have received a copy of the GNU General Public License
     104along with this program.  If not, see <http://www.gnu.org/licenses/>.
     105
     106=cut
     107
    30108
    311091;
Note: See TracChangeset for help on using the changeset viewer.