Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit f27009b

Browse files
committed
Handles most common French and Spanish formats
1 parent d084079 commit f27009b

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

lib/griddler/email_parser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def self.regex_split_points
8484
/^On.*<\n?.*>.*\n?wrote:$/,
8585
/On.*wrote:/,
8686
/\*?From:.*$/i,
87-
/^[[:space:]]*\d{4}[-\/]\d{1,2}[-\/]\d{1,2}[[:space:]].*[[:space:]]<.*>?$/i
87+
/^[[:space:]]*\d{4}[-\/]\d{1,2}[-\/]\d{1,2}[[:space:]].*[[:space:]]<.*>?$/i,
88+
/^[[:space:]]*\>?[[:space:]]*Le.*<\n?.*>.*\n?a[[:space:]]?\n?écrit :$/, # French
89+
/^[[:space:]]*\>?[[:space:]]*El.*<\n?.*>.*\n?escribió:$/ # Spanish
8890
]
8991
end
9092

spec/griddler/email_spec.rb

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,73 @@
157157
expect(body_from_email(text: body)).to eq 'Hello.'
158158
end
159159

160+
it 'handles french format: "Le [date], [soandso] <[email protected]> a écrit :"' do
161+
body = <<-EOF.strip_heredoc
162+
Hello.
163+
164+
Le 11 mars 2016, at 18:00, Tristan <[email protected]> a écrit :
165+
> Check out this report.
166+
>
167+
> It's pretty cool.
168+
>
169+
> Thanks, Tristan
170+
>
171+
EOF
172+
173+
expect(body_from_email(text: body)).to eq 'Hello.'
174+
end
175+
176+
it 'handles LONG french format: "Le [date], [soandso] <[email protected]> a écrit :"' do
177+
body = <<-EOF.strip_heredoc
178+
Hello.
179+
180+
Le 11 mars 2016, at 18:00, Tristan With A Really Really Long Name <
181+
tristanhasasuperlongemailthatforcesanewline@candidates.welcomekit.co> a
182+
écrit :
183+
> Check out this report.
184+
>
185+
> It's pretty cool.
186+
>
187+
> Thanks, Tristan
188+
>
189+
EOF
190+
191+
expect(body_from_email(text: body)).to eq 'Hello.'
192+
end
193+
194+
it 'handles spanish format: "El [date], [soandso] <[email protected]> escribió:"' do
195+
body = <<-EOF.strip_heredoc
196+
Hello.
197+
198+
El 11/03/2016 11:34, Pedro Pérez <[email protected]> escribió:
199+
> Check out this report.
200+
>
201+
> It's pretty cool.
202+
>
203+
> Thanks, Pedro
204+
>
205+
EOF
206+
207+
expect(body_from_email(text: body)).to eq 'Hello.'
208+
end
209+
210+
it 'handles LONG spanish format: "El [date], [soandso] <[email protected]> escribió:"' do
211+
body = <<-EOF.strip_heredoc
212+
Hello.
213+
214+
El 11/03/2016 11:34, Pedro Pérez <
215+
[email protected]> escribió:
216+
> Check out this report.
217+
>
218+
> It's pretty cool.
219+
>
220+
> Thanks, Pedro
221+
>
222+
EOF
223+
224+
expect(body_from_email(text: body)).to eq 'Hello.'
225+
end
226+
160227
it 'handles "From: [email protected]" format' do
161228
body = <<-EOF
162229
Hello.

0 commit comments

Comments
 (0)