lib/buildbox/result.rb in buildbox-0.0.2 vs lib/buildbox/result.rb in buildbox-0.0.3
- old
+ new
@@ -1,7 +1,36 @@
module Buildbox
- class Result < Struct.new(:output, :exit_status)
+ class Result
+ require 'securerandom'
+
+ attr_reader :uuid, :command
+ attr_accessor :output, :finished, :exit_status
+
+ def initialize(command)
+ @uuid = SecureRandom.uuid
+ @output = ""
+ @finished = false
+ @command = command
+ end
+
+ def finished?
+ finished
+ end
+
def success?
exit_status == 0
+ end
+
+ def as_json
+ { :uuid => @uuid,
+ :command => @command,
+ :output => clean_output,
+ :exit_status => @exit_status }
+ end
+
+ private
+
+ def clean_output
+ Buildbox::UTF8.clean(@output).chomp
end
end
end