Class: Metabuild::LogText
Overview
Simple log that just prints out text (for console builds)
Instance Attribute Summary collapse
-
#fail ⇒ Object
readonly
Returns the value of attribute fail.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#skip ⇒ Object
readonly
Returns the value of attribute skip.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
- #add_fail(msg) ⇒ Object
- #add_skip(msg) ⇒ Object
- #add_success(msg) ⇒ Object
-
#failure(msg) ⇒ Object
Stop script, adding a message to the log.
- #finish ⇒ Object
-
#initialize(name) ⇒ LogText
constructor
A new instance of LogText.
- #integrate(log) ⇒ Object
- #output ⇒ Object
- #report ⇒ Object
-
#run(command, env, fail_msg, skip) ⇒ Object
Run a shell command, log.
-
#silent(command, env) ⇒ Object
Run a shell command, no logging.
- #status ⇒ Object
-
#stop ⇒ Object
Output log and exit with error exit status.
-
#valid(command, env, fail_msg, success_msg, skip) ⇒ Object
Run a shell command.
Methods inherited from Log
#env_spawn, #env_system, #parallel_wait, #script
Constructor Details
#initialize(name) ⇒ LogText
Returns a new instance of LogText.
227 228 229 230 231 232 |
# File 'lib/metabuild.rb', line 227 def initialize(name) super(name) @fail, @success, @skip = [], [], [] @subscripts = [] @report_done = false end |
Instance Attribute Details
#fail ⇒ Object (readonly)
Returns the value of attribute fail.
225 226 227 |
# File 'lib/metabuild.rb', line 225 def fail @fail end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
225 226 227 |
# File 'lib/metabuild.rb', line 225 def name @name end |
#skip ⇒ Object (readonly)
Returns the value of attribute skip.
225 226 227 |
# File 'lib/metabuild.rb', line 225 def skip @skip end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
225 226 227 |
# File 'lib/metabuild.rb', line 225 def success @success end |
Instance Method Details
#add_fail(msg) ⇒ Object
234 235 236 |
# File 'lib/metabuild.rb', line 234 def add_fail(msg) @fail.push msg end |
#add_skip(msg) ⇒ Object
242 243 244 |
# File 'lib/metabuild.rb', line 242 def add_skip(msg) @skip.push "SKIPPED : #{msg}" end |
#add_success(msg) ⇒ Object
238 239 240 |
# File 'lib/metabuild.rb', line 238 def add_success(msg) @success.push msg end |
#failure(msg) ⇒ Object
Stop script, adding a message to the log
318 319 320 321 |
# File 'lib/metabuild.rb', line 318 def failure(msg) add_fail msg stop end |
#finish ⇒ Object
329 330 331 332 |
# File 'lib/metabuild.rb', line 329 def finish report exit status end |
#integrate(log) ⇒ Object
310 311 312 313 314 315 |
# File 'lib/metabuild.rb', line 310 def integrate log @subscripts.push log.name log.success.each {|s| @success.push("[#{log.name}] " + s)} log.fail.each {|f| @fail.push("[#{log.name}] " + f)} log.skip.each {|f| @skip.push("[#{log.name}] " + f)} end |
#output ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/metabuild.rb', line 256 def output puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" puts @name puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" puts "Ran the following subscripts :" @subscripts.each {|s| puts s} puts "----------------------------------------------" puts "Sucess : " @success.each {|s| puts s} puts "----------------------------------------------" puts "Fail : " @fail.each {|s| puts s} puts "----------------------------------------------" puts "Skipped : " @skip.each {|s| puts s} puts "----------------------------------------------" end |
#report ⇒ Object
246 247 248 249 250 251 252 253 254 |
# File 'lib/metabuild.rb', line 246 def report return if @report_done # prevent reporting several times if @subscript $subscript_log = self else output end @report_done = true end |
#run(command, env, fail_msg, skip) ⇒ Object
Run a shell command, log
279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/metabuild.rb', line 279 def run(command, env, fail_msg, skip) if skip add_skip command else if env_system(command, env) add_success "[#{@name}] #{command} SUCCESS" else failure fail_msg end end end |
#silent(command, env) ⇒ Object
Run a shell command, no logging
292 293 294 |
# File 'lib/metabuild.rb', line 292 def silent(command, env) stop unless env_system(command, env) end |
#status ⇒ Object
274 275 276 |
# File 'lib/metabuild.rb', line 274 def status @fail.empty? end |
#stop ⇒ Object
Output log and exit with error exit status
324 325 326 327 |
# File 'lib/metabuild.rb', line 324 def stop report exit false end |
#valid(command, env, fail_msg, success_msg, skip) ⇒ Object
Run a shell command. Log success and failure
297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/metabuild.rb', line 297 def valid(command, env, fail_msg, success_msg, skip) if skip add_skip command else if env_system(command, env) add_success success_msg if success_msg != "" else failure(fail_msg) if ENV.has_key? "METABUILD_PARALLEL" add_fail fail_msg end end end |