Skip to content

Commit

Permalink
strip whitespace in message
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Ellis committed Feb 15, 2011
1 parent b2022ed commit 95b8365
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 237 deletions.
Binary file removed .markers.rb.swp
Binary file not shown.
Binary file removed .ratl.rb.swp
Binary file not shown.
Binary file removed .ratl_spec.rb.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/ratl.rb
Expand Up @@ -17,7 +17,7 @@ def splitter
parsed_messages = MARKERS.map do |marker|
parse_client(marker)
end
parsed_messages.sort_by(&:size).first
parsed_messages.sort_by(&:size).first.strip
end

def parse_client(delimiter)
Expand Down
47 changes: 0 additions & 47 deletions markers.rb

This file was deleted.

42 changes: 0 additions & 42 deletions ratl.rb

This file was deleted.

143 changes: 0 additions & 143 deletions ratl_spec.rb

This file was deleted.

14 changes: 10 additions & 4 deletions spec/ratl_spec.rb
Expand Up @@ -109,26 +109,32 @@

describe "#splitter" do
before do
@message = "<hi>"
@ratl = Ratl.new(@text)
@parsed = @ratl.splitter
end

it "pulls the text above the first marker" do
marker = "On Fri, Jan 7, 2011 at 3:15 PM, Steve Ellis <sellis@pivotallabs.com> wrote:"

@ratl.splitter.should_not include marker
@ratl.splitter.should include "<hi>"
@ratl.splitter.should include @message
end

it "removes the content-type and mime encodings" do
marker = /Content-Type: text\/plain; charset=ISO-8859-1\s*Content-Transfer-Encoding: quoted-printable/

@ratl.splitter.should_not =~ marker
@ratl.splitter.should include "<hi>"
end

it "uses the shortest possible message" do
@ratl.splitter.should include "<hi>"
@ratl.splitter.should_not include "test comment"
@parsed.should include @message
@parsed.should_not include "test comment"
end

it "strips leading/trailing whitespace" do
@parsed.should include @message
@parsed.should_not =~ /\s#{@message}\s/
end
end
end

0 comments on commit 95b8365

Please sign in to comment.