[前][次][番号順一覧][スレッド一覧]

ruby-changes:27677

From: drbrain <ko1@a...>
Date: Tue, 12 Mar 2013 02:27:24 +0900 (JST)
Subject: [ruby-changes:27677] drbrain:r39729 (trunk): * lib/net/smtp.rb: Added Net::SMTP#rset method to implement the SMTP

drbrain	2013-03-12 02:27:03 +0900 (Tue, 12 Mar 2013)

  New Revision: 39729

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39729

  Log:
    * lib/net/smtp.rb:  Added Net::SMTP#rset method to implement the SMTP
      RSET command.  [ruby-trunk - Feature #5373]
    * NEWS:  ditto.
    * test/net/smtp/test_smtp.rb:  Test for the above.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/lib/net/smtp.rb
    trunk/test/net/smtp/test_smtp.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39728)
+++ ChangeLog	(revision 39729)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar 12 02:25:19 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/net/smtp.rb:  Added Net::SMTP#rset method to implement the SMTP
+	  RSET command.  [ruby-trunk - Feature #5373]
+	* NEWS:  ditto.
+	* test/net/smtp/test_smtp.rb:  Test for the above.
+
 Mon Mar 11 22:44:57 2013  Tanaka Akira  <akr@f...>
 
 	* lib/resolv-replace.rb (TCPSocket#initialize): resolve the 3rd
Index: lib/net/smtp.rb
===================================================================
--- lib/net/smtp.rb	(revision 39728)
+++ lib/net/smtp.rb	(revision 39729)
@@ -815,6 +815,12 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/smtp.rb#L815
 
     public
 
+    # Aborts the current mail transaction
+
+    def rset
+      getok('RSET')
+    end
+
     def starttls
       getok('STARTTLS')
     end
Index: NEWS
===================================================================
--- NEWS	(revision 39728)
+++ NEWS	(revision 39729)
@@ -25,5 +25,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L25
   The ancestors of a singleton class now include that singleton class.
 
 === Stdlib updates (outstanding ones only)
+
+* Net::SMTP
+  * Added Net::SMTP#rset to implement the RSET comamnd
+
 === Stdlib compatibility issues (excluding feature bug fixes)
 === C API updates
Index: test/net/smtp/test_smtp.rb
===================================================================
--- test/net/smtp/test_smtp.rb	(revision 39728)
+++ test/net/smtp/test_smtp.rb	(revision 39729)
@@ -1,8 +1,26 @@ https://github.com/ruby/ruby/blob/trunk/test/net/smtp/test_smtp.rb#L1
 require 'net/smtp'
+require 'stringio'
 require 'minitest/autorun'
 
 module Net
   class TestSMTP < MiniTest::Unit::TestCase
+    class FakeSocket
+      def initialize out = "250 OK\n"
+        @write_io = StringIO.new
+        @read_io  = StringIO.new out
+      end
+
+      def writeline line
+        @write_io.write "#{line}\r\n"
+      end
+
+      def readline
+        line = @read_io.gets
+        raise 'ran out of input' unless line
+        line.chop
+      end
+    end
+
     def test_esmtp
       smtp = Net::SMTP.new 'localhost', 25
       assert smtp.esmtp
@@ -12,5 +30,12 @@ module Net https://github.com/ruby/ruby/blob/trunk/test/net/smtp/test_smtp.rb#L30
       assert_equal 'omg', smtp.esmtp
       assert_equal 'omg', smtp.esmtp?
     end
+
+    def test_rset
+      smtp = Net::SMTP.new 'localhost', 25
+      smtp.instance_variable_set :@socket, FakeSocket.new
+
+      assert smtp.rset
+    end
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]