Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mail.require_silently for parser warnings #1557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def self.eager_autoload!
@@autoloads.each { |_,path| require(path) }
end

def self.require_silently(file) # :nodoc:
before, $-w = $-w, false
require(file)
ensure
$-w = before
end

# Autoload mail send and receive classes.
require 'mail/network'

Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/address.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/address_lists_parser'
Mail.require_silently 'mail/parsers/address_lists_parser'
require 'mail/constants'
require 'mail/utilities'

Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/address_list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/address_lists_parser'
Mail.require_silently 'mail/parsers/address_lists_parser'

module Mail
class AddressList #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/content_disposition_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/content_disposition_parser'
Mail.require_silently 'mail/parsers/content_disposition_parser'

module Mail
class ContentDispositionElement #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/content_location_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/content_location_parser'
Mail.require_silently 'mail/parsers/content_location_parser'

module Mail
class ContentLocationElement #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/content_transfer_encoding_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/content_transfer_encoding_parser'
Mail.require_silently 'mail/parsers/content_transfer_encoding_parser'

module Mail
class ContentTransferEncodingElement #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/content_type_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/content_type_parser'
Mail.require_silently 'mail/parsers/content_type_parser'

module Mail
class ContentTypeElement #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/date_time_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/date_time_parser'
Mail.require_silently 'mail/parsers/date_time_parser'

module Mail
class DateTimeElement #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/envelope_from_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/envelope_from_parser'
Mail.require_silently 'mail/parsers/envelope_from_parser'
require 'date'

module Mail
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/message_ids_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/message_ids_parser'
Mail.require_silently 'mail/parsers/message_ids_parser'
require 'mail/utilities'

module Mail
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/mime_version_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/mime_version_parser'
Mail.require_silently 'mail/parsers/mime_version_parser'

module Mail
class MimeVersionElement #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/phrase_list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/phrase_lists_parser'
Mail.require_silently 'mail/parsers/phrase_lists_parser'
require 'mail/utilities'

module Mail
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/elements/received_element.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/received_parser'
Mail.require_silently 'mail/parsers/received_parser'
require 'mail/utilities'
require 'date'

Expand Down
22 changes: 11 additions & 11 deletions lib/mail/parsers.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require 'mail/parsers/address_lists_parser'
require 'mail/parsers/content_disposition_parser'
require 'mail/parsers/content_location_parser'
require 'mail/parsers/content_transfer_encoding_parser'
require 'mail/parsers/content_type_parser'
require 'mail/parsers/date_time_parser'
require 'mail/parsers/envelope_from_parser'
require 'mail/parsers/message_ids_parser'
require 'mail/parsers/mime_version_parser'
require 'mail/parsers/phrase_lists_parser'
require 'mail/parsers/received_parser'
Mail.require_silently 'mail/parsers/address_lists_parser'
Mail.require_silently 'mail/parsers/content_disposition_parser'
Mail.require_silently 'mail/parsers/content_location_parser'
Mail.require_silently 'mail/parsers/content_transfer_encoding_parser'
Mail.require_silently 'mail/parsers/content_type_parser'
Mail.require_silently 'mail/parsers/date_time_parser'
Mail.require_silently 'mail/parsers/envelope_from_parser'
Mail.require_silently 'mail/parsers/message_ids_parser'
Mail.require_silently 'mail/parsers/mime_version_parser'
Mail.require_silently 'mail/parsers/phrase_lists_parser'
Mail.require_silently 'mail/parsers/received_parser'