koseki-mocksmtpd 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +13 -0
- data/README +30 -1
- data/lib/mocksmtpd.rb +27 -8
- data/templates/mocksmtpd.conf.erb +1 -1
- metadata +2 -8
data/ChangeLog
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
+
== 0.0.3 / 2008-11-08
|
2
|
+
|
3
|
+
* rescue Process.eid NotImplementedError.
|
4
|
+
* warn when Process.eid can't be changed.
|
5
|
+
* read log level from config file.
|
6
|
+
* change param name from Loglevel to LogLevel
|
7
|
+
* add debug log.
|
8
|
+
|
9
|
+
== 0.0.2 / 2008-11-03
|
10
|
+
|
11
|
+
* release gem version.
|
12
|
+
|
1
13
|
== 0.0.1 / 2008-11-03
|
2
14
|
|
15
|
+
* moved into github
|
3
16
|
* initial release
|
4
17
|
|
data/README
CHANGED
@@ -4,6 +4,14 @@
|
|
4
4
|
|
5
5
|
== Description
|
6
6
|
|
7
|
+
Mocksmtpd is a SMTP server for developping and testing web application. This SMTP server does not send mail anywhere. Otherwise, save all mails as HTML format.
|
8
|
+
|
9
|
+
You can test mail using browser testing tools like Selenium.
|
10
|
+
|
11
|
+
=== Screenshot
|
12
|
+
|
13
|
+
http://koseki2.tumblr.com/post/57148631
|
14
|
+
http://koseki2.tumblr.com/post/57148564
|
7
15
|
|
8
16
|
== Installation
|
9
17
|
|
@@ -13,9 +21,30 @@
|
|
13
21
|
|
14
22
|
=== Gem Installation
|
15
23
|
|
16
|
-
|
24
|
+
gem sources -a http://gems.github.com
|
17
25
|
gem install koseki-mocksmtpd
|
18
26
|
|
27
|
+
== Quick Start
|
28
|
+
|
29
|
+
$ mocksmtpd init
|
30
|
+
$ cd ./mocksmtpd
|
31
|
+
$ sudo mocksmtpd
|
32
|
+
|
33
|
+
== Usaage
|
34
|
+
|
35
|
+
mocksmtpd init [dirname] ... create log,inbox dir and config file.
|
36
|
+
mocksmtpd ... start as console mode.
|
37
|
+
mocksmtpd start ... start as daemon.
|
38
|
+
mocksmtpd stop ... stop running daemon.
|
39
|
+
|
40
|
+
=== Options
|
41
|
+
|
42
|
+
The default config file is ./mocksmtpd.conf, but you can specify any other file using -f option.
|
43
|
+
|
44
|
+
-f / --config=FILE ... Specify config file.
|
45
|
+
--help ... Show help.
|
46
|
+
--version ... Show version.
|
47
|
+
|
19
48
|
== Features/Problems
|
20
49
|
|
21
50
|
|
data/lib/mocksmtpd.rb
CHANGED
@@ -8,7 +8,7 @@ require 'nkf'
|
|
8
8
|
require 'smtpserver'
|
9
9
|
|
10
10
|
class Mocksmtpd
|
11
|
-
VERSION = '0.0.
|
11
|
+
VERSION = '0.0.3'
|
12
12
|
TEMPLATE_DIR = Pathname.new(File.dirname(__FILE__)) + "../templates"
|
13
13
|
|
14
14
|
include ERB::Util
|
@@ -132,16 +132,27 @@ class Mocksmtpd
|
|
132
132
|
puts "done"
|
133
133
|
end
|
134
134
|
|
135
|
+
def create_logger(file = nil)
|
136
|
+
file = file.to_s.strip
|
137
|
+
file = nil if file.empty?
|
138
|
+
lvstr = @conf[:LogLevel].to_s.strip
|
139
|
+
lvstr = "INFO" unless %w{FATAL ERROR WARN INFO DEBUG}.include?(lvstr)
|
140
|
+
level = WEBrick::BasicLog.const_get(lvstr)
|
141
|
+
logger = WEBrick::Log.new(file, level)
|
142
|
+
logger.debug("Logger initialized")
|
143
|
+
return logger
|
144
|
+
end
|
145
|
+
|
135
146
|
def start
|
136
147
|
load_conf
|
137
|
-
@logger =
|
148
|
+
@logger = create_logger(@logfile)
|
138
149
|
@daemon = true
|
139
150
|
smtpd
|
140
151
|
end
|
141
152
|
|
142
153
|
def console
|
143
154
|
load_conf
|
144
|
-
@logger =
|
155
|
+
@logger = create_logger
|
145
156
|
@daemon = false
|
146
157
|
smtpd
|
147
158
|
end
|
@@ -149,16 +160,19 @@ class Mocksmtpd
|
|
149
160
|
def create_pid_file
|
150
161
|
if @pidfile.exist?
|
151
162
|
pid = @pidfile.read
|
152
|
-
@logger.warn("pid file already exists:
|
163
|
+
@logger.warn("pid file already exists: pid=#{pid}")
|
153
164
|
exit 1
|
154
165
|
end
|
166
|
+
pid = Process.pid
|
155
167
|
open(@pidfile, "w") do |io|
|
156
|
-
io <<
|
168
|
+
io << pid
|
157
169
|
end
|
170
|
+
@logger.debug("pid file saved: pid=#{pid} file=#{@pidfile}")
|
158
171
|
end
|
159
172
|
|
160
173
|
def delete_pid_file
|
161
174
|
File.delete(@pidfile)
|
175
|
+
@logger.debug("pid file deleted: file=#{@pidfile}")
|
162
176
|
end
|
163
177
|
|
164
178
|
def init_permission
|
@@ -169,7 +183,10 @@ class Mocksmtpd
|
|
169
183
|
begin
|
170
184
|
Process.egid = gid
|
171
185
|
Process.euid = uid
|
172
|
-
rescue
|
186
|
+
rescue NotImplementedError => e
|
187
|
+
@logger.debug("Process.euid= not implemented.")
|
188
|
+
rescue Errno::EPERM => e
|
189
|
+
@logger.warn("could not change euid/egid. #{e}")
|
173
190
|
end
|
174
191
|
end
|
175
192
|
|
@@ -177,8 +194,8 @@ class Mocksmtpd
|
|
177
194
|
start_cb = Proc.new do
|
178
195
|
@logger.info("Inbox: #{@inbox}")
|
179
196
|
if @daemon
|
180
|
-
|
181
|
-
|
197
|
+
@logger.debug("LogFile: #{@logfile}")
|
198
|
+
@logger.debug("PidFile: #{@pidfile}")
|
182
199
|
end
|
183
200
|
|
184
201
|
begin
|
@@ -267,6 +284,7 @@ class Mocksmtpd
|
|
267
284
|
open(mail[:path], "w") do |io|
|
268
285
|
io << @templates[:mail].result(binding)
|
269
286
|
end
|
287
|
+
@logger.debug("mail saved: #{mail[:path]}")
|
270
288
|
end
|
271
289
|
|
272
290
|
def save_index(mail)
|
@@ -284,6 +302,7 @@ class Mocksmtpd
|
|
284
302
|
open(path, "w") do |io|
|
285
303
|
io << htmlsrc
|
286
304
|
end
|
305
|
+
@logger.debug("index saved: #{path}")
|
287
306
|
end
|
288
307
|
|
289
308
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koseki-mocksmtpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOSEKI Kengo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-08 00:00:00 -08:00
|
13
13
|
default_executable: mocksmtpd
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -29,18 +29,12 @@ files:
|
|
29
29
|
- bin/mocksmtpd
|
30
30
|
- test/mocksmtpd_test.rb
|
31
31
|
- test/test_helper.rb
|
32
|
-
- lib/mocksmtpd-old.rb
|
33
|
-
- lib/mocksmtpd-old.rb~
|
34
32
|
- lib/mocksmtpd.rb
|
35
|
-
- lib/mocksmtpd.rb~
|
36
33
|
- lib/smtpserver.rb
|
37
34
|
- templates/html
|
38
35
|
- templates/html/index.erb
|
39
|
-
- templates/html/index.erb~
|
40
36
|
- templates/html/index_entry.erb
|
41
|
-
- templates/html/index_entry.erb~
|
42
37
|
- templates/html/mail.erb
|
43
|
-
- templates/html/mail.html.erb~
|
44
38
|
- templates/mocksmtpd.conf.erb
|
45
39
|
has_rdoc: true
|
46
40
|
homepage: http://github.com/koseki/mocksmtpd/
|