lib/ezmlm.rb
author Mahlon E. Smith <mahlon@martini.nu>
Wed, 01 Feb 2017 15:35:35 -0800
changeset 12 3cc813140c80
parent 6 66beb495a861
child 14 cba9fb39bcdb
permissions -rw-r--r--
First round of modernizing after a long absence. Much work to be done.

#!/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