cabbage 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/cabbage.gemspec +1 -1
  3. data/lib/cabbage/email/email.rb +24 -17
  4. metadata +10 -10
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cabbage"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Josh Lauer"]
@@ -26,8 +26,10 @@ module Cabbage
26
26
  attr_reader :raw_source, :raw_parsed, :header, :original_keys, :parts, :multipart
27
27
 
28
28
  def method_missing(m, *args, &block)
29
- if @header.keys.include?(m.intern)
30
- @header[m.intern]
29
+ if self.keys.include?(m)
30
+ self[m]
31
+ elsif self.key.include?(m.intern)
32
+ self[m.intern]
31
33
  else
32
34
  raise "undefined method in Cabbage::Email"
33
35
  end
@@ -53,13 +55,9 @@ module Cabbage
53
55
  @original_keys = @raw_parsed[:original_keys]
54
56
  if header[:content_type].include?("multipart")
55
57
  @multipart = true
56
- make_flat(@raw_parsed).each do |raw_part|
57
- @parts << MimePart.new(raw_part)
58
- end
59
- else
60
- make_flat(@raw_parsed).each do |raw_part|
61
- @parts << MimePart.new(raw_part)
62
- end
58
+ end
59
+ make_flat(@raw_parsed).each do |raw_part|
60
+ @parts << MimePart.new(raw_part)
63
61
  end
64
62
  return true
65
63
  end
@@ -71,19 +69,29 @@ module Cabbage
71
69
  def [](key)
72
70
  if @header.has_key?(key)
73
71
  @header[key]
74
- elsif key == :body
75
- self.body
76
72
  elsif self.mime_types.include?(key)
77
73
  @parts[self.mime_types.index(key)].body
78
- elsif key.class == FixNum
79
-
74
+ elsif key.class == String && self.keys.include?(key.intern)
75
+ self[key.intern]
76
+ elsif key == :body
77
+ self.body
78
+ elsif key == :plaintext && self.mime_types.include?("text/plain")
79
+ @parts[self.mime_types.index("text/plain")].body
80
+ elsif key == :html && self.mime_types.include?("text/html")
81
+ @parts[self.mime_types.index("text/html")].body
82
+ elsif key == :attachments
83
+ self.attachments
84
+ elsif key.class == Fixnum
85
+ # to be implemented
86
+ nil
80
87
  else
88
+ # perhaps raise exception here?
81
89
  nil
82
90
  end
83
91
  end
84
92
 
85
93
  def keys
86
- @header.keys + [:body] + self.mime_types
94
+ @header.keys + [:body, :html, :plaintext, :attachments] + self.mime_types
87
95
  end
88
96
 
89
97
  def attachments
@@ -122,12 +130,11 @@ module Cabbage
122
130
  ########################## PRIVATE METHODS ##########################
123
131
  #####################################################################
124
132
 
125
- private
133
+ #private
126
134
 
127
135
  def make_flat(tree)
128
136
  results = []
129
-
130
- if tree[:body].class == Hash
137
+ if tree[:body].class == Array
131
138
  tree[:body].each do |this_part|
132
139
  if this_part[:header][:content_type] =~ /^multipart/
133
140
  results << make_flat(this_part)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cabbage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &12429820 !ruby/object:Gem::Requirement
16
+ requirement: &12777640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *12429820
24
+ version_requirements: *12777640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &12425540 !ruby/object:Gem::Requirement
27
+ requirement: &12760460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12425540
35
+ version_requirements: *12760460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &12420200 !ruby/object:Gem::Requirement
38
+ requirement: &12736820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12420200
46
+ version_requirements: *12736820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &12400380 !ruby/object:Gem::Requirement
49
+ requirement: &12733280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *12400380
57
+ version_requirements: *12733280
58
58
  description: More to come.
59
59
  email: josh.lauer75@gmail.com
60
60
  executables: []
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: 634790544501283345
97
+ hash: -3456766712988366960
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements: