Skip to content

Commit

Permalink
Merge pull request mikel#1510 from mikel/chore/remove-trailing-whites…
Browse files Browse the repository at this point in the history
…pace

[Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
  • Loading branch information
mikel authored Dec 3, 2022
2 parents 0588bee + 956a73e commit c9ea62c
Show file tree
Hide file tree
Showing 38 changed files with 307 additions and 307 deletions.
50 changes: 25 additions & 25 deletions lib/mail/body.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# encoding: utf-8
# frozen_string_literal: true
module Mail

# = Body
#
#
# The body is where the text of the email is stored. Mail treats the body
# as a single object. The body itself has no information about boundaries
# used in the MIME standard, it just looks at its content as either a single
# block of text, or (if it is a multipart message) as an array of blocks of text.
#
#
# A body has to be told to split itself up into a multipart message by calling
# #split with the correct boundary. This is because the body object has no way
# of knowing what the correct boundary is for itself (there could be many
# boundaries in a body in the case of a nested MIME text).
#
#
# Once split is called, Mail::Body will slice itself up on this boundary,
# assigning anything that appears before the first part to the preamble, and
# anything that appears after the closing boundary to the epilogue, then
# each part gets initialized into a Mail::Part object.
#
#
# The boundary that is used to split up the Body is also stored in the Body
# object for use on encoding itself back out to a string. You can
# object for use on encoding itself back out to a string. You can
# overwrite this if it needs to be changed.
#
#
# On encoding, the body will return the preamble, then each part joined by
# the boundary, followed by a closing boundary string and then the epilogue.
class Body
Expand Down Expand Up @@ -57,15 +57,15 @@ def init_with(coder)

# Matches this body with another body. Also matches the decoded value of this
# body with a string.
#
#
# Examples:
#
#
# body = Mail::Body.new('The body')
# body == body #=> true
#
#
# body = Mail::Body.new('The body')
# body == 'The body' #=> true
#
#
# body = Mail::Body.new("VGhlIGJvZHk=\n")
# body.encoding = 'base64'
# body == "The body" #=> true
Expand All @@ -76,28 +76,28 @@ def ==(other)
super
end
end

# Accepts a string and performs a regular expression against the decoded text
#
#
# Examples:
#
#
# body = Mail::Body.new('The body')
# body =~ /The/ #=> 0
#
#
# body = Mail::Body.new("VGhlIGJvZHk=\n")
# body.encoding = 'base64'
# body =~ /The/ #=> 0
def =~(regexp)
self.decoded =~ regexp
end

# Accepts a string and performs a regular expression against the decoded text
#
#
# Examples:
#
#
# body = Mail::Body.new('The body')
# body.match(/The/) #=> #<MatchData "The">
#
#
# body = Mail::Body.new("VGhlIGJvZHk=\n")
# body.encoding = 'base64'
# body.match(/The/) #=> #<MatchData "The">
Expand Down Expand Up @@ -125,7 +125,7 @@ def include?(other)
def set_sort_order(order)
@part_sort_order = order
end

# Allows you to sort the parts according to the default sort order, or the sort order you
# set with :set_sort_order.
#
Expand All @@ -137,7 +137,7 @@ def sort_parts!
end
@parts.sort!(@part_sort_order)
end

def negotiate_best_encoding(message_encoding, allowed_encodings = nil)
Mail::Encodings::TransferEncoding.negotiate(message_encoding, encoding, raw_source, allowed_encodings)
end
Expand All @@ -164,7 +164,7 @@ def encoded(transfer_encoding = nil)
# Cannot decode, so skip normalization
raw_source
else
# Decode then encode to normalize and allow transforming
# Decode then encode to normalize and allow transforming
# from base64 to Q-P and vice versa
decoded = dec.decode(raw_source)
if defined?(Encoding) && charset && charset != "US-ASCII"
Expand All @@ -183,7 +183,7 @@ def decoded
Encodings.get_encoding(encoding).decode(raw_source)
end
end

def to_s
decoded
end
Expand Down Expand Up @@ -289,11 +289,11 @@ def extract_parts
end
parts.map(&:first)
end

def crlf_boundary
"\r\n--#{boundary}\r\n"
end

def end_boundary
"\r\n--#{boundary}--\r\n"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/field_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true
module Mail

# Field List class provides an enhanced array that keeps a list of
# Field List class provides an enhanced array that keeps a list of
# email fields in order. And allows you to insert new fields without
# having to worry about the order they will appear in.
class FieldList < Array
Expand Down
52 changes: 26 additions & 26 deletions lib/mail/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
module Mail

# Allows you to create a new Mail::Message object.
#
#
# You can make an email via passing a string or passing a block.
#
#
# For example, the following two examples will create the same email
# message:
#
#
# Creating via a string:
#
#
# string = "To: mikel@test.lindsaar.net\r\n"
# string << "From: bob@test.lindsaar.net\r\n"
# string << "Subject: This is an email\r\n"
# string << "\r\n"
# string << "This is the body"
# Mail.new(string)
#
#
# Or creating via a block:
#
#
# message = Mail.new do
# to 'mikel@test.lindsaar.net'
# from 'bob@test.lindsaar.net'
# subject 'This is an email'
# body 'This is the body'
# end
#
#
# Or creating via a hash (or hash like object):
#
#
# message = Mail.new({:to => 'mikel@test.lindsaar.net',
# 'from' => 'bob@test.lindsaar.net',
# :subject => 'This is an email',
# :body => 'This is the body' })
#
#
# Note, the hash keys can be strings or symbols, the passed in object
# does not need to be a hash, it just needs to respond to :each_pair
# and yield each key value pair.
#
#
# As a side note, you can also create a new email through creating
# a Mail::Message object directly and then passing in values via string,
# symbol or direct method calls. See Mail::Message for more information.
#
#
# mail = Mail.new
# mail.to = 'mikel@test.lindsaar.net'
# mail[:from] = 'bob@test.lindsaar.net'
Expand All @@ -54,20 +54,20 @@ def self.new(*args, &block)
# Sets the default delivery method and retriever method for all new Mail objects.
# The delivery_method and retriever_method default to :smtp and :pop3, with defaults
# set.
#
#
# So sending a new email, if you have an SMTP server running on localhost is
# as easy as:
#
#
# Mail.deliver do
# to 'mikel@test.lindsaar.net'
# from 'bob@test.lindsaar.net'
# subject 'hi there!'
# body 'this is a body'
# end
#
#
# If you do not specify anything, you will get the following equivalent code set in
# every new mail object:
#
#
# Mail.defaults do
# delivery_method :smtp, { :address => "localhost",
# :port => 25,
Expand All @@ -76,24 +76,24 @@ def self.new(*args, &block)
# :password => nil,
# :authentication => nil,
# :enable_starttls_auto => true }
#
#
# retriever_method :pop3, { :address => "localhost",
# :port => 995,
# :user_name => nil,
# :password => nil,
# :enable_ssl => true }
# end
#
#
# Mail.delivery_method.new #=> Mail::SMTP instance
# Mail.retriever_method.new #=> Mail::POP3 instance
#
# Each mail object inherits the default set in Mail.delivery_method, however, on
# a per email basis, you can override the method:
#
# mail.delivery_method :smtp
#
#
# Or you can override the method and pass in settings:
#
#
# mail.delivery_method :smtp, :address => 'some.host'
def self.defaults(&block)
Configuration.instance.instance_eval(&block)
Expand All @@ -112,21 +112,21 @@ def self.retriever_method
# Send an email using the default configuration. You do need to set a default
# configuration first before you use self.deliver, if you don't, an appropriate
# error will be raised telling you to.
#
#
# If you do not specify a delivery type, SMTP will be used.
#
#
# Mail.deliver do
# to 'mikel@test.lindsaar.net'
# from 'ada@test.lindsaar.net'
# subject 'This is a test email'
# body 'Not much to say here'
# end
#
#
# You can also do:
#
#
# mail = Mail.read('email.eml')
# mail.deliver!
#
#
# And your email object will be created and sent.
def self.deliver(*args, &block)
mail = self.new(args, &block)
Expand Down Expand Up @@ -190,7 +190,7 @@ def Mail.connection(&block)

# You can register an object to be informed of every email that is sent through
# this method.
#
#
# Your object needs to respond to a single method #delivered_email(mail)
# which receives the email that is sent.
def self.register_observer(observer)
Expand All @@ -208,7 +208,7 @@ def self.unregister_observer(observer)
# You can register an object to be given every mail object that will be sent,
# before it is sent. So if you want to add special headers or modify any
# email that gets sent through the Mail library, you can do so.
#
#
# Your object needs to respond to a single method #delivering_email(mail)
# which receives the email that is about to be sent. Make your modifications
# directly to this object.
Expand Down
4 changes: 2 additions & 2 deletions lib/mail/network/delivery_methods/file_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
module Mail
# FileDelivery class delivers emails into multiple files based on the destination
# address. Each file is appended to if it already exists.
#
#
# So if you have an email going to fred@test, bob@test, joe@anothertest, and you
# set your location path to /path/to/mails then FileDelivery will create the directory
# if it does not exist, and put one copy of the email in three files, called
# by their message id
#
#
# Make sure the path you specify with :location is writable by the Ruby process
# running Mail.
class FileDelivery
Expand Down
30 changes: 15 additions & 15 deletions lib/mail/network/delivery_methods/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

module Mail
# == Sending Email with SMTP
#
#
# Mail allows you to send emails using SMTP. This is done by wrapping Net::SMTP in
# an easy to use manner.
#
#
# === Sending via SMTP server on Localhost
#
#
# Sending locally (to a postfix or sendmail server running on localhost) requires
# no special setup. Just to Mail.deliver &block or message.deliver! and it will
# be sent in this method.
#
#
# === Sending via MobileMe
#
#
# Mail.defaults do
# delivery_method :smtp, { :address => "smtp.me.com",
# :port => 587,
Expand All @@ -24,9 +24,9 @@ module Mail
# :authentication => 'plain',
# :enable_starttls_auto => true }
# end
#
#
# === Sending via GMail
#
#
# Mail.defaults do
# delivery_method :smtp, { :address => "smtp.gmail.com",
# :port => 587,
Expand All @@ -48,30 +48,30 @@ module Mail
# verify mode constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER),
# or a string containing the name of an OpenSSL verify mode (none, peer).
#
# === Others
#
# === Others
#
# Feel free to send me other examples that were tricky
#
#
# === Delivering the email
#
#
# Once you have the settings right, sending the email is done by:
#
#
# Mail.deliver do
# to 'mikel@test.lindsaar.net'
# from 'ada@test.lindsaar.net'
# subject 'testing sendmail'
# body 'testing sendmail'
# end
#
#
# Or by calling deliver on a Mail message
#
#
# mail = Mail.new do
# to 'mikel@test.lindsaar.net'
# from 'ada@test.lindsaar.net'
# subject 'testing sendmail'
# body 'testing sendmail'
# end
#
#
# mail.deliver!
class SMTP
attr_accessor :settings
Expand Down
Loading

0 comments on commit c9ea62c

Please sign in to comment.