Class: MailManager::Base
- Inherits:
-
Object
- Object
- MailManager::Base
- 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
-
#create_list(params) ⇒ Object
Create a new list.
-
#get_list(list_name) ⇒ Object
Get an existing list as a MailManager::List instance.
-
#initialize ⇒ Base
constructor
:nodoc:.
-
#list_names ⇒ Object
Only retrieves the list names, doesn’t wrap them in MailManager::List instances.
-
#lists ⇒ Object
Returns an array of MailManager::List instances of the lists in your Mailman installation.
-
#python ⇒ Object
:nodoc:.
-
#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.
-
#root ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ Base
: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 |
#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 101 |
# File 'lib/mailmanager.rb', line 98 def get_list(list_name) raise "#{list_name} list does not exist" unless list_names.include?(list_name.downcase) MailManager::List.new(list_name) end |
#list_names ⇒ Object
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 lists.map { |list| list.name } end |
#lists ⇒ Object
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 |
#python ⇒ Object
: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 |
#root ⇒ Object
:nodoc:
72 73 74 |
# File 'lib/mailmanager.rb', line 72 def root #:nodoc: MailManager.root end |