lib/ezmlm.rb
author Mahlon E. Smith <mahlon@laika.com>
Tue, 16 May 2017 15:52:05 -0700
changeset 20 9d59d30685cb
parent 18 9aaac749fd9f
child 22 d1b9dd767e3a
permissions -rw-r--r--
Fixes for documentation and test directories that didn't make it into the repo.

# vim: set nosta noet ts=4 sw=4:

require 'pathname'

# A Ruby interface to the ezmlm-idx mailing list system.
#
#   Ezmlm.find_directories( '/lists' ) #=> [ Ezmlm::List, Ezmlm::List ]
#
#   Ezmlm.each_list( '/lists' ) do |list|
#       puts "\"%s\" <%s>" % [ list.name, list.address ]
#   end
#
module Ezmlm
	# $Id$

	# Package version
	VERSION = '1.0.1'

	# Suck in the components.
	#
	require 'ezmlm/hash'
	require 'ezmlm/list'
	require 'ezmlm/list/author'
	require 'ezmlm/list/message'
	require 'ezmlm/list/thread'


	###############
	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 + '*' ).sort.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