equal
deleted
inserted
replaced
29 ### Create a new Ezmlm::List object for the specified +listdir+, which should be |
29 ### Create a new Ezmlm::List object for the specified +listdir+, which should be |
30 ### an ezmlm-idx mailing list directory. |
30 ### an ezmlm-idx mailing list directory. |
31 def initialize( listdir ) |
31 def initialize( listdir ) |
32 listdir = Pathname.new( listdir ) if !listdir.is_a?( Pathname ) |
32 listdir = Pathname.new( listdir ) if !listdir.is_a?( Pathname ) |
33 @listdir = listdir |
33 @listdir = listdir |
|
34 |
|
35 # Cached lookups |
|
36 @config = nil |
34 end |
37 end |
35 |
38 |
36 |
39 |
37 ###### |
40 ###### |
38 public |
41 public |
39 ###### |
42 ###### |
40 |
43 |
41 # The Pathname object for the list directory |
44 # The Pathname object for the list directory |
42 attr_reader :listdir |
45 attr_reader :listdir |
43 |
46 |
|
47 |
|
48 ### Return the configured name of the list (without the host) |
|
49 def name |
|
50 return self.config[ 'L' ] |
|
51 end |
|
52 |
|
53 |
|
54 ### Return the configured host of the list |
|
55 def host |
|
56 return self.config[ 'H' ] |
|
57 end |
|
58 |
|
59 |
|
60 ### Return the configured address of the list (in list@host form) |
|
61 def address |
|
62 return "%s@%s" % [ self.name, self.host ] |
|
63 end |
|
64 alias_method :fullname, :address |
|
65 |
44 |
66 |
45 ### Return the number of messages in the list archive |
67 ### Return the number of messages in the list archive |
46 def message_count |
68 def message_count |
47 numfile = self.listdir + 'num' |
69 numfile = self.listdir + 'num' |
48 return 0 unless numfile.exist? |
70 return 0 unless numfile.exist? |
60 ### Return the author of the last post to the list. |
82 ### Return the author of the last post to the list. |
61 def last_message_author |
83 def last_message_author |
62 mail = self.last_post or return nil |
84 mail = self.last_post or return nil |
63 return mail.from |
85 return mail.from |
64 end |
86 end |
|
87 |
|
88 |
|
89 ### Return the list config as a Hash |
|
90 def config |
|
91 unless @config |
|
92 configfile = self.listdir + 'config' |
|
93 raise "List config file %p does not exist" % [ configfile ] unless configfile.exist? |
|
94 |
|
95 @config = configfile.read.scan( /^(\S):([^\n]*)$/m ).inject({}) do |h,pair| |
|
96 key,val = *pair |
|
97 h[key] = val |
|
98 h |
|
99 end |
|
100 end |
|
101 |
|
102 return @config |
|
103 end |
65 |
104 |
66 |
105 |
67 ### Return the email address of the list's owner. |
106 ### Return the email address of the list's owner. |
68 def owner |
107 def owner |
69 config = self.listdir + 'config' |
108 self.config['5'] |
70 if config.read =~ /^5:([^\n]+)$/m |
|
71 return $1 |
|
72 else |
|
73 return nil |
|
74 end |
|
75 end |
109 end |
76 |
110 |
77 |
111 |
78 ### Fetch an Array of the email addresses for all of the list's subscribers. |
112 ### Fetch an Array of the email addresses for all of the list's subscribers. |
79 def subscribers |
113 def subscribers |
146 return nil unless last_archdir |
180 return nil unless last_archdir |
147 |
181 |
148 # Find the last numbered file under the last numbered directory we found |
182 # Find the last numbered file under the last numbered directory we found |
149 # above. |
183 # above. |
150 last_post_path = Pathname.glob( last_archdir + '[0-9]*' ). |
184 last_post_path = Pathname.glob( last_archdir + '[0-9]*' ). |
151 sort_by {|pn| Integer(pn.basename.to_s) }.last |
185 sort_by {|pn| pn.basename.to_s }.last |
152 |
186 |
153 raise RuntimeError, "unexpectedly empty archive directory '%s'" % [ last_archdir ] \ |
187 raise RuntimeError, "unexpectedly empty archive directory '%s'" % [ last_archdir ] \ |
154 unless last_post_path |
188 unless last_post_path |
155 |
189 |
156 last_post = TMail::Mail.load( last_post_path.to_s ) |
190 last_post = TMail::Mail.load( last_post_path.to_s ) |