Module: Kata::Base
- Includes:
- CommandLineReporter
- Defined in:
- lib/kata/base.rb
Constant Summary collapse
- @@times =
[]
Instance Method Summary collapse
- #context(txt) ⇒ Object
- #detail(txt) ⇒ Object
- #example(txt) ⇒ Object
- #kata(txt, lib = nil) ⇒ Object
- #requirement(txt = 'kata requirement') ⇒ Object
Instance Method Details
#context(txt) ⇒ Object
16 17 18 19 |
# File 'lib/kata/base.rb', line 16 def context(txt) puts indent + txt yield if block_given? end |
#detail(txt) ⇒ Object
44 45 46 |
# File 'lib/kata/base.rb', line 44 def detail(txt) puts indent + '- ' + "detail: #{txt}" end |
#example(txt) ⇒ Object
40 41 42 |
# File 'lib/kata/base.rb', line 40 def example(txt) puts indent + '- ' + "example: #{txt}" end |
#kata(txt, lib = nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/kata/base.rb', line 9 def kata(txt, lib = nil) @kata_name = txt puts "#{@kata_name} Kata" yield if block_given? complete end |
#requirement(txt = 'kata requirement') ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kata/base.rb', line 21 def requirement(txt = 'kata requirement') puts indent + txt start = Time.now yield if block_given? rsp = ask "\ncompleted (Y|n): ", 'y' puts system %Q{git add . && git commit -m '#{txt}' > /dev/null} rescue Exception elapsed = Time.now - start @@times << {:title => txt, :time => elapsed} complete false if rsp.downcase == 'n' end |