Skip to content

Commit

Permalink
cleaning up the reg exp
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Ellis committed Feb 15, 2011
1 parent 8e30510 commit b2022ed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/markers.rb
Expand Up @@ -36,12 +36,12 @@ module Markers
EMAIL = "#{EMAIL_CHARS}+@#{EMAIL_CHARS}+\.[a-zA-Z]+"
#########################################
#Client Delimiters
GMAIL = /(.*)(^On #{DAY_ABREV_3_CHAR}, #{MONTH_ABREV_3_CHAR} #{MONTH_DATE}, 2[0-9]{3} at #{TIMES} (?:AM||PM), .* <#{EMAIL}> wrote:)(.*)/m
GMAIL = "On #{DAY_ABREV_3_CHAR}, #{MONTH_ABREV_3_CHAR} #{MONTH_DATE}, 2[0-9]{3} at #{TIMES} (?:AM||PM), .* <#{EMAIL}> wrote:"
# On Fri, Jan 7, 2011 at 3:15 PM, Steve Ellis <sellis@pivotallabs.com> wrote:
IPHONE = /(.*)(On #{MONTH_ABREV_3_CHAR} #{DAY_DATE}, #{YEAR_DATE}, at #{TIMES}, .* <#{EMAIL}> wrote:)(.*)/
IPHONE = "On #{MONTH_ABREV_3_CHAR} #{DAY_DATE}, #{YEAR_DATE}, at #{TIMES} (?:AM||PM), .* <#{EMAIL}> wrote:"
# On Jan 24, 2011, at 8:00 PM, Airbnb <automated@airbnb.com> wrote:


MARKERS = [GMAIL, IPHONE]
MARKERS = [GMAIL, IPHONE].map{|m| /#{m}/s}

end
24 changes: 24 additions & 0 deletions spec/markers_spec.rb
@@ -0,0 +1,24 @@
require 'dependencies.rb'

describe Markers do
describe "MARKERS" do
context "matching emails" do
it "correctly parses GMAIL" do
message = "Here \nOn Fri, Jan 7, 2011 at 3:09 PM, ahiruubdfsu <notifications@rr.redroverhq.us> wrote:\nstuff"
parsed = message.split(/#{Markers::GMAIL}/s)

parsed.size.should == 2
parsed.should include "Here \n"
parsed.should include "\nstuff"
end
it "correctly parses IPHONE" do
message = "start\nOn Jan 24, 2011, at 8:00 PM, Airbnb <automated@airbnb.com> wrote:\nAIRBNB FTW"
parsed = message.split(/#{Markers::IPHONE}/s)

parsed.size.should == 2
parsed.should include "start\n"
parsed.should include "\nAIRBNB FTW"
end
end
end
end
9 changes: 0 additions & 9 deletions spec/ratl_spec.rb
Expand Up @@ -107,15 +107,6 @@
end
end

describe "MARKERS" do
context "correctly matches" do
it "GMAILs" do
message = "Here \nOn Fri, Jan 7, 2011 at 3:09 PM, ahiruubdfsu <notifications@rr.redroverhq.us> wrote: stuff"
debugger
Ratl.new(message).splitter(Markers::GMAIL).should == "Here"
end
end
end
describe "#splitter" do
before do
@ratl = Ratl.new(@text)
Expand Down

0 comments on commit b2022ed

Please sign in to comment.