lib/ezmlm.rb
author Mahlon E. Smith <mahlon@martini.nu>
Thu, 03 Oct 2019 11:44:44 -0700
changeset 28 99fdbf4a5f37
parent 25 81cc7d47f68f
child 29 5e07ff7d5601
permissions -rw-r--r--
Be explicit with sticky removal, so two simultaneous processes don't create a race where sticky is left enabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
     1
# vim: set nosta noet ts=4 sw=4:
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     2
20
9d59d30685cb Fixes for documentation and test directories that didn't make it into the repo.
Mahlon E. Smith <mahlon@laika.com>
parents: 18
diff changeset
     3
require 'pathname'
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     4
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     5
# A Ruby interface to the ezmlm-idx mailing list system.
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
     6
#
17
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     7
#   Ezmlm.find_directories( '/lists' ) #=> [ Ezmlm::List, Ezmlm::List ]
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     8
#
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
     9
#   Ezmlm.each_list( '/lists' ) do |list|
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
    10
#       puts "\"%s\" <%s>" % [ list.name, list.address ]
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
    11
#   end
23c7f5c8ee39 Multiple changes.
Mahlon E. Smith <mahlon@laika.com>
parents: 16
diff changeset
    12
#
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    13
module Ezmlm
28
99fdbf4a5f37 Be explicit with sticky removal, so two simultaneous processes don't create a race where sticky is left enabled.
Mahlon E. Smith <mahlon@martini.nu>
parents: 25
diff changeset
    14
	# $Id: ezmlm.rb,v 81cc7d47f68f 2017/05/30 18:08:48 mahlon $
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    15
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    16
	# Package version
28
99fdbf4a5f37 Be explicit with sticky removal, so two simultaneous processes don't create a race where sticky is left enabled.
Mahlon E. Smith <mahlon@martini.nu>
parents: 25
diff changeset
    17
	VERSION = '1.1.2'
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    18
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    19
	# Suck in the components.
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    20
	#
16
e135ccae6783 Migrate hashing functions to C.
Mahlon E. Smith <mahlon@laika.com>
parents: 15
diff changeset
    21
	require 'ezmlm/hash'
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    22
	require 'ezmlm/list'
15
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    23
	require 'ezmlm/list/author'
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    24
	require 'ezmlm/list/message'
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    25
	require 'ezmlm/list/thread'
a38e6916504c Everything is workin!
Mahlon E. Smith <mahlon@laika.com>
parents: 14
diff changeset
    26
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    27
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    28
	###############
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    29
	module_function
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    30
	###############
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    31
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    32
	### Find all directories that look like an Ezmlm list directory under
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    33
	### the specified +listsdir+ and return Pathname objects for each.
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    34
	###
6
66beb495a861 Checkpoint commit.
Michael Granger <mgranger@laika.com>
parents: 5
diff changeset
    35
	def find_directories( listsdir )
66beb495a861 Checkpoint commit.
Michael Granger <mgranger@laika.com>
parents: 5
diff changeset
    36
		listsdir = Pathname.new( listsdir )
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    37
		return Pathname.glob( listsdir + '*' ).sort.select do |entry|
25
81cc7d47f68f Oop, the 'mailinglist' file was leftover from older ezmlm. Not created by ezmlm-make anymore.
Mahlon E. Smith <mahlon@martini.nu>
parents: 24
diff changeset
    38
			entry.directory? && ( entry + 'ezmlmrc' ).exist?
6
66beb495a861 Checkpoint commit.
Michael Granger <mgranger@laika.com>
parents: 5
diff changeset
    39
		end
66beb495a861 Checkpoint commit.
Michael Granger <mgranger@laika.com>
parents: 5
diff changeset
    40
	end
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    41
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    42
14
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    43
	### Iterate over each directory that looks like an Ezmlm list in the
cba9fb39bcdb Checkpoint commit.
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    44
	### specified +listsdir+ and yield it as an Ezmlm::List object.
12
3cc813140c80 First round of modernizing after a long absence.
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    45
	###
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    46
	def each_list( listsdir )
6
66beb495a861 Checkpoint commit.
Michael Granger <mgranger@laika.com>
parents: 5
diff changeset
    47
		find_directories( listsdir ).each do |entry|
1
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    48
			yield( Ezmlm::List.new(entry) )
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    49
		end
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    50
	end
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    51
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    52
end # module Ezmlm
1d3cfd4837a8 Filled out the project, added Ezmlm module + spec.
Michael Granger <mgranger@laika.com>
parents:
diff changeset
    53