Class: MailManager::List
- Inherits:
-
Object
- Object
- MailManager::List
- Defined in:
- lib/mailmanager/list.rb
Overview
The List class represents mailing lists in Mailman. Typically you get them by doing one of these things: mm = MailManager.init(‘/mailman/root’) mylist = mm.get_list(‘list_name’) OR mylist = mm.create_list(:name => ‘list_name’, :admin_email => ‘[email protected]’, :admin_password => ‘supersecret’)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the list.
Class Method Summary collapse
-
.create(params) ⇒ Object
:nodoc:.
-
.delete(list_name) ⇒ Object
:nodoc:.
-
.lib ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#add_member(email, name = '') ⇒ Object
Adds a new list member, subject to the list’s subscription rules.
-
#add_moderator(email) ⇒ Object
Adds a new moderator to the list.
-
#address ⇒ Object
Returns the list’s email address.
-
#approved_add_member(email, name = '') ⇒ Object
Adds a new list member, bypassing the list’s subscription rules.
-
#approved_delete_member(email, name = '') ⇒ Object
Deletes a list member, bypassing the list’s unsubscription rules.
-
#delete ⇒ Object
Deletes the list, but not the archives.
-
#delete_member(email) ⇒ Object
Deletes a list member, subject to the list’s unsubscription rules.
-
#delete_moderator(email) ⇒ Object
Deletes a moderator from the list.
-
#description ⇒ Object
Returns the list description.
-
#description=(desc) ⇒ Object
Sets the list description to a new value.
-
#digest_members ⇒ Object
Returns just the digest list members (no regular members) as an array.
-
#host_name ⇒ Object
Returns the list’s host name.
-
#host_name=(host_name) ⇒ Object
Sets the list’s host name.
-
#info_url ⇒ Object
Returns the info URL for the list.
-
#initialize(name) ⇒ List
constructor
This doesn’t do any checking to see whether or not the requested list exists or not.
-
#inject(from, subj, message, custom_headers = nil) ⇒ Object
Injects a message into the list.
-
#inject_raw(message) ⇒ Object
Injects a raw message into the list.
-
#lib ⇒ Object
:nodoc:.
-
#members ⇒ Object
Returns all list members (regular & digest) as an array.
-
#moderators ⇒ Object
Returns the list of moderators as an array of email addresses.
-
#regular_members ⇒ Object
Returns just the regular list members (no digest members) as an array.
-
#request_email ⇒ Object
Returns the request email address for the list.
-
#subject_prefix ⇒ Object
Returns the list’s subject prefix.
-
#subject_prefix=(sp) ⇒ Object
Sets the list’s subject prefix to a new value.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(name) ⇒ List
This doesn’t do any checking to see whether or not the requested list exists or not. Better to use MailManager::Base#get_list instead.
18 19 20 |
# File 'lib/mailmanager/list.rb', line 18 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the list
14 15 16 |
# File 'lib/mailmanager/list.rb', line 14 def name @name end |
Class Method Details
.create(params) ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/mailmanager/list.rb', line 34 def self.create(params) #:nodoc: lib.create_list(params) end |
.delete(list_name) ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/mailmanager/list.rb', line 38 def self.delete(list_name) #:nodoc: lib.delete_list(list_name) end |
.lib ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/mailmanager/list.rb', line 30 def self.lib #:nodoc: MailManager::Lib.new end |
Instance Method Details
#add_member(email, name = '') ⇒ Object
Adds a new list member, subject to the list’s subscription rules
71 72 73 |
# File 'lib/mailmanager/list.rb', line 71 def add_member(email, name='') add_member_using(:add_member, email, name) end |
#add_moderator(email) ⇒ Object
Adds a new moderator to the list. Returns :already_a_moderator if the requested new moderator is already a moderator.
98 99 100 101 |
# File 'lib/mailmanager/list.rb', line 98 def add_moderator(email) result = lib.add_moderator(self, email) result['result'].to_sym end |
#address ⇒ Object
Returns the list’s email address
48 49 50 51 |
# File 'lib/mailmanager/list.rb', line 48 def address result = lib.list_address(self) result['return'] end |
#approved_add_member(email, name = '') ⇒ Object
Adds a new list member, bypassing the list’s subscription rules
76 77 78 |
# File 'lib/mailmanager/list.rb', line 76 def approved_add_member(email, name='') add_member_using(:approved_add_member, email, name) end |
#approved_delete_member(email, name = '') ⇒ Object
Deletes a list member, bypassing the list’s unsubscription rules
86 87 88 |
# File 'lib/mailmanager/list.rb', line 86 def approved_delete_member(email, name='') delete_member_using(:approved_delete_member, email) end |
#delete ⇒ Object
Deletes the list, but not the archives
43 44 45 |
# File 'lib/mailmanager/list.rb', line 43 def delete self.class.delete(self.name) end |
#delete_member(email) ⇒ Object
Deletes a list member, subject to the list’s unsubscription rules
81 82 83 |
# File 'lib/mailmanager/list.rb', line 81 def delete_member(email) delete_member_using(:delete_member, email) end |
#delete_moderator(email) ⇒ Object
Deletes a moderator from the list. Raises a ModeratorNotFoundError if the requested deletion isn’t a moderator.
105 106 107 108 |
# File 'lib/mailmanager/list.rb', line 105 def delete_moderator(email) result = lib.delete_moderator(self, email) result['result'].to_sym end |
#description ⇒ Object
Returns the list description
153 154 155 156 |
# File 'lib/mailmanager/list.rb', line 153 def description result = lib.description(self) result['return'] end |
#description=(desc) ⇒ Object
Sets the list description to a new value
159 160 161 162 |
# File 'lib/mailmanager/list.rb', line 159 def description=(desc) result = lib.set_description(self, desc) result['result'].to_sym end |
#digest_members ⇒ Object
Returns just the digest list members (no regular members) as an array
65 66 67 68 |
# File 'lib/mailmanager/list.rb', line 65 def digest_members result = lib.digest_members(self) result['return'] end |
#host_name ⇒ Object
Returns the list’s host name
178 179 180 181 |
# File 'lib/mailmanager/list.rb', line 178 def host_name result = lib.host_name(self) result['return'] end |
#host_name=(host_name) ⇒ Object
Sets the list’s host name
184 185 186 187 |
# File 'lib/mailmanager/list.rb', line 184 def host_name=(host_name) result = lib.set_host_name(self, host_name) result['result'].to_sym end |
#info_url ⇒ Object
Returns the info URL for the list
139 140 141 142 143 144 |
# File 'lib/mailmanager/list.rb', line 139 def info_url result = lib.web_page_url(self) root = result['return'] root += "/" unless root[-1,1] == '/' "#{root}listinfo/#{name}" end |
#inject(from, subj, message, custom_headers = nil) ⇒ Object
Injects a message into the list.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/mailmanager/list.rb', line 111 def inject(from, subj, , custom_headers=nil) =<<EOF From: #{from} To: #{address} Subject: #{subj} EOF if !custom_headers.nil? raise ArgumentError, "custom headers arg should be a hash" unless custom_headers.respond_to?(:each_pair) headers = [] custom_headers.each_pair { |hdr, val| headers << "#{hdr}: #{val}" } += headers.join("\n") end += "\n#{}" result = lib.inject(self, ) result['result'].to_sym end |
#inject_raw(message) ⇒ Object
Injects a raw message into the list. You must send a properly formatted email to this method. You probably want to set the To: header to the list’s address. You can get that from MailManager::List#address
133 134 135 136 |
# File 'lib/mailmanager/list.rb', line 133 def inject_raw() result = lib.inject(self, ) result['result'].to_sym end |
#lib ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/mailmanager/list.rb', line 26 def lib #:nodoc: self.class.lib end |
#members ⇒ Object
Returns all list members (regular & digest) as an array
54 55 56 |
# File 'lib/mailmanager/list.rb', line 54 def members regular_members + digest_members end |
#moderators ⇒ Object
Returns the list of moderators as an array of email addresses
91 92 93 94 |
# File 'lib/mailmanager/list.rb', line 91 def moderators result = lib.moderators(self) result['return'] end |
#regular_members ⇒ Object
Returns just the regular list members (no digest members) as an array
59 60 61 62 |
# File 'lib/mailmanager/list.rb', line 59 def regular_members result = lib.regular_members(self) result['return'] end |
#request_email ⇒ Object
Returns the request email address for the list
147 148 149 150 |
# File 'lib/mailmanager/list.rb', line 147 def request_email result = lib.request_email(self) result['return'] end |
#subject_prefix ⇒ Object
Returns the list’s subject prefix
165 166 167 168 |
# File 'lib/mailmanager/list.rb', line 165 def subject_prefix result = lib.subject_prefix(self) result['return'] end |
#subject_prefix=(sp) ⇒ Object
Sets the list’s subject prefix to a new value. Remember to leave a space at the end (assuming you want one, and you probably do).
172 173 174 175 |
# File 'lib/mailmanager/list.rb', line 172 def subject_prefix=(sp) result = lib.set_subject_prefix(self, sp) result['result'].to_sym end |
#to_s ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/mailmanager/list.rb', line 22 def to_s #:nodoc: @name end |