File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -725,6 +725,8 @@ class IMAP < Protocol
725
725
"UTF8=ONLY" => "UTF8=ACCEPT" ,
726
726
} . freeze
727
727
728
+ autoload :Config , File . expand_path ( "imap/config" , __dir__ )
729
+
728
730
autoload :SASL , File . expand_path ( "imap/sasl" , __dir__ )
729
731
autoload :SASLAdapter , File . expand_path ( "imap/sasl_adapter" , __dir__ )
730
732
autoload :StringPrep , File . expand_path ( "imap/stringprep" , __dir__ )
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+ # :markup: markdown
3
+
4
+ module Net
5
+ class IMAP
6
+
7
+ # Net::IMAP::Config stores configuration options for Net::IMAP clients.
8
+ #
9
+ # ## Thread Safety
10
+ #
11
+ # *NOTE:* Updates to config objects are not synchronized for thread-safety.
12
+ #
13
+ class Config
14
+
15
+ # The debug mode (boolean)
16
+ attr_accessor :debug
17
+ alias debug? debug
18
+
19
+ # Seconds to wait until a connection is opened.
20
+ #
21
+ # If the IMAP object cannot open a connection within this time,
22
+ # it raises a Net::OpenTimeout exception. See Net::IMAP.new.
23
+ attr_accessor :open_timeout
24
+
25
+ # Seconds to wait until an IDLE response is received, after
26
+ # the client asks to leave the IDLE state. See Net::IMAP#idle_done.
27
+ attr_accessor :idle_response_timeout
28
+
29
+ # Creates a new config object and initialize its attribute with +attrs+.
30
+ #
31
+ # If a block is given, the new config object is yielded to it.
32
+ def initialize ( **attrs )
33
+ super ( )
34
+ attrs . each do send ( :"#{ _1 } =" , _2 ) end
35
+ yield self if block_given?
36
+ end
37
+
38
+ end
39
+ end
40
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "net/imap"
4
+ require "test/unit"
5
+
6
+ class ConfigTest < Test ::Unit ::TestCase
7
+ Config = Net ::IMAP ::Config
8
+
9
+ test "#debug" do
10
+ assert Config . new ( debug : true ) . debug
11
+ refute Config . new ( debug : false ) . debug
12
+ assert Config . new ( debug : true ) . debug?
13
+ refute Config . new ( debug : false ) . debug?
14
+ config = Config . new do |c |
15
+ c . debug = true
16
+ end
17
+ assert config . debug
18
+ config = Config . new
19
+ config . debug = true
20
+ assert config . debug
21
+ assert config . debug?
22
+ config . debug = false
23
+ refute config . debug
24
+ refute config . debug?
25
+ end
26
+
27
+ end
You can’t perform that action at this time.
0 commit comments