kata 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  ## Kata ##
2
2
 
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.
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 but you can't
5
+ really test yourself. This gem provides a DSL to author the kata and administer
6
+ it as a test providing feedback for evaluation. It also provides basic github
7
+ repo setup so that you can chart solution progress over time.
8
8
 
9
9
  ### Authoring a Kata ###
10
10
 
11
+ The inspiration for this gem came from my friend Nick Hengeveld
12
+
11
13
  Authoring a kata is as simple as installing this gem and creating a ruby file
12
14
  much like an RSpec test as illustrated below:
13
15
 
@@ -162,7 +164,7 @@ With rspec configured you can also run autotest if you have it installed.
162
164
 
163
165
  Running the kata from the command line yields:
164
166
 
165
- wesbailey@feynman:~/katas> kata stringcalculator.rb
167
+ wesbailey@feynman:~/katas> kata take stringcalculator.rb
166
168
  String Calculator Kata
167
169
  Create an add method that will accept two digits as arguments
168
170
  - invoking with 1 and 2 returns 3
@@ -192,6 +194,9 @@ displayed:
192
194
  Congratulations!
193
195
  - Create an add method that will accept two digits as arguments 00:02:02
194
196
  - Modify the add method to access multple digits as arguments 00:00:45
197
+ ---------------------------------------------------------------------- --------
198
+ Total Time taking Calculator kata: 00:02:47
199
+
195
200
 
196
201
  ### Installing Kata ###
197
202
 
data/bin/kata CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'kata'
2
2
 
3
- usage = <<EOF
3
+ def usage
4
+ puts(<<EOF); exit 1
4
5
  NAME
5
6
  kata - Ruby kata management
6
7
 
@@ -17,31 +18,41 @@ PRIMARY COMMANDS
17
18
 
18
19
  kata take file
19
20
  Start a kata development session
21
+
22
+ kata version
23
+ Current installed version number
24
+
25
+ kata help
26
+ This usage message
20
27
  EOF
28
+ end
21
29
 
22
30
  begin
23
- case ARGV[0].downcase.to_sym
24
- when :setup
25
- raise ArgumentError unless ARGV[1] && File.exists?(ARGV[1])
31
+ argument = ARGV[0].downcase.to_sym
32
+ rescue
33
+ usage
34
+ end
26
35
 
27
- name = nil
36
+ case argument
37
+ when :setup
38
+ raise ArgumentError unless ARGV[1] && File.exists?(ARGV[1])
28
39
 
29
- File.open(ARGV[1]).each do |line|
30
- if line.match /^kata *\"([^\"]*)\" *do$/
31
- name = $1
32
- break
33
- end
34
- end
40
+ name = nil
35
41
 
36
- setup = Kata::Setup.new name
37
- setup.build_tree
38
- setup.create_repo
39
- when :take
40
- load ARGV[1]
41
- else
42
- raise ArgumentError
43
- end
44
- rescue Exception
45
- puts usage
46
- exit 1
42
+ File.open(ARGV[1]).each do |line|
43
+ if line.match /^kata *\"([^\"]*)\" *do$/
44
+ name = $1
45
+ break
46
+ end
47
+ end
48
+
49
+ setup = Kata::Setup.new name
50
+ setup.build_tree
51
+ setup.create_repo
52
+ when :take
53
+ load ARGV[1]
54
+ when :version
55
+ puts "kata #{Kata::VERSION}"
56
+ else
57
+ usage
47
58
  end
@@ -1,2 +1,3 @@
1
1
  require 'kata/setup'
2
2
  require 'kata/base'
3
+ require 'kata/version'
@@ -0,0 +1,3 @@
1
+ module Kata
2
+ VERSION = '1.0.6'
3
+ end
@@ -24,6 +24,7 @@ module Kata
24
24
 
25
25
  Dir[File.join(subject.repo_name, '**', '*.rb')].size.should == 4
26
26
  Dir[File.join(subject.repo_name, 'README')].size.should == 1
27
+ Dir[File.join(subject.repo_name, '.rspec')].size.should == 1
27
28
  end
28
29
  end
29
30
  end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'kata/version'
3
+
4
+ describe 'kata shell' do
5
+ it "should exit with status 1" do
6
+ system "ruby -I lib bin/kata 1> /dev/null"
7
+ $?.exitstatus.should == 1
8
+ end
9
+
10
+ it "should display the version" do
11
+ %x{ruby -I lib bin/kata version}.chomp.should == "kata #{Kata::VERSION}"
12
+ end
13
+
14
+ it "should run the kata" do
15
+ File.open('test_sample.rb', 'w') do |file|
16
+ file.write <<-EOF
17
+ kata "My Test" do
18
+ end
19
+ EOF
20
+ end
21
+
22
+ %x{ruby -I lib bin/kata take test_sample.rb}.chomp.should == 'My Test Kata'
23
+
24
+ File.unlink 'test_sample.rb'
25
+ end
26
+
27
+ it "should display the usage message" do
28
+ %x{ruby -I lib bin/kata help}.should =~ /NAME\n.*kata - Ruby kata management/
29
+ end
30
+ 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.5
5
+ version: 1.0.6
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-18 00:00:00 -07:00
14
+ date: 2011-03-19 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -36,10 +36,12 @@ extra_rdoc_files: []
36
36
  files:
37
37
  - lib/kata/base.rb
38
38
  - lib/kata/setup.rb
39
+ - lib/kata/version.rb
39
40
  - lib/kata.rb
40
41
  - README.md
41
42
  - spec/kata_base_spec.rb
42
43
  - spec/kata_setup_spec.rb
44
+ - spec/kata_spec.rb
43
45
  - spec/spec_helper.rb
44
46
  - spec/support/helpers/stdout_helper.rb
45
47
  - spec/support/matchers/kata.rb
@@ -75,6 +77,7 @@ summary: A code kata DSL
75
77
  test_files:
76
78
  - spec/kata_base_spec.rb
77
79
  - spec/kata_setup_spec.rb
80
+ - spec/kata_spec.rb
78
81
  - spec/spec_helper.rb
79
82
  - spec/support/helpers/stdout_helper.rb
80
83
  - spec/support/matchers/kata.rb