Permalink
Browse files

use TermColor to output

  • Loading branch information...
1 parent 95eb80e commit 3794a2f3dbd254efc73629c1ce86fe19f708e7db @jugyo committed Jan 6, 2010
Showing with 22 additions and 2 deletions.
  1. +1 −0 Rakefile
  2. +2 −0 lib/cilite.rb
  3. +5 −0 lib/cilite/build.rb
  4. +13 −2 lib/cilite/runner.rb
  5. +1 −0 test/tester/test_runner.rb
View
1 Rakefile
@@ -15,6 +15,7 @@ begin
gem.add_dependency 'kvs'
gem.add_dependency 'sinatra'
gem.add_dependency 'choice'
+ gem.add_dependency 'termcolor', '>= 1.2.0'
end
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
View
2 lib/cilite.rb
@@ -6,6 +6,8 @@
require 'kvs'
require 'singleton'
require 'sinatra'
+gem 'termcolor', '>= 1.2.0'
+require 'termcolor'
work_dir = '.cilite'
Dir.mkdir(work_dir) unless File.exists?(work_dir)
View
5 lib/cilite/build.rb
@@ -13,6 +13,11 @@ def start
end
@status = $?.exitstatus.to_i
rescue Exception => e
+ @status = -1
+ end
+
+ def success?
+ status == 0
end
def to_hash
View
15 lib/cilite/runner.rb
@@ -40,15 +40,26 @@ def test_if_updated
end
def test(hash)
+ puts "<magenta>start: #{hash}</magenta>".termcolor, config[:test_command]
+
build = Build.new(config[:test_command])
build.start
- puts "#{hash} => #{build.status}"
- puts build.output
Log[hash] = build.to_hash.merge(
:hash => hash,
:created_at => Time.now,
:branch => config[:branch]
)
+
+ output_result(hash, build)
+ end
+
+ def output_result(hash, build)
+ puts build.output
+ if build.success?
+ puts "<green>[Success!] #{hash}</green>".termcolor
+ else
+ puts "<red>[Failure!] #{hash}</red>".termcolor
+ end
end
end
end
View
1 test/tester/test_runner.rb
@@ -16,6 +16,7 @@ class TestRunner < Test::Unit::TestCase
stub(test_build_stub).to_hash { {:foo => :bar} }
stub(test_build_stub).status { 0 }
stub(test_build_stub).output { 'output' }
+ stub(test_build_stub).success? { true }
mock(CiLite::Build).new(@runner.config[:test_command]) { test_build_stub }
mock(CiLite::Log).[]=.with_any_args
stub(Time).now { 'now' }

0 comments on commit 3794a2f

Please sign in to comment.