lib/ezmlm.rb
author Mahlon E. Smith <mahlon@martini.nu>
Fri, 03 Feb 2017 10:52:46 -0800
changeset 13 a03c08c289e9
parent 12 3cc813140c80
child 14 cba9fb39bcdb
permissions -rw-r--r--
Multiple changes. - Start converting from from the old 'config' file format where applicable. - Port the ezmlm address hashing algorithm for fast email lookups - Add subscription and unsubscription for primary and behavioral dirs - Add a safety check for writes to the list directory

#!/usr/bin/ruby
# vim: set nosta noet ts=4 sw=4:
#
# A Ruby programmatic interface to the ezmlm-idx mailing list system
#
# == Version
#
#  $Id$
#
#---
#
# Please see the file LICENSE in the base directory for licensing details.
#

require 'pathname'


### Toplevel namespace module
module Ezmlm

	# Package version
	VERSION = '0.1.0'

	require 'ezmlm/list'

	###############
	module_function
	###############

	### Find all directories that look like an Ezmlm list directory under the specified +listsdir+
	### and return Pathname objects for each.
	###
	def find_directories( listsdir )
		listsdir = Pathname.new( listsdir )
		return Pathname.glob( listsdir + '*' ).select do |entry|
			entry.directory? && ( entry + 'mailinglist' ).exist?
		end
	end


	### Iterate over each directory that looks like an Ezmlm list in the specified +listsdir+ and
	### yield it as an Ezmlm::List object.
	###
	def each_list( listsdir )
		find_directories( listsdir ).each do |entry|
			yield( Ezmlm::List.new(entry) )
		end
	end

end # module Ezmlm