Sha256: 97c320956a2265d39dfbe0557915b7787bc78f1e52dd2deedde529f3a3bf84bf
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 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 finish! @finished = true end def log(*args) internal_log(sprintf(*args)) end def skip(*args) internal_log(sprintf(*args)) skip_now end def skip_now skip! finish! throw :skip end def error(*args) internal_log(sprintf(*args)) fail! end def fatal(msg) internal_log(msg) fail_now end def fail_now fail! finish! throw :skip 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rgot-0.0.5 | lib/rgot/common.rb |
rgot-0.0.4 | lib/rgot/common.rb |
rgot-0.0.3 | lib/rgot/common.rb |