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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c8f40288af6ce36eda5971ed93ede0bdb8cf077
4
- data.tar.gz: 7f79cd1c3ab012ae3ddee78820d42e1e6b5500c8
3
+ metadata.gz: 2aa241982d4d0042b269a45812005b55639ed5aa
4
+ data.tar.gz: c3287e3ae8bf85afc9a29ea472f8830926bb78d0
5
5
  SHA512:
6
- metadata.gz: 0be1d7588bd5278f3f042744254d2dc939a22df7c537d2ecdb1ce1de722aee27e6a30b102e8da8407d4b2137cabc7f89df3bccba07a42bd2c30cad1cca777a3c
7
- data.tar.gz: f553f34ef34eedf8da1e84604b2f0023bc6e11618c2572540184f8af5cbd9311d10eef25a7fef173537d0a7f51184d0a4b7c4d49f6846316952d2cb88f245ee9
6
+ metadata.gz: 12e2dd0e22ee789a2c4e37fb26245f900dde5125a9d2d4d4209a13f8b8c4b390df8c77e0b578e34e39b6d16c73f4df629d1ff0936d730d13830960fd146a8874
7
+ data.tar.gz: c8e86d4849d4f7ed2eb6af0674c39709695b2c10b1ff4abad333856c2f61c7b0357c2de4e90823eb385b64edc33c5a69faf04077ada9e4c9fece2b6005f70d44
@@ -2,7 +2,7 @@ require 'mail'
2
2
  require_relative 'accessors'
3
3
 
4
4
  module MailXSMTPAPI
5
- class Field < ::Mail::StructuredField
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
- super(FIELD_NAME, value || {}, charset)
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
- "#{CAPITALIZED_FIELD}: #{JSON.generate(value).gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')}\r\n"
26
+ "#{wrapped_value}\r\n"
26
27
  end
27
28
  end
28
29
 
29
- # the decoded version is good for interacting with the header in code
30
- # see: Mail::StructuredField#default
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?
@@ -1,3 +1,3 @@
1
1
  module MailXSMTPAPI
2
- VERSION = '1.0.0.alpha'
2
+ VERSION = '1.0.0.alpha2'
3
3
  end
@@ -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 h, subject.new(h).decoded
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.alpha
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-09 00:00:00.000000000 Z
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
@@ -1,5 +0,0 @@
1
- # library
2
- require 'mail_x_smtpapi/field'
3
-
4
- # integration
5
- require 'mail/x_smtpapi'