Skip to content

Commit

Permalink
Merge pull request #1560 from tk0miya/net-smtp
Browse files Browse the repository at this point in the history
stdlib: Add types for net/smtp
  • Loading branch information
soutaro authored Nov 1, 2023
2 parents 3e5c12c + 0685bd3 commit f841f20
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ gem "rdoc", "~> 6.4.0"
# Test gems
gem "rbs-amber", path: "test/assets/test-gem"

# Bundled gems
gem "net-smtp"

group :minitest do
gem "minitest"
end
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ GEM
language_server-protocol (3.17.0.3)
marcel (1.0.2)
minitest (5.20.0)
net-protocol (0.2.1)
timeout
net-smtp (0.4.0)
net-protocol
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
Expand Down Expand Up @@ -82,6 +86,7 @@ GEM
tempfile (0.1.3)
test-unit (3.6.1)
power_assert
timeout (0.4.0)
unicode-display_width (2.5.0)

PLATFORMS
Expand All @@ -95,6 +100,7 @@ DEPENDENCIES
json
json-schema
minitest
net-smtp
rake
rake-compiler
rbs!
Expand Down
2 changes: 2 additions & 0 deletions stdlib/net-smtp/0/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- name: net-protocol
55 changes: 55 additions & 0 deletions stdlib/net-smtp/0/net-smtp.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module Net
# Module mixed in to all SMTP error classes
module SMTPError
attr_reader response: Response

def initialize: (Response response, ?message: String) -> void

def message: () -> String?
end

# Represents an SMTP authentication error.
class SMTPAuthenticationError < ProtoAuthError
include SMTPError
end

# Represents SMTP error code 4xx, a temporary error.
class SMTPServerBusy < ProtoServerError
include SMTPError
end

# Represents an SMTP command syntax error (error code 500)
class SMTPSyntaxError < ProtoSyntaxError
include SMTPError
end

# Represents a fatal SMTP error (error code 5xx, except for 500)
class SMTPFatalError < ProtoFatalError
include SMTPError
end

# Unexpected reply code returned from server.
class SMTPUnknownError < ProtoUnknownError
include SMTPError
end

# Command is not supported on server.
class SMTPUnsupportedCommand < ProtocolError
include SMTPError
end

class SMTP < Protocol
def self.start: (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) -> instance
| [T] (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) { (instance) -> T } -> T
| (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) -> instance
| [T] (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) { (instance) -> T } -> T

def initialize: (String address, ?Integer port) -> void
def send_message: (_Each[String] mail_src, String from_addr, *String to_addrs) -> void
end

class Response
end

class SMTPSession = SMTP
end

0 comments on commit f841f20

Please sign in to comment.