mail-jenc 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce87dd8df9f740e8fa733161962382dd20924534f720769c4efe0b0bc91a22db
4
- data.tar.gz: 1755e999ed838155ed411e3703250ad61634176f0a8299796040ff19f2fe859b
3
+ metadata.gz: 659a351886afb57bc995d5059ba5a7771f342bb42543963abc18fcf7cfc2f232
4
+ data.tar.gz: a7403f922e8aeff212f8da861c6cb12da21bd54823c10b800e2f471d0e5a2701
5
5
  SHA512:
6
- metadata.gz: 55b29a387293f1af1b37066621967d1a6fc3143649866b438560f386e909500fa1f2a602f37f536477fc84189fbe8dbf5dc06a6d86f332cc0c6e15d1ae3f20d4
7
- data.tar.gz: 172ee348a7e0611d9fb0416f5a87b0cce1c3e461ded1cf628b72c8127e8ea7234b3af2404f901ebe5ca5dc16da78a8e73029689239ff415b5a0cf51232a0b811
6
+ metadata.gz: bec8d00b898b8b67bfe177aae5d40403f7b52f7a8477732091d51a1bbe8b82732a86f80b707371e3b4a0a155ae5eb60fe95310c4f28e6c4d13d5d10318da340b
7
+ data.tar.gz: ef8a1742265b7b27302ee91f7081da69183073152a750f94c4db0d7f86e8aa7d582b3ddb46f4a0fcbab625989da79d6de307d85edc6d0517f68e14cd9f7803bb
data/README.md CHANGED
@@ -4,8 +4,8 @@ A mail patch for encoding conventional mail.
4
4
 
5
5
  ## Dependencies
6
6
 
7
- * ruby 2.3+
8
- * mail 2.7
7
+ * ruby 2.5+
8
+ * mail 2.8
9
9
 
10
10
  ## Installation
11
11
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
5
  module AttachmentsListPatch
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
5
  class BEncoder
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
- module AddressFieldPatch
5
+ module CommonAddressFieldPatch
4
6
  def initialize(value, charset = nil)
5
7
  if Jenc.enabled?
6
8
  if value.is_a?(String) && !value.ascii_only? && value.encoding == Encoding::UTF_8 && charset && charset.downcase != 'utf-8'
@@ -19,9 +21,9 @@ module Mail
19
21
  end
20
22
  end
21
23
 
22
- klasses = ObjectSpace.each_object(Class).select { |klass| klass < Mail::CommonAddress }
24
+ klasses = ObjectSpace.each_object(Class).select { |klass| klass < Mail::CommonAddressField }
23
25
  klasses.each do |klass|
24
- unless klass.included_modules.include?(Mail::Jenc::AddressFieldPatch)
25
- klass.prepend Mail::Jenc::AddressFieldPatch
26
+ unless klass.included_modules.include?(Mail::Jenc::CommonAddressFieldPatch)
27
+ klass.prepend Mail::Jenc::CommonAddressFieldPatch
26
28
  end
27
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
5
  module UnstructuredFieldPatch
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
5
  module MessagePatch
@@ -14,12 +16,22 @@ module Mail
14
16
 
15
17
  def add_file(values)
16
18
  if Jenc.enabled?
17
- if values.is_a?(Hash) && header.charset
18
- values[:header_charset] = header.charset
19
+ if values.is_a?(Hash)
20
+ values[:charset] ||= nil
21
+ values[:header_charset] = header.charset if header.charset
19
22
  end
20
23
  end
21
24
  super
22
25
  end
26
+
27
+ def convert_to_multipart
28
+ unless has_content_type?
29
+ content_type = 'text/plain'
30
+ content_type += "; charset=#{charset}" if charset
31
+ self.content_type = content_type
32
+ end
33
+ super
34
+ end
23
35
  end
24
36
  end
25
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
5
  class PercentEncoder
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
5
  class RFC2231Encoder
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
- module Ruby19Patch
5
+ module UtilitiesPatch
4
6
  def transcode_charset(str, from_encoding, to_encoding = Encoding::UTF_8)
5
7
  if Jenc.enabled?
6
- coded = super(str, from_encoding, Ruby19Patch.preferred_charset(to_encoding))
8
+ coded = super(str, from_encoding, UtilitiesPatch.preferred_charset(to_encoding))
7
9
  coded.force_encoding(to_encoding)
8
10
  else
9
11
  super
@@ -19,6 +21,6 @@ module Mail
19
21
  end
20
22
  end
21
23
 
22
- unless Mail::Ruby19.singleton_class.included_modules.include?(Mail::Jenc::Ruby19Patch)
23
- Mail::Ruby19.singleton_class.prepend Mail::Jenc::Ruby19Patch
24
+ unless Mail::Utilities.singleton_class.included_modules.include?(Mail::Jenc::UtilitiesPatch)
25
+ Mail::Utilities.singleton_class.prepend Mail::Jenc::UtilitiesPatch
24
26
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mail
2
4
  module Jenc
3
- VERSION = '1.0.10'
5
+ VERSION = '1.1.0'
4
6
  end
5
7
  end
data/lib/mail/jenc.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mail'
2
4
 
3
5
  Dir["#{__dir__}/jenc/**/*.rb"].each do |file|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-jenc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshikazu Kaneta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-12 00:00:00.000000000 Z
11
+ date: 2023-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.7.1
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 2.8.0
19
+ version: 2.8.1
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 2.7.1
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 2.8.0
26
+ version: 2.8.1
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -85,12 +79,11 @@ files:
85
79
  - lib/mail/jenc/attachments_list_patch.rb
86
80
  - lib/mail/jenc/b_encoder.rb
87
81
  - lib/mail/jenc/fields/address_field_patch.rb
88
- - lib/mail/jenc/fields/content_type_field_patch.rb
89
82
  - lib/mail/jenc/fields/unstructured_field_patch.rb
90
83
  - lib/mail/jenc/message_patch.rb
91
84
  - lib/mail/jenc/percent_encoder.rb
92
85
  - lib/mail/jenc/rfc2231_encoder.rb
93
- - lib/mail/jenc/ruby_1_9_patch.rb
86
+ - lib/mail/jenc/utilities_patch.rb
94
87
  - lib/mail/jenc/version.rb
95
88
  homepage: https://github.com/kanety/mail-jenc
96
89
  licenses:
@@ -111,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
104
  - !ruby/object:Gem::Version
112
105
  version: '0'
113
106
  requirements: []
114
- rubygems_version: 3.3.3
107
+ rubygems_version: 3.2.22
115
108
  signing_key:
116
109
  specification_version: 4
117
110
  summary: A mail patch for encoding conventional mail
@@ -1,19 +0,0 @@
1
- module Mail
2
- module Jenc
3
- module ContentTypeFieldPatch
4
- def parameters
5
- if Jenc.enabled?
6
- super.tap do |parameters|
7
- parameters.delete('charset') if parameters.key?('boundary') || parameters.key?('name')
8
- end
9
- else
10
- super
11
- end
12
- end
13
- end
14
- end
15
- end
16
-
17
- unless Mail::ContentTypeField.included_modules.include?(Mail::Jenc::ContentTypeFieldPatch)
18
- Mail::ContentTypeField.prepend Mail::Jenc::ContentTypeFieldPatch
19
- end