astrotrain 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{astrotrain}
5
- s.version = "0.4.3"
5
+ s.version = "0.4.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["technoweenie"]
9
- s.date = %q{2009-09-27}
9
+ s.date = %q{2009-10-02}
10
10
  s.email = %q{technoweenie@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -7,7 +7,7 @@ module Astrotrain
7
7
  # Wrapper around a TMail object
8
8
  class Message
9
9
  attr_accessor :body
10
- attr_reader :mail, :attachments
10
+ attr_reader :mail
11
11
 
12
12
  class << self
13
13
  attr_reader :queue_path, :archive_path
@@ -184,17 +184,15 @@ module Astrotrain
184
184
  end
185
185
 
186
186
  def body
187
- @body ||= begin
188
- process_message_body
189
- @body
190
- end
187
+ @body ||= process_message_body(:body)
191
188
  end
192
189
 
193
190
  def html
194
- @html ||= begin
195
- process_message_body
196
- @html
197
- end
191
+ @html ||= process_message_body(:html)
192
+ end
193
+
194
+ def attachments
195
+ @attachments ||= process_message_body(:attachments)
198
196
  end
199
197
 
200
198
  def raw
@@ -202,28 +200,15 @@ module Astrotrain
202
200
  end
203
201
 
204
202
  def header(key)
205
- @headers ||= {}
206
- if !@headers.key?(key)
207
- @headers[key] = if self.class.skipped_headers.include?(key)
208
- nil
209
- else
210
- header = @mail.header[key]
211
- begin
212
- header.to_s
213
- rescue
214
- header.raw_body
215
- end
216
- end
217
- end
218
- @headers[key]
203
+ headers[key]
219
204
  end
220
205
 
221
206
  def headers
222
207
  @headers ||= begin
223
208
  h = {}
224
209
  @mail.header.each do |key, value|
225
- header_value = header(key)
226
- h[key] = header_value if header_value
210
+ next if self.class.skipped_headers.include?(key)
211
+ h[key] = read_header(key)
227
212
  end
228
213
  h
229
214
  end
@@ -280,7 +265,16 @@ module Astrotrain
280
265
  end
281
266
 
282
267
  protected
283
- def process_message_body
268
+ def read_header(key)
269
+ header = @mail.header[key]
270
+ begin
271
+ header.to_s
272
+ rescue
273
+ header.raw_body
274
+ end
275
+ end
276
+
277
+ def process_message_body(var = nil)
284
278
  if @mail.multipart?
285
279
  @attachments.clear
286
280
  @body, @html = [], []
@@ -295,6 +289,7 @@ module Astrotrain
295
289
  @body = convert_to_utf8(@body)
296
290
  @html = convert_to_utf8(@html)
297
291
  end
292
+ instance_variable_get "@#{var}" if var
298
293
  end
299
294
 
300
295
  def scan_parts(message)
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.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - technoweenie
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-27 00:00:00 -07:00
12
+ date: 2009-10-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency