Permalink
Browse files

add ansi colors to build log, and stderr

  • Loading branch information...
chriskite committed Sep 12, 2013
1 parent d358034 commit 8968469608a339e039b5131004fbd096d7ac71a4
View
@@ -33,6 +33,7 @@ gem 'daemons'
gem 'delayed_job_active_record'
gem 'mysql2'
gem 'jira-ruby', require: 'jira'
+gem 'ansible'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
@@ -39,6 +39,7 @@ GEM
i18n (= 0.6.1)
multi_json (~> 1.0)
addressable (2.3.5)
+ ansible (0.2.0)
arel (3.0.2)
builder (3.0.4)
chronic (0.9.1)
@@ -191,6 +192,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ ansible
coffee-rails (~> 3.2.1)
daemons
delayed_job_active_record
@@ -0,0 +1,8 @@
+.ansible_30 { color: black; }
+.ansible_31 { color: red; }
+.ansible_32 { color: limegreen; }
+.ansible_33 { color: yellow;}
+.ansible_34 { color: blue;}
+.ansible_35 { color: magenta; }
+.ansible_36 { color: cyan; }
+.ansible_37 { color: white; }
@@ -0,0 +1,6 @@
+.modal-body {
+ background-color: black;
+ color: white;
+ font-family: "Inconsolata", "Consolas", "Monospace", courier;
+ font-size: 16px;
+}
@@ -1,3 +0,0 @@
-// Place all the styles related to the PullRequests controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -1,4 +1,6 @@
class PullRequestsController < ApplicationController
+ include Ansible
+
# GET /pull_requests/1
# GET /pull_requests/1.json
def show
@@ -23,7 +25,7 @@ def build_log
@pull_request = PullRequest.find(params[:id])
respond_to do |format|
- format.json { render json: { build_log: @pull_request.build_log }.to_json }
+ format.json { render json: { build_log: ansi_escaped(@pull_request.build_log) }.to_json }
format.html { render html: @pull_request, layout: false }
end
end
@@ -1,2 +1,7 @@
module PullRequestsHelper
+ include Ansible
+
+ def ansi2html(str)
+ ansi_escaped(str.gsub("\n", "<br />"))
+ end
end
@@ -131,7 +131,7 @@ def run_build_command
env_vars = env_vars.map { |env,val| "CHRYSALIS_#{env}=#{val}" }.join(" ")
Rails.logger.info "Building #{build_path}"
- system("cd #{build_path} && #{env_vars} ./build/build.sh > build.log")
+ system("cd #{build_path} && #{env_vars} ./build/build.sh &> build.log")
raise "Error running build.sh" if 0 != $?
end
@@ -1,4 +1 @@
-<pre>
-<%= @pull_request.build_log %>
-</pre>
-
+<%= ansi2html(h(@pull_request.build_log)).html_safe %>

0 comments on commit 8968469

Please sign in to comment.