Module: Itrp::Export::Monitor

Includes:
GemConfig::Base
Defined in:
lib/itrp/export/monitor.rb,
lib/itrp/export/monitor/mail.rb,
lib/itrp/export/monitor/service.rb,
lib/itrp/export/monitor/version.rb,
lib/itrp/export/monitor/exchange.rb

Overview

Configuration for ITRP Export Monitor:

Itrp::Export::Monitor.configure do |export|
  export.name           = 'people_export'
  export.root           = File.expand_path('../exports', __FILE__)
  export.id             = 8713
  export.to             = "#{export.root}/people"
  export.imap_user_name = '[email protected]'
  export.imap_password  = 'secret'
  ...
end

Start the ITRP Export Monitor:

Itrp::Export::Monitor.run

All options available:

- logger:         The Ruby Logger instance, default: Logger.new(STDOUT)
- daemonize:      Set to +true+ to run in daemon mode; not available on Windows (default: false)
- name:           *required* The name of the export
- root:           *required* The root directory to store export monitor logs, pids and downloads
- id/ids:         *required* The id(s) of the scheduled exports to monitor
- to:             Location to store export files (default = <root>/ready)
- to_ftp:         The address of the FTP server to sent the completed downloads to
- to_ftp_dir:     The subdirectory on the FTP server (default = '.')
- ftp_user_name:  The user name to access the FTP server
- ftp_password:   The password to access the FTP server
- imap_address:   The address of the IMAP mail server (default: 'imap.googlemail.com')
- imap_port:      The port of the IMAP mail server (default: 993)
- imap_ssl:       Set to +false+ to disabled SSL (default: true)
- imap_user_name: *required* The user name to access the IMAP server
- imap_password:  *required* The password to access the IMAP server
- imap_mailbox:   The mailbox to monitor for ITRP export mails (default: 'INBOX')
- imap_archive:   The archive mailbox to store the processed ITRP export mails (default: '[Gmail]/All Mail')
- imap_search:    The query used to search for emails from ITRP containing export data (default: `'FROM ITRP HEADER X-ITRP-ExportID ""'`)
- on_exception:   A Proc that takes an exception and the mail as an argument: Proc.new{ |ex, mail| ... }

Defined Under Namespace

Classes: Exchange, Mail, Service

Constant Summary collapse

VERSION =
'1.0.5'

Class Method Summary collapse

Class Method Details

.loggerObject



113
114
115
# File 'lib/itrp/export/monitor.rb', line 113

def logger
  configuration.logger
end

.process(mail) ⇒ Object



109
110
111
# File 'lib/itrp/export/monitor.rb', line 109

def process(mail)
  @service.process(mail)
end

.runObject



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/itrp/export/monitor.rb', line 96

def run
  # create the export monitor as a singleton
  @service = Itrp::Export::Monitor::Service.new
  # generate clacks file
  clacks_config_filename = @service.generate_clacks_config
  # start clacks with the generated config
  args = ['-c', clacks_config_filename]
  args << '-D' if @service.option(:daemonize)
  Clacks::Command.new(args).exec
  # return the singleton instance
  @service
end