8 |
8 |
9 Examples |
9 Examples |
10 -------- |
10 -------- |
11 |
11 |
12 |
12 |
13 *Print the list address for all lists in a directory*: |
13 ### Print the list address for all lists in a directory: |
14 |
14 |
15 Ezmlm.each_list( '/lists' ) do |list| |
15 Ezmlm.each_list( '/lists' ) do |list| |
16 puts list.address |
16 puts list.address |
17 end |
17 end |
18 |
18 |
19 |
19 |
20 *Check if I'm subscribed to a list, and if so, unsubscribe*: |
20 ### Check if I'm subscribed to a list, and if so, unsubscribe: |
21 |
21 |
22 (You don't really have to check first, subscribe and unsubscribe are |
22 (You don't really have to check first, subscribe and unsubscribe are |
23 idempotent.) |
23 idempotent.) |
24 |
24 |
25 list = Ezmlm::List.new( '/lists/waffle-lovers' ) |
25 list = Ezmlm::List.new( '/lists/waffle-lovers' ) |
29 end |
29 end |
30 |
30 |
31 puts "The list now has %d subscribers!" % [ list.subscribers.size ] |
31 puts "The list now has %d subscribers!" % [ list.subscribers.size ] |
32 |
32 |
33 |
33 |
34 *Iterate over the subscriber list*: |
34 ### Iterate over the subscriber list: |
35 |
35 |
36 list.subscribers.each do |subscriber| |
36 list.subscribers.each do |subscriber| |
37 # ... |
37 # ... |
38 end |
38 end |
39 |
39 |
40 |
40 |
41 *Make the list moderated, and add a moderator*: |
41 ### Make the list moderated, and add a moderator: |
42 |
42 |
43 list.moderated = true |
43 list.moderated = true |
44 list.add_moderator( 'mahlon@martini.nu' ) |
44 list.add_moderator( 'mahlon@martini.nu' ) |
45 list.moderated? #=> true |
45 list.moderated? #=> true |
46 |
46 |
47 All other list behavior tunables operate in a similar fashion, see RDoc |
47 All other list behavior tunables operate in a similar fashion, see RDoc |
48 for details. |
48 for details. |
49 |
49 |
50 |
50 |
51 *Archiving!* |
51 ### Archiving! |
52 |
52 |
53 All of the archival pieces take advantage of Ezmlm-IDX extensions. |
53 All of the archival pieces take advantage of Ezmlm-IDX extensions. |
54 If you want to use these features, you'll want to enable archiving |
54 If you want to use these features, you'll want to enable archiving |
55 and indexing for your lists, using the -a and -i flags to ezmlm-make. |
55 and indexing for your lists, using the -a and -i flags to ezmlm-make. |
56 (Enabling archiving with this library also enables indexing and thread |
56 (Enabling archiving with this library also enables indexing and thread |
65 ezmlm-make) but not indexing, you can manually run ezmlm-archive to |
65 ezmlm-make) but not indexing, you can manually run ezmlm-archive to |
66 rebuild the necessary files - afterwards, they are kept up to date |
66 rebuild the necessary files - afterwards, they are kept up to date |
67 automatically. |
67 automatically. |
68 |
68 |
69 |
69 |
70 *How many messages are in the archive?*: |
70 ### How many messages are in the archive?: |
71 |
71 |
72 list.message_count #=> 123 |
72 list.message_count #=> 123 |
73 |
73 |
74 |
74 |
75 *Fetch message number 100 from the archive*: |
75 ### Fetch message number 100 from the archive: |
76 |
76 |
77 message = list.message( 100 ) or abort "No such message." |
77 message = list.message( 100 ) or abort "No such message." |
78 |
78 |
79 puts message.subject |
79 puts message.subject |
80 puts message.body.to_s # Print just the body of the message. |
80 puts message.body.to_s # Print just the body of the message. |
94 Message objects act as "Mail" objects from the excellent library from |
94 Message objects act as "Mail" objects from the excellent library from |
95 Mikel Lindsaar (https://github.com/mikel/mail). See its documentation |
95 Mikel Lindsaar (https://github.com/mikel/mail). See its documentation |
96 for specifics. |
96 for specifics. |
97 |
97 |
98 |
98 |
99 *Iterate over messages in a specific thread*: |
99 ### Iterate over messages in a specific thread: |
100 |
100 |
101 Messages know what thread they belong to. Once you have a thread object |
101 Messages know what thread they belong to. Once you have a thread object |
102 from a message, it is an enumerable. Iterate or sort on it using |
102 from a message, it is an enumerable. Iterate or sort on it using |
103 standard Ruby methods. |
103 standard Ruby methods. |
104 |
104 |
108 |
108 |
109 Threads are also aware of who participated in the conversation, via the |
109 Threads are also aware of who participated in the conversation, via the |
110 'authors' and 'each_author' methods. |
110 'authors' and 'each_author' methods. |
111 |
111 |
112 |
112 |
113 *Iterate over messages from a specific author:* |
113 ### Iterate over messages from a specific author: |
114 |
114 |
115 Messages know who authored them. Once you have an author object from a |
115 Messages know who authored them. Once you have an author object from a |
116 message, it is an enumerable. Iterate or sort on it using standard Ruby |
116 message, it is an enumerable. Iterate or sort on it using standard Ruby |
117 methods. |
117 methods. |
118 |
118 |