Fix rake bug.(Move functions inside namespace)

This commit is contained in:
BoHung Chiu 2021-10-06 11:50:38 +08:00
parent 27deea2610
commit 80e1362ab6
1 changed files with 74 additions and 73 deletions

View File

@ -64,8 +64,7 @@ namespace :epaper do
paper.save paper.save
end end
end end
end def verify_email(from_addr,check_emails,tls) #true if check_email is ok
def verify_email(from_addr,check_emails,tls) #true if check_email is ok
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
TCPSocket.open(@address, @port) TCPSocket.open(@address, @port)
end end
@ -92,15 +91,15 @@ def verify_email(from_addr,check_emails,tls) #true if check_email is ok
end end
s.close s.close
invalid_emails invalid_emails
end end
def get_response(reqline) def get_response(reqline)
res = critical { res = critical {
@socket.writeline reqline @socket.writeline reqline
recv_response() recv_response()
} }
return res return res
end end
def recv_response def recv_response
buf = '' buf = ''
while true while true
line = @socket.readline line = @socket.readline
@ -108,8 +107,8 @@ def recv_response
break unless line[3,1] == '-' # "210-PIPELINING" break unless line[3,1] == '-' # "210-PIPELINING"
end end
Net::SMTP::Response.parse(buf) Net::SMTP::Response.parse(buf)
end end
def critical def critical
return Net::SMTP::Response.parse('200 dummy reply code') if @error_occurred return Net::SMTP::Response.parse('200 dummy reply code') if @error_occurred
begin begin
return yield() return yield()
@ -117,11 +116,11 @@ def critical
@error_occurred = true @error_occurred = true
raise raise
end end
end end
def ssl_socket(socket, context) def ssl_socket(socket, context)
OpenSSL::SSL::SSLSocket.new socket, context OpenSSL::SSL::SSLSocket.new socket, context
end end
def tlsconnect(s) def tlsconnect(s)
verified = false verified = false
s = ssl_socket(s, @ssl_context) s = ssl_socket(s, @ssl_context)
s.sync_close = true s.sync_close = true
@ -133,10 +132,12 @@ def tlsconnect(s)
s s
ensure ensure
s.close unless verified s.close unless verified
end end
def new_internet_message_io(s) def new_internet_message_io(s)
io = Net::InternetMessageIO.new(s) io = Net::InternetMessageIO.new(s)
io.read_timeout = @read_timeout io.read_timeout = @read_timeout
io.debug_output = @debug_output io.debug_output = @debug_output
io io
end
end end