astrotrain 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'astrotrain'
16
- s.version = '0.6.3'
17
- s.date = '2012-04-25'
16
+ s.version = '0.6.4'
17
+ s.date = '2012-09-25'
18
18
  s.rubyforge_project = 'astrotrain'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -61,6 +61,7 @@ Gem::Specification.new do |s|
61
61
  lib/astrotrain/transports/http_post.rb
62
62
  lib/astrotrain/transports/resque.rb
63
63
  test/fixtures/apple_multipart.txt
64
+ test/fixtures/bad_ascii.txt
64
65
  test/fixtures/bad_content_type.txt
65
66
  test/fixtures/bad_email_format.txt
66
67
  test/fixtures/basic.txt
@@ -1,5 +1,5 @@
1
1
  module Astrotrain
2
- VERSION = '0.6.3'
2
+ VERSION = '0.6.4'
3
3
 
4
4
  require 'utf8'
5
5
  require 'charlock_holmes'
@@ -146,10 +146,10 @@ module Astrotrain
146
146
  @headers ||= begin
147
147
  @mail.header.fields.inject({}) do |memo, field|
148
148
  name = field.name.downcase.to_s
149
+ next memo if self.class.skipped_headers.include?(name)
150
+
149
151
  header = unquoted_header(name)
150
- self.class.skipped_headers.include?(name) ?
151
- memo :
152
- memo.update(name => self.class.unescape(unquoted_header(name)))
152
+ memo.update(name => self.class.unescape(header))
153
153
  end
154
154
  end
155
155
  end
@@ -246,9 +246,11 @@ module Astrotrain
246
246
 
247
247
  # Stolen from Rack/Camping, remove the "+" => " " translation
248
248
  def self.unescape(s)
249
- s.gsub!(/((?:%[0-9a-fA-F]{2})+)/n){
250
- [$1.delete('%')].pack('H*')
251
- }
249
+ s.gsub!(/((?:%[0-9a-fA-F]{2})+)/n) do
250
+ original = $1.dup
251
+ replacement = [$1.delete('%')].pack('H*')
252
+ replacement.as_utf8.valid? ? replacement : original
253
+ end
252
254
  s
253
255
  end
254
256
 
@@ -0,0 +1,38 @@
1
+ Return-Path: <user@example.com>
2
+ X-Original-To: reply@reply.github.com
3
+ Delivered-To: reply@reply.github.com
4
+ From: Bob <user@example.com>
5
+ To: Processor <processor@astrotrain.com>
6
+ Subject: Sup
7
+ Date: Tue, 25 Sep 2012 14:45:37 +0000
8
+ Message-ID: <CC871184.427E3%abc.def@ghi.com>
9
+ Content-Type: multipart/alternative;
10
+ boundary="_000_CC871184427E3_"
11
+
12
+ --_000_CC871184427E3_
13
+ Content-Type: text/plain; charset="us-ascii"
14
+ Content-Transfer-Encoding: quoted-printable
15
+
16
+ Sup
17
+
18
+ --_000_CC871184427E3_
19
+ Content-Type: text/html; charset="us-ascii"
20
+ Content-ID: <4CD4FB706F8DDB4EBE9DEC869CBB1D20@namprd06.prod.outlook.com>
21
+ Content-Transfer-Encoding: quoted-printable
22
+
23
+ <html>
24
+ <head>
25
+ <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
26
+ >
27
+ </head>
28
+ <body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-lin=
29
+ e-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-fami=
30
+ ly: Calibri, sans-serif; ">
31
+ <div>Sup</div>
32
+ <br clear=3Dall> =
33
+
34
+ </body>
35
+ </html>
36
+
37
+
38
+ --_000_CC871184427E3_--
@@ -192,6 +192,13 @@ class MessageParsingTest < Test::Unit::TestCase
192
192
  assert_mail_utf8 msg
193
193
  end
194
194
 
195
+ test "deals with bad ascii" do
196
+ path = mail(:bad_ascii)
197
+ msg = Astrotrain::Message.read(path)
198
+ assert_mail_utf8 msg
199
+ assert msg.headers['message-id'].as_utf8.valid?
200
+ end
201
+
195
202
  def assert_mail_utf8(mail)
196
203
  [:html, :body].each do |attr|
197
204
  str = mail.send(attr)
@@ -2,6 +2,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
2
2
 
3
3
  Astrotrain::Transports.load :http
4
4
  Astrotrain::Transports.load :resque
5
+ if redis_url = ENV['GH_REDIS_URL'] || ENV['REDIS_URL']
6
+ Resque.redis = redis_url
7
+ end
5
8
 
6
9
  class TransportTest < Test::Unit::TestCase
7
10
  class Job
@@ -97,6 +100,22 @@ class TransportTest < Test::Unit::TestCase
97
100
  assert !params.key?(:attachments)
98
101
  end
99
102
 
103
+ test "encoding bad ascii" do
104
+ extend Resque::Helpers
105
+
106
+ msg = astrotrain(:bad_ascii)
107
+ params = Astrotrain::Transports::Resque.create_hash(msg, 'bar@example.com')
108
+ params = decode(encode(params))
109
+
110
+ assert_equal 'processor@astrotrain.com', params['to'][0]['address']
111
+ assert_equal 'Processor', params['to'][0]['name']
112
+ assert_equal 'user@example.com', params['from'][0]['address']
113
+ assert_equal 'Bob', params['from'][0]['name']
114
+ assert_equal msg.subject, params['subject']
115
+ assert_equal msg.body, params['body']
116
+ assert !params.key?('attachments')
117
+ end
118
+
100
119
  def stub_http
101
120
  Astrotrain::Transports::HttpPost.connection =
102
121
  Faraday::Connection.new do |builder|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astrotrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-25 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: utf8
16
- requirement: &70343659221820 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.1.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70343659221820
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.8
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: mail
27
- requirement: &70343659220900 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.4.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70343659220900
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.4.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: i18n
38
- requirement: &70343659220240 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.6.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70343659220240
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: faraday
49
- requirement: &70343659219600 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 0.5.0
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70343659219600
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.5.0
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: addressable
60
- requirement: &70343659219040 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 2.2.4
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70343659219040
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.2.4
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: charlock_holmes
71
- requirement: &70343659218520 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: 0.6.8
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70343659218520
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.6.8
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: resque
82
- requirement: &70343659217960 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,7 +117,12 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *70343659217960
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  description: email => http post
92
127
  email: technoweenie@gmail.com
93
128
  executables: []
@@ -104,6 +139,7 @@ files:
104
139
  - lib/astrotrain/transports/http_post.rb
105
140
  - lib/astrotrain/transports/resque.rb
106
141
  - test/fixtures/apple_multipart.txt
142
+ - test/fixtures/bad_ascii.txt
107
143
  - test/fixtures/bad_content_type.txt
108
144
  - test/fixtures/bad_email_format.txt
109
145
  - test/fixtures/basic.txt
@@ -140,9 +176,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
176
  - - ! '>='
141
177
  - !ruby/object:Gem::Version
142
178
  version: '0'
143
- segments:
144
- - 0
145
- hash: 1829060415533477535
146
179
  required_rubygems_version: !ruby/object:Gem::Requirement
147
180
  none: false
148
181
  requirements:
@@ -151,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
184
  version: '0'
152
185
  requirements: []
153
186
  rubyforge_project: astrotrain
154
- rubygems_version: 1.8.10
187
+ rubygems_version: 1.8.23
155
188
  signing_key:
156
189
  specification_version: 2
157
190
  summary: email => http post