Sha256: e04493c37b421da992947191de60ad94ed466ecdf30aa71a6344b89870f59e39
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module Rgot class Common def initialize @output = "" @failed = false @skipped = false @finished = false @start = Rgot.now end def failed? @failed end def skipped? @skipped end def finished? @finished end def fail! @failed = true end def skip! @skipped = true end def finished! @finished = true end def log(*args) internal_log(sprintf(*args)) end def error(*args) internal_log(sprintf(*args)) fail! end def fatal(msg) internal_log(msg) fail_now! end def fail_now! fail! @finished = true exit 1 end private def decorate(str) c = caller[2] # internal_log -> other log -> running method path = c.sub(/:.*/, '') line = c.match(/:(\d+?):/)[1] relative_path = Pathname.new(path).relative_path_from(Pathname.new(Dir.pwd)).to_s "\t#{relative_path}:#{line}: #{str}\n" end def internal_log(msg) @output << decorate(msg) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rgot-0.0.2 | lib/rgot/common.rb |
rgot-0.0.1 | lib/rgot/common.rb |