Class: MailManager::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mailmanager.rb

Overview

The MailManager::Base class is the root class for working with a Mailman installation. You get an instance of it by calling MailManager.init(‘/mailman/root’).

Constant Summary collapse

REQUIRED_BIN_FILES =

:nodoc:

['list_lists', 'newlist', 'inject']

Instance Method Summary collapse

Constructor Details

#initializeBase

:nodoc:



50
51
52
53
54
55
56
57
58
# File 'lib/mailmanager.rb', line 50

def initialize #:nodoc:
  raise "Must set MailManager.root before calling #{self.class}.instance" if MailManager.root.nil?
  raise "#{root} does not exist" unless Dir.exist?(root)
  raise "#{root}/bin does not exist" unless Dir.exist?("#{root}/bin")
  REQUIRED_BIN_FILES.each do |bin_file|
    raise "#{root}/bin/#{bin_file} not found" unless File.exist?("#{root}/bin/#{bin_file}")
  end
  @lib = MailManager::Lib.new
end

Instance Method Details

#create_list(params) ⇒ Object

Create a new list. Returns an instance of MailManager::List. Params are:

  • :name => ‘new_list_name’

  • :admin_email => ‘[email protected]

  • :admin_password => ‘supersecret’



92
93
94
# File 'lib/mailmanager.rb', line 92

def create_list(params)
  MailManager::List.create(params)
end

#delete_list(list_name) ⇒ Object



102
103
104
# File 'lib/mailmanager.rb', line 102

def delete_list(list_name)
  MailManager::List.delete(list_name)
end

#get_list(list_name) ⇒ Object

Get an existing list as a MailManager::List instance. Raises an exception if the list doesn’t exist.



98
99
100
# File 'lib/mailmanager.rb', line 98

def get_list(list_name)
  @lib.get_list(list_name)
end

#list_namesObject

Only retrieves the list names, doesn’t wrap them in MailManager::List instances.



84
85
86
# File 'lib/mailmanager.rb', line 84

def list_names
  @lib.list_names
end

#listsObject

Returns an array of MailManager::List instances of the lists in your Mailman installation.



78
79
80
# File 'lib/mailmanager.rb', line 78

def lists
  @lib.lists
end

#pythonObject

:nodoc:



68
69
70
# File 'lib/mailmanager.rb', line 68

def python #:nodoc:
  MailManager.python
end

#python=(python) ⇒ Object

If you want to use a non-default python executable to run the Python portions of this gem, set its full path here. Since we require Python 2.6+ and some distros don’t ship with that version, you can point this at a newer Python you have installed. Defaults to /usr/bin/env python.



64
65
66
# File 'lib/mailmanager.rb', line 64

def python=(python)
  MailManager.python = python
end

#rootObject

:nodoc:



72
73
74
# File 'lib/mailmanager.rb', line 72

def root #:nodoc:
  MailManager.root
end