mail-x_smtpapi 1.0.0.alpha → 1.0.0.alpha2
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 +4 -4
- data/lib/mail_x_smtpapi/field.rb +8 -7
- data/lib/mail_x_smtpapi/version.rb +1 -1
- data/test/mail_x_smtpapi_field_test.rb +8 -2
- metadata +2 -3
- data/lib/mail_x_smtpapi.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aa241982d4d0042b269a45812005b55639ed5aa
|
4
|
+
data.tar.gz: c3287e3ae8bf85afc9a29ea472f8830926bb78d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12e2dd0e22ee789a2c4e37fb26245f900dde5125a9d2d4d4209a13f8b8c4b390df8c77e0b578e34e39b6d16c73f4df629d1ff0936d730d13830960fd146a8874
|
7
|
+
data.tar.gz: c8e86d4849d4f7ed2eb6af0674c39709695b2c10b1ff4abad333856c2f61c7b0357c2de4e90823eb385b64edc33c5a69faf04077ada9e4c9fece2b6005f70d44
|
data/lib/mail_x_smtpapi/field.rb
CHANGED
@@ -2,7 +2,7 @@ require 'mail'
|
|
2
2
|
require_relative 'accessors'
|
3
3
|
|
4
4
|
module MailXSMTPAPI
|
5
|
-
class Field < ::Mail::
|
5
|
+
class Field < ::Mail::UnstructuredField
|
6
6
|
FIELD_NAME = 'x-smtpapi'
|
7
7
|
CAPITALIZED_FIELD = 'X-SMTPAPI'
|
8
8
|
|
@@ -14,22 +14,23 @@ module MailXSMTPAPI
|
|
14
14
|
include Filters
|
15
15
|
|
16
16
|
def initialize(value = nil, charset = 'utf-8')
|
17
|
-
|
17
|
+
self.charset = charset
|
18
|
+
self.name = CAPITALIZED_FIELD
|
19
|
+
self.value = value || {}
|
18
20
|
end
|
19
21
|
|
20
|
-
# emits JSON with extra spaces inserted for line wrapping.
|
21
22
|
def encoded
|
22
23
|
if empty?
|
23
24
|
''
|
24
25
|
else
|
25
|
-
"#{
|
26
|
+
"#{wrapped_value}\r\n"
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
#
|
30
|
-
#
|
30
|
+
# to take advantage of folding, decoded must return a string with
|
31
|
+
# emits JSON with extra spaces inserted for line wrapping.
|
31
32
|
def decoded
|
32
|
-
value
|
33
|
+
JSON.generate(value).gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
|
33
34
|
end
|
34
35
|
|
35
36
|
def empty?
|
@@ -20,9 +20,15 @@ class MailXSMTPAPI::FieldTest < MiniTest::Unit::TestCase
|
|
20
20
|
assert f.encoded.match(/\r\n$/)
|
21
21
|
end
|
22
22
|
|
23
|
+
def test_encoded_is_folded
|
24
|
+
f = subject.new('to' => 100.times.map{ 'test@example.com'} )
|
25
|
+
max_line_length = f.encoded.split(/[\r\n]+/).map(&:length).max
|
26
|
+
assert max_line_length < 998, "max line length: #{max_line_length}"
|
27
|
+
end
|
28
|
+
|
23
29
|
def test_decoded
|
24
|
-
h = {'to' => ['a@example.com']}
|
25
|
-
assert_equal
|
30
|
+
h = {'to' => ['a@example.com', 'b@example.com']}
|
31
|
+
assert_equal '{"to": ["a@example.com", "b@example.com"]}', subject.new(h).decoded
|
26
32
|
end
|
27
33
|
|
28
34
|
def test_empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-x_smtpapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lance Ivy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,7 +65,6 @@ files:
|
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
67
|
- lib/mail/x_smtpapi.rb
|
68
|
-
- lib/mail_x_smtpapi.rb
|
69
68
|
- lib/mail_x_smtpapi/accessors.rb
|
70
69
|
- lib/mail_x_smtpapi/field.rb
|
71
70
|
- lib/mail_x_smtpapi/version.rb
|