Sha256: 3b5092b6775b1788fdabf66eef995b56ef7f29eaf89ff24c86712d07228ed12b
Contents?: true
Size: 893 Bytes
Versions: 5
Compression:
Stored size: 893 Bytes
Contents
# coding: utf-8 require 'pathname' require 'thinreports' class Thinreports::Example ROOT = Pathname.new File.expand_path('..', __FILE__) attr_reader :name, :description def initialize(name, description) @name = name @description = description end def start print "[#{name}] #{description}: " end def success print "ok#{$/}" end def error(e) puts "#{$/}ERROR: #{e}" puts e.backtrace end def layout_filename resource("#{@name}.tlf") end def output_filename resource("#{@name}.pdf") end def resource(filename = nil) path = ROOT.join @name.to_s filename ? path.join(filename).to_s : path.to_s end end def example(name, description = nil, &block) ex = Thinreports::Example.new(name, description) ex.start block.arity == 1 ? block.call(ex) : ex.instance_eval(&block) ex.success rescue => e ex.error(e) end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
thinreports-0.9.1 | examples/helper.rb |
thinreports-0.9.0 | examples/helper.rb |
thinreports-0.8.2 | examples/helper.rb |
thinreports-0.8.1 | examples/helper.rb |
thinreports-0.8.0 | examples/helper.rb |