The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Gantry::Utils::CRON - a way to call a controller's method from a CRON script

SYNOPSIS

  use strict; use warnings;

  use Gantry::Utils::CRON;

  my $cron = Gantry::Utils::CRON->new( {
    controller      => 'Apps::RR::InvoiceMunger::Batch',
    conf_instance   => 'apps_rr_invoicemunger_dev_prod',
    conf_file       => '/etc/gantry.conf',         # optional
    template_engine => 'TT',                       # optional
    namespace       => 'Apps::RR::InvoiceMunger',  # optional
  } );

  # alternative setters
  $cron->set_controller( 'Apps::RR::InvoiceMunger::Batch' );
  $cron->set_conf_instance( 'invoice_munger_prod' );
  $cron->set_conf_file( '/etc/gantry.conf' );
  $cron->set_template_engine( 'TT' );    
  $cron->set_namespace( 'mynamespace' );

  $cron->run( {
    method => 'do_process_files',          # do_* required
    args   => [ '1', '2' ],                # optional
    params => { confirm => 1, test => 3 }  # optional
    type   => 'post'                       # or 'get' -- optional 
  } );

  print STDERR $cron->status();  
  print STDERR $cron->content();

DESCRIPTION

This module is a utility to run a Gantry do_ method from a CRON script

METHODS

new( {} );

Standard constructor, call it first.

Required

    controller      - Gantry controller that contains the do_ method
    conf_instance   - Gantry conf instance name

Optional

    conf_file       - defaults to '/etc/gantry.conf'
    template_engine - defaults to 'TT'
    namespace       
run( {} )

This method executes the defined controller's do_ method.

Accepts

  method - the do_ method
  args   - array of args to be passed to the method
  params - hashref of params to be passed to method
  type   - 'get' or 'post' defaults to 'post' 

Returns

  status  - page status code
  content - plain-text version of method's returned content
        
set_content

setter for the returned content

content

getter for the returned content

set_status

setter for the returned status

status

getter for the returned status

set_controller

setter for controller

controller

getter for controller

set_conf_instance

setter for the Gantry conf_instance

conf_instance

getter for the Gantry conf_instance

set_conf_file

setter for the Gantry conf_file.

conf_file

getter for the Gantry conf_file. Defaults to /etc/gantry.conf

SEE ALSO

Gantry(3)

LIMITATIONS

This module depends on Gantry(3), HTML::TreeBuilder, HTML::FormatText

AUTHOR

Tim Keefer <tim@timkeefer.com>

COPYRIGHT and LICENSE

Copyright (c) 2007, Tim Keefer.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.