kata 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Kata ##
1
+ # Kata
2
2
 
3
3
  A kata is defined as an exercise in programming which helps hone your skills
4
4
  through practice and repetition. Authoring katas is done in blogs but you can't
@@ -6,7 +6,7 @@ really test yourself. This gem provides a DSL to author the kata and administer
6
6
  it as a test providing feedback for evaluation. It also provides basic github
7
7
  repo setup so that you can chart solution progress over time.
8
8
 
9
- ### Authoring a Kata ###
9
+ ## Authoring a Kata
10
10
 
11
11
  The inspiration for this gem came from my friend Nick Hengeveld
12
12
 
@@ -76,7 +76,7 @@ examples of the requirement in practice
76
76
 
77
77
  * *string* - An example that will help illustrate the requirement in practice
78
78
 
79
- ### Setting up a Kata ###
79
+ ## Setting up a Kata
80
80
 
81
81
  To setup a minimal github repo you must first already have a github account and
82
82
  git installed on your machine. To build a kata repo simply use the setup
@@ -160,16 +160,17 @@ Following TDD the first test has been written and passes:
160
160
 
161
161
  With rspec configured you can also run autotest if you have it installed.
162
162
 
163
- ### Administering a Kata ###
163
+ ## Administering a Kata
164
164
 
165
165
  Running the kata from the command line yields:
166
166
 
167
167
  wesbailey@feynman:~/katas> kata take stringcalculator.rb
168
168
  String Calculator Kata
169
169
  Create an add method that will accept two digits as arguments
170
- - invoking with 1 and 2 returns 3
171
- - invoking with 1 returns 1
172
- - invoking with no arguments returns 0
170
+ - detail: invoking with 1 and 2 returns 3
171
+ - detail: invoking with 1 returns 1
172
+ - detail: invoking with no arguments returns 0
173
+ - example: "1,2" sums to 3
173
174
 
174
175
  continue (Y|n):
175
176
 
@@ -178,15 +179,15 @@ requirement is completed. Once it is then enter and the next requirement will
178
179
  appear as illustrated below:
179
180
 
180
181
  Modify the add method to access multple digits as arguments
181
- - invoking with 1 and 2 and 3 returns 6
182
- - invoking with 1 and 2 and 3 and 4 and 5 returns 15
182
+ - example: "1,2,3" sums to 6
183
+ - example: "1,2,3,4,5" sums to 15
183
184
 
184
185
  continue (Y|n):
185
186
 
186
187
  The process continues until all of the requirements have been coded. The
187
188
  kata will keep track of the ammount of time it takes for you to complete coding.
188
189
 
189
- ### Completing the Kata ###
190
+ ## Completing the Kata
190
191
 
191
192
  After completing the requirements of the kata continue and the report is
192
193
  displayed:
@@ -198,9 +199,13 @@ displayed:
198
199
  Total Time taking Calculator kata: 00:02:47
199
200
 
200
201
 
201
- ### Installing Kata ###
202
+ ## Installing Kata
202
203
 
203
204
  It is up on rubygems.org so add it to your bundle or do it the old fashioned
204
205
  way with:
205
206
 
206
207
  gem install kata
208
+
209
+ ## Contributions
210
+
211
+ Wes Bailey ([Exposing Gotchas](http://exposinggotchas.blogspot.com/ "Exposing Gotchas"))
data/bin/kata CHANGED
@@ -48,7 +48,7 @@ case argument
48
48
 
49
49
  setup = Kata::Setup.new name
50
50
  setup.build_tree
51
- setup.create_repo
51
+ setup.create_repo rescue Exception
52
52
  when :take
53
53
  load ARGV[1]
54
54
  when :version
data/lib/kata/base.rb CHANGED
@@ -2,19 +2,19 @@ module Kata
2
2
  module Base
3
3
  @@times = []
4
4
 
5
- def kata txt, lib = nil
5
+ def kata(txt, lib = nil)
6
6
  @kata_name = txt
7
7
  puts "#{@kata_name} Kata"
8
8
  yield if block_given?
9
9
  complete
10
10
  end
11
11
 
12
- def context txt
12
+ def context(txt)
13
13
  puts indent + txt
14
14
  yield if block_given?
15
15
  end
16
16
 
17
- def requirement txt
17
+ def requirement(txt)
18
18
  puts indent + txt
19
19
 
20
20
  start = Time.now
@@ -31,22 +31,22 @@ module Kata
31
31
  complete false if rsp.downcase == 'n'
32
32
  end
33
33
 
34
- def example txt
34
+ def example(txt)
35
35
  puts indent + '- ' + "example: #{txt}"
36
36
  end
37
37
 
38
- def detail txt
38
+ def detail(txt)
39
39
  puts indent + '- ' + "detail: #{txt}"
40
40
  end
41
41
 
42
42
  private
43
43
 
44
- def ask prompt, default
44
+ def ask(prompt, default)
45
45
  print prompt
46
46
  $stdin.gets.chomp || default
47
47
  end
48
48
 
49
- def complete status = true
49
+ def complete(status = true)
50
50
  if @@times.size > 0
51
51
  title = status ? 'Congratulations!' : 'You completed the following:'
52
52
 
@@ -55,10 +55,16 @@ module Kata
55
55
  [use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
56
56
  end
57
57
 
58
- puts "\n\n#{title}"
59
- puts @@times.inject('') {|s,p| s << "- #{p[:title][0,70].ljust(70, ' ')} #{formatter.call(p[:time]).rjust(10,' ')}\n"}
60
- puts '-' * 70 + ' ' * 5 + '-' * 8
61
- puts "Total Time taking #{@kata_name} kata: ".ljust(70, ' ') + ' ' * 5 + formatter.call(@@times.inject(0) {|s,h| s += h[:time]})
58
+ File.open('results.txt', 'w') do |file|
59
+ file.puts "\n\n#{title}"
60
+ file.puts @@times.inject('') {|s,p| s << "- #{p[:title][0,70].ljust(70, ' ')} #{formatter.call(p[:time]).rjust(10,' ')}\n"}
61
+ file.puts '-' * 70 + ' ' * 5 + '-' * 8
62
+ file.puts "Total Time taking #{@kata_name} kata: ".ljust(70, ' ') + ' ' * 5 + formatter.call(@@times.inject(0) {|s,h| s += h[:time]})
63
+ end
64
+
65
+ File.open('results.txt', 'r') do |file|
66
+ puts file.readline
67
+ end
62
68
  end
63
69
 
64
70
  exit 1 unless status
data/lib/kata/setup.rb CHANGED
@@ -6,7 +6,7 @@ module Kata
6
6
  attr_accessor :kata_name
7
7
  attr_reader :repo_name
8
8
 
9
- def initialize kata_name = 'kata'
9
+ def initialize(kata_name = 'kata')
10
10
  self.kata_name = kata_name
11
11
  self.repo_name = kata_name
12
12
  end
@@ -52,7 +52,7 @@ module Kata
52
52
  puts "You can now change directories to #{repo_name} and take your kata"
53
53
  end
54
54
 
55
- def repo_name= kata_name
55
+ def repo_name=(kata_name)
56
56
  @repo_name = "#{kata_name.gsub(/( |-)\1?/, '_')}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}".downcase
57
57
  end
58
58
 
data/lib/kata/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kata
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.8'
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kata
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.7
5
+ version: 1.0.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Wes
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-03-19 00:00:00 -07:00
14
+ date: 2011-10-03 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency