email_reply_parser 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,7 +7,16 @@ This is what GitHub uses to display comments that were created from
7
7
  email replies. This code is being open sourced in an effort to
8
8
  crowdsource the quality of our email representation.
9
9
 
10
- See more at http://help.github.com/code/email_reply_parser/
10
+ See more at the [Rocco docs][rocco].
11
+
12
+ [rocco]: http://help.github.com/code/email_reply_parser/
13
+
14
+ ## Problem?
15
+
16
+ If you have a question about the behavior and formatting of email replies on GitHub, check out [support][support]. If you have a specific issue regarding this library, then hit up the [Issues][issues].
17
+
18
+ [support]: http://support.github.com/
19
+ [issues]: https://github.com/github/email_reply_parser/issues
11
20
 
12
21
  ## Installation
13
22
 
@@ -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 = 'email_reply_parser'
16
- s.version = '0.2.0'
17
- s.date = '2011-03-17'
16
+ s.version = '0.3.0'
17
+ s.date = '2011-08-23'
18
18
  s.rubyforge_project = 'email_reply_parser'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -68,6 +68,7 @@ Gem::Specification.new do |s|
68
68
  test/emails/email_1_1.txt
69
69
  test/emails/email_1_2.txt
70
70
  test/emails/email_1_3.txt
71
+ test/emails/email_1_4.txt
71
72
  ]
72
73
  # = MANIFEST =
73
74
 
@@ -30,7 +30,7 @@ require 'strscan'
30
30
  #
31
31
  # [mail]: https://github.com/mikel/mail
32
32
  class EmailReplyParser
33
- VERSION = "0.2.0"
33
+ VERSION = "0.3.0"
34
34
 
35
35
  # Splits an email body into a list of Fragments.
36
36
  #
@@ -74,7 +74,7 @@ class EmailReplyParser
74
74
  @fragment = nil
75
75
 
76
76
  # Use the StringScanner to pull out each line of the email content.
77
- @scanner = StringScanner.new(text)
77
+ @scanner = StringScanner.new(text)
78
78
  while line = @scanner.scan_until(/\n/)
79
79
  scan_line(line)
80
80
  end
@@ -113,7 +113,7 @@ class EmailReplyParser
113
113
 
114
114
  # We're looking for leading `>`'s to see if this line is part of a
115
115
  # quoted Fragment.
116
- line_levels = line =~ /(>+)$/ ? $1.size : 0
116
+ is_quoted = !!(line =~ /(>+)$/)
117
117
 
118
118
  # Mark the current Fragment as a signature if the current line is empty
119
119
  # and the Fragment starts with a common signature indicator.
@@ -128,14 +128,14 @@ class EmailReplyParser
128
128
  # reply header also counts as part of the quoted Fragment, even though
129
129
  # it doesn't start with `>`.
130
130
  if @fragment &&
131
- ((@fragment.quoted? != line_levels.zero?) ||
132
- (@fragment.quoted? && quote_header?(line)))
131
+ ((@fragment.quoted? == is_quoted) ||
132
+ (@fragment.quoted? && (quote_header?(line) || line == EMPTY)))
133
133
  @fragment.lines << line
134
134
 
135
135
  # Otherwise, finish the fragment and start a new one.
136
136
  else
137
137
  finish_fragment
138
- @fragment = Fragment.new(!line_levels.zero?, line)
138
+ @fragment = Fragment.new(is_quoted, line)
139
139
  end
140
140
  end
141
141
 
@@ -63,6 +63,14 @@ I am currently using the Java HTTP API.\n", reply.fragments[0].to_s
63
63
  assert_match /^_/, reply.fragments[5].to_s
64
64
  end
65
65
 
66
+ def test_recognizes_date_string_above_quote
67
+ reply = email :email_1_4
68
+
69
+ assert_match /^Awesome/, reply.fragments[0].to_s
70
+ assert_match /^On/, reply.fragments[1].to_s
71
+ assert_match /Loader/, reply.fragments[1].to_s
72
+ end
73
+
66
74
  def email(name)
67
75
  body = IO.read EMAIL_FIXTURE_PATH.join("#{name}.txt").to_s
68
76
  EmailReplyParser.read body
@@ -0,0 +1,5 @@
1
+ Awesome! I haven't had another problem with it.
2
+
3
+ On Aug 22, 2011, at 7:37 PM, defunkt<reply@reply.github.com> wrote:
4
+
5
+ > Loader seems to be working well.
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_reply_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 2
7
+ - 3
9
8
  - 0
10
- version: 0.2.0
9
+ version: 0.3.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Rick Olson
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-03-17 00:00:00 -07:00
17
+ date: 2011-08-23 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
@@ -38,6 +37,7 @@ files:
38
37
  - test/emails/email_1_1.txt
39
38
  - test/emails/email_1_2.txt
40
39
  - test/emails/email_1_3.txt
40
+ - test/emails/email_1_4.txt
41
41
  has_rdoc: true
42
42
  homepage: http://github.com/github/email_reply_parser
43
43
  licenses: []
@@ -48,27 +48,23 @@ rdoc_options:
48
48
  require_paths:
49
49
  - lib
50
50
  required_ruby_version: !ruby/object:Gem::Requirement
51
- none: false
52
51
  requirements:
53
52
  - - ">="
54
53
  - !ruby/object:Gem::Version
55
- hash: 3
56
54
  segments:
57
55
  - 0
58
56
  version: "0"
59
57
  required_rubygems_version: !ruby/object:Gem::Requirement
60
- none: false
61
58
  requirements:
62
59
  - - ">="
63
60
  - !ruby/object:Gem::Version
64
- hash: 3
65
61
  segments:
66
62
  - 0
67
63
  version: "0"
68
64
  requirements: []
69
65
 
70
66
  rubyforge_project: email_reply_parser
71
- rubygems_version: 1.3.7
67
+ rubygems_version: 1.3.6
72
68
  signing_key:
73
69
  specification_version: 2
74
70
  summary: Short description used in Gem listings.