mail_extract 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mail_extract.rb CHANGED
@@ -5,6 +5,8 @@ module MailExtract
5
5
  class << self
6
6
  # Shortcut to MailExtract::Parser.new
7
7
  #
8
+ # @return [MailExtract::Parser]
9
+ #
8
10
  def new(body)
9
11
  MailExtract::Parser.new(body)
10
12
  end
@@ -15,6 +15,24 @@ module MailExtract
15
15
  detect_type(str)
16
16
  end
17
17
 
18
+ # Returns true if line was detected as text
19
+ #
20
+ def text?
21
+ type == :text
22
+ end
23
+
24
+ # Returns true if line was detected as quote
25
+ #
26
+ def quote?
27
+ type == :quote
28
+ end
29
+
30
+ # Returns true if line was detected as signature
31
+ #
32
+ def signature?
33
+ type == :signature
34
+ end
35
+
18
36
  private
19
37
 
20
38
  def detect_type(line)
@@ -5,7 +5,8 @@ module MailExtract
5
5
  attr_reader :body
6
6
 
7
7
  # Initialize a new MailExtract::Parser object
8
- # text - Email message body
8
+ #
9
+ # text - Email message body
9
10
  #
10
11
  def initialize(text)
11
12
  @lines = []
@@ -35,23 +36,14 @@ module MailExtract
35
36
  #
36
37
  def parse_line(str)
37
38
  line = MailExtract::Line.new(str)
38
- if line.type == :quote
39
- if @last_type == :text
40
- @type = :quote
41
- end
42
- elsif line.type == :text
43
- if @last_type == :quote
44
- @type = :text
45
- end
46
- if @last_type == :signature
47
- @type = :signature
48
- end
49
- elsif line.type == :signature
50
- if @last_type == :text
51
- @type = :signature
52
- elsif @last_type == :quote
53
- @type = :quote
54
- end
39
+ if line.quote?
40
+ if @last_type == :text ; @type = :quote ; end
41
+ elsif line.text?
42
+ if @last_type == :quote ; @type = :text ; end
43
+ if @last_type == :signature ; @type = :signature ; end
44
+ elsif line.signature?
45
+ if @last_type == :text ; @type = :signature ;
46
+ elsif @last_type == :quote ; @type = :quote ; end
55
47
  end
56
48
  @last_type = line.type
57
49
  @lines << line.body.strip if @type == :text
@@ -1,3 +1,5 @@
1
1
  module MailExtract
2
- VERSION = "0.1.0".freeze unless defined? ::MailExtract::VERSION
2
+ unless defined? ::MailExtract::VERSION
3
+ VERSION = "0.1.1".freeze
4
+ end
3
5
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_extract
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
5
+ version: 0.1.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - Dan Sosedoff
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-07-21 00:00:00 -05:00
13
+ date: 2011-08-02 00:00:00 -05:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,10 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 2
32
- - 6
33
24
  version: "2.6"
34
25
  type: :development
35
26
  version_requirements: *id001
@@ -72,18 +63,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
63
  requirements:
73
64
  - - ">="
74
65
  - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
66
  version: "0"
79
67
  required_rubygems_version: !ruby/object:Gem::Requirement
80
68
  none: false
81
69
  requirements:
82
70
  - - ">="
83
71
  - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
72
  version: "0"
88
73
  requirements: []
89
74