mailman 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -2
- data/lib/mailman/application.rb +23 -19
- data/lib/mailman/route/conditions.rb +3 -3
- data/lib/mailman/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -14,8 +14,6 @@ end
|
|
14
14
|
|
15
15
|
See the [User Guide](https://github.com/titanous/mailman/blob/master/USER_GUIDE.md) for more information.
|
16
16
|
|
17
|
-
There is also a great [Getting Started Guide](http://dansowter.com/mailman-guide/) written by Dan Sowter.
|
18
|
-
|
19
17
|
|
20
18
|
## Installation
|
21
19
|
|
@@ -42,6 +40,7 @@ and my mentor was [Steven Soroka](http://github.com/ssoroka).
|
|
42
40
|
|
43
41
|
- [Nicolas Aguttes](http://github.com/tranquiliste)
|
44
42
|
- [Nathan Broadbent](https://github.com/ndbroadbent)
|
43
|
+
- [John Cant](https://github.com/johncant)
|
45
44
|
- [Tim Carey-Smith](http://github.com/halorgium)
|
46
45
|
- [Dan Cheail](https://github.com/DanCheail)
|
47
46
|
- [Francis Chong](https://github.com/siuying)
|
data/lib/mailman/application.rb
CHANGED
@@ -18,10 +18,17 @@ module Mailman
|
|
18
18
|
# @param [Hash] options the application options
|
19
19
|
# @option options [true,false] :graceful_death catch interrupt signal and don't die until end of poll
|
20
20
|
# @param [Proc] block a block with routes
|
21
|
+
|
21
22
|
def initialize(&block)
|
22
23
|
@router = Mailman::Router.new
|
23
24
|
@processor = MessageProcessor.new(:router => @router)
|
24
|
-
|
25
|
+
|
26
|
+
if Mailman.config.maildir
|
27
|
+
require 'maildir'
|
28
|
+
@maildir = Maildir.new(Mailman.config.maildir)
|
29
|
+
end
|
30
|
+
|
31
|
+
instance_eval(&block) if block_given?
|
25
32
|
end
|
26
33
|
|
27
34
|
def polling?
|
@@ -37,10 +44,12 @@ module Mailman
|
|
37
44
|
def run
|
38
45
|
Mailman.logger.info "Mailman v#{Mailman::VERSION} started"
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
if Mailman.config.rails_root
|
48
|
+
rails_env = File.join(Mailman.config.rails_root, 'config', 'environment.rb')
|
49
|
+
if File.exist?(rails_env) && !(defined?(Rails) && Rails.env)
|
50
|
+
Mailman.logger.info "Rails root found in #{Mailman.config.rails_root}, requiring environment..."
|
51
|
+
require rails_env
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
if Mailman.config.graceful_death
|
@@ -67,36 +76,31 @@ module Mailman
|
|
67
76
|
|
68
77
|
# Maildir
|
69
78
|
elsif Mailman.config.maildir
|
70
|
-
require 'maildir'
|
71
79
|
|
72
80
|
Mailman.logger.info "Maildir receiver enabled (#{Mailman.config.maildir})."
|
73
|
-
@maildir = Maildir.new(Mailman.config.maildir)
|
74
81
|
|
75
|
-
|
82
|
+
Mailman.logger.debug "Processing new message queue..."
|
83
|
+
@maildir.list(:new).each do |message|
|
84
|
+
@processor.process_maildir_message(message)
|
85
|
+
end
|
76
86
|
|
77
87
|
if Mailman.config.watch_maildir
|
78
88
|
require 'listen'
|
79
89
|
Mailman.logger.debug "Monitoring the Maildir for new messages..."
|
80
90
|
|
81
91
|
callback = Proc.new do |modified, added, removed|
|
82
|
-
|
92
|
+
added.each do |new_file|
|
93
|
+
message = Maildir::Message.new(@maildir, "new/#{new_file}")
|
94
|
+
@processor.process_maildir_message(message)
|
95
|
+
end
|
83
96
|
end
|
84
97
|
|
85
|
-
@listener = Listen.to(File.join(
|
98
|
+
@listener = Listen.to(File.join(@maildir.path, 'new'), :relative_paths => true).change(&callback)
|
86
99
|
@listener.start
|
87
100
|
end
|
88
101
|
end
|
89
102
|
end
|
90
103
|
|
91
|
-
# List all message in Maildir new directory and process it
|
92
|
-
def process_maildir
|
93
|
-
# Process messages queued in the new directory
|
94
|
-
Mailman.logger.debug "Processing new message queue..."
|
95
|
-
@maildir.list(:new).each do |message|
|
96
|
-
@processor.process_maildir_message(message)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
104
|
private
|
101
105
|
|
102
106
|
# Run the polling loop for the email inbox connection
|
@@ -38,11 +38,11 @@ module Mailman
|
|
38
38
|
class BodyCondition < Condition
|
39
39
|
def match(message)
|
40
40
|
if message.multipart?
|
41
|
+
result = nil
|
41
42
|
message.parts.each do |part|
|
42
|
-
if result = @matcher.match(part.decoded)
|
43
|
-
return result
|
44
|
-
end
|
43
|
+
break if result = @matcher.match(part.decoded)
|
45
44
|
end
|
45
|
+
return result
|
46
46
|
else
|
47
47
|
@matcher.match(message.body.decoded)
|
48
48
|
end
|
data/lib/mailman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|