Class: MailManager::Lib
- Inherits:
-
Object
- Object
- MailManager::Lib
- Defined in:
- lib/mailmanager/lib.rb
Overview
:nodoc:all
Instance Method Summary collapse
- #add_member(list, member) ⇒ Object
- #add_moderator(list, email) ⇒ Object
- #approved_add_member(list, member) ⇒ Object
- #approved_delete_member(list, email) ⇒ Object
- #create_list(params) ⇒ Object
- #delete_list(params) ⇒ Object
- #delete_member(list, email) ⇒ Object
- #delete_moderator(list, email) ⇒ Object
- #description(list) ⇒ Object
- #digest_members(list) ⇒ Object
- #find_member(regex) ⇒ Object
- #get_list(list_name) ⇒ Object
- #host_name(list) ⇒ Object
- #inject(list, message, queue = nil) ⇒ Object
- #list_address(list) ⇒ Object
- #list_names ⇒ Object
- #lists ⇒ Object
- #mailmanager ⇒ Object
- #moderators(list) ⇒ Object
- #regular_members(list) ⇒ Object
- #request_email(list) ⇒ Object
- #set_description(list, desc) ⇒ Object
- #set_host_name(list, host_name) ⇒ Object
- #set_subject_prefix(list, sp) ⇒ Object
- #subject_prefix(list) ⇒ Object
- #web_page_url(list) ⇒ Object
Instance Method Details
#add_member(list, member) ⇒ Object
89 90 91 |
# File 'lib/mailmanager/lib.rb', line 89 def add_member(list, member) withlist_command(:AddMember, list, member) end |
#add_moderator(list, email) ⇒ Object
109 110 111 112 113 114 |
# File 'lib/mailmanager/lib.rb', line 109 def add_moderator(list, email) if moderators(list)['return'].include?(email) raise ModeratorAlreadyExistsError, "#{email} is already a moderator of #{list.name}" end withlist_command('moderator.append', list, email) end |
#approved_add_member(list, member) ⇒ Object
93 94 95 |
# File 'lib/mailmanager/lib.rb', line 93 def approved_add_member(list, member) withlist_command(:ApprovedAddMember, list, member) end |
#approved_delete_member(list, email) ⇒ Object
101 102 103 |
# File 'lib/mailmanager/lib.rb', line 101 def approved_delete_member(list, email) withlist_command(:ApprovedDeleteMember, list, email) end |
#create_list(params) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mailmanager/lib.rb', line 41 def create_list(params) raise ArgumentError, "Missing :name param" if params[:name].nil? list_name = params[:name] raise ListNameConflictError, "List \"#{list_name}\" already exists" if list_names.include?(list_name) cmd = :newlist # create the list out = command(cmd, params) # get the new list begin get_list(list_name) rescue ListNotFoundError raise MailmanExecuteError, "List creation failed: #{out}" end end |
#delete_list(params) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/mailmanager/lib.rb', line 61 def delete_list(params) params = {:name => params} unless params.respond_to?(:has_key?) raise ListNotFoundError, "#{params[:name]} does not exist" unless list_names.include?(params[:name]) cmd = :rmlist out = command(cmd, params) parse_output(cmd, out) end |
#delete_member(list, email) ⇒ Object
97 98 99 |
# File 'lib/mailmanager/lib.rb', line 97 def delete_member(list, email) withlist_command(:DeleteMember, list, email) end |
#delete_moderator(list, email) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/mailmanager/lib.rb', line 116 def delete_moderator(list, email) unless moderators(list)['return'].include?(email) raise ModeratorNotFoundError, "#{email} is not a moderator of #{list.name}" end withlist_command('moderator.remove', list, email) end |
#description(list) ⇒ Object
131 132 133 |
# File 'lib/mailmanager/lib.rb', line 131 def description(list) withlist_command(:description, list) end |
#digest_members(list) ⇒ Object
85 86 87 |
# File 'lib/mailmanager/lib.rb', line 85 def digest_members(list) withlist_command(:getDigestMemberKeys, list) end |
#find_member(regex) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/mailmanager/lib.rb', line 34 def find_member(regex) raise ArgumentError, "Expected a Python Regular Expression as String" if regex.is_a? Regexp cmd = :find_member out = command(cmd, {:regex => regex}) parse_output(cmd, out) end |
#get_list(list_name) ⇒ Object
56 57 58 59 |
# File 'lib/mailmanager/lib.rb', line 56 def get_list(list_name) raise ListNotFoundError, "#{list_name} does not exist" unless list_names.include?(list_name) MailManager::List.new(list_name) end |
#host_name(list) ⇒ Object
147 148 149 |
# File 'lib/mailmanager/lib.rb', line 147 def host_name(list) withlist_command(:host_name, list) end |
#inject(list, message, queue = nil) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/mailmanager/lib.rb', line 69 def inject(list, , queue=nil) cmd = :inject params = {:listname => list.name, :stdin => } params[:queue] = queue unless queue.nil? command(cmd, params) {'result' => 'success'} end |
#list_address(list) ⇒ Object
77 78 79 |
# File 'lib/mailmanager/lib.rb', line 77 def list_address(list) withlist_command(:getListAddress, list) end |
#list_names ⇒ Object
30 31 32 |
# File 'lib/mailmanager/lib.rb', line 30 def list_names lists.map { |list| list.name } end |
#lists ⇒ Object
24 25 26 27 28 |
# File 'lib/mailmanager/lib.rb', line 24 def lists cmd = :list_lists out = command(cmd) parse_output(cmd, out) end |
#mailmanager ⇒ Object
20 21 22 |
# File 'lib/mailmanager/lib.rb', line 20 def mailmanager MailManager::Base.instance end |
#moderators(list) ⇒ Object
105 106 107 |
# File 'lib/mailmanager/lib.rb', line 105 def moderators(list) withlist_command(:moderator, list) end |
#regular_members(list) ⇒ Object
81 82 83 |
# File 'lib/mailmanager/lib.rb', line 81 def regular_members(list) withlist_command(:getRegularMemberKeys, list) end |
#request_email(list) ⇒ Object
127 128 129 |
# File 'lib/mailmanager/lib.rb', line 127 def request_email(list) withlist_command(:GetRequestEmail, list) end |
#set_description(list, desc) ⇒ Object
135 136 137 |
# File 'lib/mailmanager/lib.rb', line 135 def set_description(list, desc) withlist_command(:description, list, desc) end |
#set_host_name(list, host_name) ⇒ Object
151 152 153 |
# File 'lib/mailmanager/lib.rb', line 151 def set_host_name(list, host_name) withlist_command(:host_name, list, host_name) end |
#set_subject_prefix(list, sp) ⇒ Object
143 144 145 |
# File 'lib/mailmanager/lib.rb', line 143 def set_subject_prefix(list, sp) withlist_command(:subject_prefix, list, sp) end |
#subject_prefix(list) ⇒ Object
139 140 141 |
# File 'lib/mailmanager/lib.rb', line 139 def subject_prefix(list) withlist_command(:subject_prefix, list) end |
#web_page_url(list) ⇒ Object
123 124 125 |
# File 'lib/mailmanager/lib.rb', line 123 def web_page_url(list) withlist_command('web_page_url', list) end |