kata 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +93 -14
  2. data/lib/kata/setup.rb +3 -0
  3. metadata +4 -4
data/README.md CHANGED
@@ -1,18 +1,17 @@
1
1
  ## Kata ##
2
2
 
3
- A kata is defined as an exercise in programming which helps hone your skills
4
- through practice and repetition. Authoring katas is done in blogs with no
5
- real way of testing yourself for improvement. This gem provides a DSL to
6
- author the kata and administer it as a test providing feedback for evaluation.
3
+ A kata is defined as an exercise in programming which helps you hone your skills
4
+ through practice and repetition. Finding katas to work on is a challenge and
5
+ to this point the only location was through mail archives and random blog posts.
6
+ The purpose of this gem is to provide a series of tools that make it easy to
7
+ author, setup and administer a kata.
7
8
 
8
- ### Writing a Kata ###
9
+ ### Authoring a Kata ###
9
10
 
10
- It is as simple as installing this gem and creating a ruby file much like
11
- an RSpec test as illustrated below:
11
+ Authoring a kata is as simple as installing this gem and creating a ruby file
12
+ much like an RSpec test as illustrated below:
12
13
 
13
- require 'kata'
14
-
15
- kata "My First Kata" do
14
+ kata "String Calculator" do
16
15
  requirement "Create an add method that will accept two digits as arguments" do
17
16
  example "invoking with 1 and 2 returns 3"
18
17
  example "invoking with 5 only returns 5"
@@ -22,14 +21,88 @@ an RSpec test as illustrated below:
22
21
  example "invoking with 1 and 2 and 3 returns 6"
23
22
  example "invoking with 1 and 2 and 3 and 4 and 5 returns 15"
24
23
  end
25
- end
24
+ context "sub" do
25
+ requirement "Create a sub method that will accept two digits as arguments" do
26
+ detail "Negative numbers are not allowed"
27
+ detail "Digits must range from 0-9"
28
+ example "9-6 = 3"
29
+ end
30
+ requirement "Modify the sub method to access multple digits as arguments" do
31
+ example "9-6-3 = 0"
32
+ end
33
+ end
34
+ end
35
+
36
+ There are five methods that can be used to author a kata that have a hierarchy
37
+ illustrated below:
38
+
39
+ 1. kata
40
+ 2. context
41
+ 3. requirement
42
+ 4. detail
43
+ 5. example
44
+
45
+ 1. The **kata()** method sets up the test to administer and starts the clock running.
46
+ It takes 2 arguments:
47
+
48
+ * *string* - The name of the kata that will be displayed when taking it as well as
49
+ being used in creating the parent directory of the github repo during setup.
50
+ * *&block* - A ruby block that includes calls to *context()* or *requirement()*
51
+
52
+ 1. The **context()** method allows for grouping of requirements with 2 arguments:
53
+
54
+ * *string* - A description of the provided context
55
+ * *&block* - A ruby block consisting of a call to *requirement()*
56
+
57
+ this method call is optional and not required to define a kata.
58
+
59
+ 1. The **requirement()** method is the heart of a kata as it is used to provide the
60
+ business rules that the code should provide solutions to. It follows the same
61
+ pattern of the other methods with 2 arguments:
26
62
 
27
- ### Taking a Kata ###
63
+ * *string* - A description of the requirement that the code implementing the
64
+ kata should meet
65
+ * *&block* - A ruby block consisting of calls to *detail()* or *example()*
66
+
67
+ 1. The **detail()** method takes a single argument allowing for further defintion
68
+ of a requirement. This method can be called repeatedly in a block.
69
+
70
+ * *string* - A description of the detail of requirement
71
+
72
+ 1. The **example()** method takes a single argument allowing for illustration of
73
+ examples of the requirement in practice
74
+
75
+ * *string* - An example that will help illustrate the requirement in practice
76
+
77
+ ### Setting up a Kata ###
78
+
79
+ To setup a minimal github repo you must first already have a github account and
80
+ git installed on your machine. To build a kata repo simply use the setup
81
+ command:
82
+
83
+ wesbailey@feynman:~/my-katas> kata setup sample.rb
84
+ {"repository":{"has_downloads":true,"url":". ... 011-03-11-165513/.git/
85
+ [master (root-commit) 804036f] starting kata
86
+ 5 files changed, 25 insertions(+), 0 deletions(-)
87
+ create mode 100644 README
88
+ create mode 100644 lib/my_first.rb
89
+ create mode 100644 spec/my_first_spec.rb
90
+ create mode 100644 spec/spec_helper.rb
91
+ create mode 100644 spec/support/matchers/my_first.rb
92
+ Counting objects: 11, done.
93
+ Delta compression using up to 4 threads.
94
+ Compressing objects: 100% (6/6), done.
95
+ Writing objects: 100% (11/11), 973 bytes, done.
96
+ Total 11 (delta 0), reused 0 (delta 0)
97
+ To git@github.com:wbailey/my_first-2011-03-11-165513.git
98
+ * [new branch] master -> master
99
+
100
+ ### Administering a Kata ###
28
101
 
29
102
  Running the kata from the command line yields:
30
103
 
31
- wesbailey@feynman:~/kata> ruby sample.rb
32
- My First Kata
104
+ wesbailey@feynman:~/my-katas> kata stringcalculator.rb
105
+ String Calculator Kata
33
106
  Create an add method that will accept two digits as arguments
34
107
  - invoking with 1 and 2 returns 3
35
108
  - invoking with 1 returns 1
@@ -37,12 +110,18 @@ Running the kata from the command line yields:
37
110
 
38
111
  continue (Y|n):
39
112
 
113
+ At this point you should go into your setup and start coding until this
114
+ requirement is completed. Once it is then enter and the next requirement will
115
+ appear as illustrated below:
116
+
40
117
  Modify the add method to access multple digits as arguments
41
118
  - invoking with 1 and 2 and 3 returns 6
42
119
  - invoking with 1 and 2 and 3 and 4 and 5 returns 15
43
120
 
44
121
  continue (Y|n):
45
122
 
123
+ The process continues until all of the requirements have been coded. The
124
+ kata will keep track of the ammount of time it takes for you to complete coding.
46
125
 
47
126
  ### Completing the Kata ###
48
127
 
data/lib/kata/setup.rb CHANGED
@@ -31,6 +31,9 @@ module Kata
31
31
  repo_params = "-d 'name=#{repo_name}' -d 'description=code+kata+repo'"
32
32
 
33
33
  # Create the repo on github
34
+ puts <<-EOF
35
+ curl #{user_string} #{repo_params} #{github.url}repos/create
36
+ EOF
34
37
  raise SystemCallError, 'unable to use curl to create repo on github' unless system <<-EOF
35
38
  curl #{user_string} #{repo_params} #{github.url}repos/create
36
39
  EOF
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kata
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
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-11 00:00:00 -08:00
14
+ date: 2011-03-12 00:00:00 -08:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- hash: -4334512147184042673
61
+ hash: -513172246977383286
62
62
  segments:
63
63
  - 0
64
64
  version: "0"
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- hash: -4334512147184042673
70
+ hash: -513172246977383286
71
71
  segments:
72
72
  - 0
73
73
  version: "0"