Module: Kata::Base

Includes:
CommandLineReporter
Defined in:
lib/kata/base.rb

Constant Summary collapse

@@times =
[]

Instance Method Summary collapse

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

#question(txt) ⇒ Object



55
56
57
# File 'lib/kata/base.rb', line 55

def question(txt)
  puts indent + "- #{txt.sub(/\?$/, '')}?"
end

#questionsObject



48
49
50
51
52
53
# File 'lib/kata/base.rb', line 48

def questions
  if block_given?
    puts "\nQuestions:"
    yield
  end
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