mini-smtp-server 0.0.1 → 0.0.2

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/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -7,9 +7,9 @@ class MiniSmtpServer < GServer
7
7
  end
8
8
 
9
9
  def serve(io)
10
- @data_mode = false
11
- @message = {:data => ""}
12
- @connection_active = true
10
+ Thread.current[:data_mode] = false
11
+ Thread.current[:message] = {:data => ""}
12
+ Thread.current[:connection_active] = true
13
13
  io.print "220 hello\r\n"
14
14
  loop do
15
15
  if IO.select([io], nil, nil, 0.1)
@@ -19,12 +19,12 @@ class MiniSmtpServer < GServer
19
19
  log(">>> " + output) if(@audit && !output.empty?)
20
20
  io.print(output) unless output.empty?
21
21
  end
22
- break if(!@connection_active || io.closed?)
22
+ break if(!Thread.current[:connection_active] || io.closed?)
23
23
  end
24
24
  io.print "221 bye\r\n"
25
25
  io.close
26
- @message[:data].gsub!(/\r\n\Z/, '').gsub!(/\.\Z/, '')
27
- new_message_event(@message)
26
+ Thread.current[:message][:data].gsub!(/\r\n\Z/, '').gsub!(/\.\Z/, '')
27
+ new_message_event(Thread.current[:message])
28
28
  end
29
29
 
30
30
  def process_line(line)
@@ -33,32 +33,32 @@ class MiniSmtpServer < GServer
33
33
  when (/^(HELO|EHLO)/)
34
34
  return "220 go on...\r\n"
35
35
  when (/^QUIT/)
36
- @connection_active = false
36
+ Thread.current[:connection_active] = false
37
37
  return ""
38
38
  when (/^MAIL FROM\:/)
39
- @message[:from] = line.gsub(/^MAIL FROM\:/, '').strip
39
+ Thread.current[:message][:from] = line.gsub(/^MAIL FROM\:/, '').strip
40
40
  return "220 OK\r\n"
41
41
  when (/^RCPT TO\:/)
42
- @message[:to] = line.gsub(/^RCPT TO\:/, '').strip
42
+ Thread.current[:message][:to] = line.gsub(/^RCPT TO\:/, '').strip
43
43
  return "220 OK\r\n"
44
44
  when (/^DATA/)
45
- @data_mode = true
45
+ Thread.current[:data_mode] = true
46
46
  return "354 Enter message, ending with \".\" on a line by itself\r\n"
47
47
  end
48
48
 
49
49
  # If we are in data mode and the entire message consists
50
50
  # solely of a period on a line by itself then we
51
51
  # are being told to exit data mode
52
- if((@data_mode) && (line.chomp =~ /^\.$/))
53
- @message[:data] += line
54
- @data_mode = false
52
+ if((Thread.current[:data_mode]) && (line.chomp =~ /^\.$/))
53
+ Thread.current[:message][:data] += line
54
+ Thread.current[:data_mode] = false
55
55
  return "220 OK\r\n"
56
56
  end
57
57
 
58
58
  # If we are in date mode then we need to add
59
59
  # the new data to the message
60
- if(@data_mode)
61
- @message[:data] += line
60
+ if(Thread.current[:data_mode])
61
+ Thread.current[:message][:data] += line
62
62
  return ""
63
63
  else
64
64
  # If we somehow get to this point then
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{mini-smtp-server}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Aaron Gough"]
12
+ s.date = %q{2010-11-05}
13
+ s.description = %q{A small and simple SMTP server}
14
+ s.email = %q{aaron@aarongough.com}
15
+ s.extra_rdoc_files = [
16
+ "MIT-LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "MIT-LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/mini-smtp-server.rb",
25
+ "lib/mini-smtp-server/mini-smtp-server.rb",
26
+ "mini-smtp-server.gemspec",
27
+ "test/setup/.gitignore",
28
+ "test/setup/custom_assertions.rb",
29
+ "test/setup/test_unit_extensions.rb",
30
+ "test/test_helper.rb",
31
+ "test/unit/mini_smtp_server_test.rb"
32
+ ]
33
+ s.homepage = %q{https://github.com/aarongough/mini-smtp-server}
34
+ s.rdoc_options = ["--charset=UTF-8", "--line-numbers", "--inline-source"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.7}
37
+ s.summary = %q{A small and simple SMTP server}
38
+ s.test_files = [
39
+ "test/setup/custom_assertions.rb",
40
+ "test/setup/test_unit_extensions.rb",
41
+ "test/test_helper.rb",
42
+ "test/unit/mini_smtp_server_test.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ else
51
+ end
52
+ else
53
+ end
54
+ end
55
+
@@ -20,7 +20,7 @@ class MiniSmtpServerTest < Test::Unit::TestCase
20
20
 
21
21
  def setup
22
22
  $messages = []
23
- @server = TestSmtpServer.new(1234)
23
+ @server = TestSmtpServer.new
24
24
  @server.start
25
25
  end
26
26
 
@@ -70,7 +70,7 @@ class MiniSmtpServerTest < Test::Unit::TestCase
70
70
  private
71
71
 
72
72
  def send_mail(message = $example_mail, from_address = "smtp@test.com", to_address = "some1@test.com")
73
- Net::SMTP.start('127.0.0.1', 1234) do |smtp|
73
+ Net::SMTP.start('127.0.0.1', 2525) do |smtp|
74
74
  smtp.send_message(message, from_address, to_address)
75
75
  smtp.finish
76
76
  sleep 0.01
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Gough
@@ -31,8 +31,10 @@ files:
31
31
  - MIT-LICENSE
32
32
  - README.rdoc
33
33
  - Rakefile
34
+ - VERSION
34
35
  - lib/mini-smtp-server.rb
35
36
  - lib/mini-smtp-server/mini-smtp-server.rb
37
+ - mini-smtp-server.gemspec
36
38
  - test/setup/.gitignore
37
39
  - test/setup/custom_assertions.rb
38
40
  - test/setup/test_unit_extensions.rb