Skip to content

Commit

Permalink
strip ANSI codes from build output in email
Browse files Browse the repository at this point in the history
  • Loading branch information
pd committed Aug 10, 2008
1 parent 8261d92 commit 14f3b57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/integrity/notifier/email.rb
Expand Up @@ -47,9 +47,14 @@ def body
Build Output:
#{build.output}
#{stripped_build_output}
email
end

private
def stripped_build_output
build.output.gsub("\e[0m", '').gsub(/\e\[3[1-7]m/, '')
end
end
end
end
6 changes: 5 additions & 1 deletion spec/notifier/email_spec.rb
Expand Up @@ -11,7 +11,7 @@ def mock_build(messages={})
:commit_message => "the commit message",
:commit_author => stub("author", :name => "Nicolás Sanguinetti"),
:commited_at => Time.mktime(2008, 07, 25, 18, 44),
:output => "the output"
:output => "the output \e[31mwith color coding\e[0m"
}.merge(messages)
@build ||= stub("build", messages)
end
Expand Down Expand Up @@ -69,6 +69,10 @@ def mock_build(messages={})
it "should include the build output" do
@mailer.body.should =~ /the output/
end

it "should strip ANSI color codes from the build output" do
@mailer.body.should_not =~ /\e\[31m/
end
end

it "should create an email with all the information" do
Expand Down

0 comments on commit 14f3b57

Please sign in to comment.