kata 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kata +1 -1
- data/lib/kata.rb +1 -0
- data/lib/kata/setup/base.rb +16 -0
- data/lib/kata/setup/javascript.rb +69 -0
- data/lib/kata/setup/ruby.rb +2 -16
- data/lib/kata/version.rb +1 -1
- data/spec/setup/javascript_spec.rb +38 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 799c980fa1d662dff11f1fe752746b0df6c25def
|
4
|
+
data.tar.gz: d3aa26a5a75c4c38b3319159b4ec801bde30b125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6974b2ece4c3aac1df67a5165382d65c6b821398834e2652dc11d492bfc56ccdc0408a44b1b1044165a301698ba362a54addb82a86bb583e7c3c6079a1d51166
|
7
|
+
data.tar.gz: b99833cf31190965749febe5ae27a2450ab6f02367ff3cd3fcb3dc79fc9fa362506806e1ca74c75aa5a59c02d7520371cf8f8575c831b4d89c454f22b614c1ac
|
data/bin/kata
CHANGED
@@ -63,7 +63,7 @@ options.file = ARGV.shift
|
|
63
63
|
|
64
64
|
case options.action
|
65
65
|
when :setup
|
66
|
-
raise
|
66
|
+
raise(ArgumentError, 'No kata source file specified') unless options.file && File.exists?(options.file)
|
67
67
|
|
68
68
|
name = nil
|
69
69
|
|
data/lib/kata.rb
CHANGED
data/lib/kata/setup/base.rb
CHANGED
@@ -28,11 +28,27 @@ module Kata
|
|
28
28
|
case type
|
29
29
|
when 'ruby'
|
30
30
|
Kata::Setup::Ruby.new(kata_name).build_tree
|
31
|
+
when 'javascript'
|
32
|
+
Kata::Setup::Javascript.new(kata_name).build_tree
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
35
37
|
|
38
|
+
def use_kata_name
|
39
|
+
kata_name.gsub(/( |-)\1?/, '_').downcase
|
40
|
+
end
|
41
|
+
|
42
|
+
def class_name
|
43
|
+
kata_name.split(/ |-|_/).map(&:capitalize).join
|
44
|
+
end
|
45
|
+
|
46
|
+
def readme
|
47
|
+
File.open(File.join(repo_name, 'README'), 'w') { |f| f.write(<<EOF) }
|
48
|
+
Leveling up my coding awesomeness!
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
36
52
|
def github
|
37
53
|
# Setup from github configuration
|
38
54
|
raise Exception, 'Git not installed? Could not find git using which' unless system('which git > /dev/null')
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'kata/setup/base'
|
2
|
+
|
3
|
+
module Kata
|
4
|
+
module Setup
|
5
|
+
class Javascript < Kata::Setup::Base
|
6
|
+
def build_tree
|
7
|
+
%w{lib spec}.each { |path| tree(path) }
|
8
|
+
readme
|
9
|
+
package_json
|
10
|
+
base_class
|
11
|
+
kata_spec
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def tree(path)
|
17
|
+
full_path = case path
|
18
|
+
when "lib"
|
19
|
+
File.join(repo_name, 'lib')
|
20
|
+
when "spec"
|
21
|
+
File.join(repo_name, "spec")
|
22
|
+
end
|
23
|
+
|
24
|
+
FileUtils.mkdir_p(full_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Using here docs for a cheap templating system
|
28
|
+
def package_json
|
29
|
+
File.open(File.join(repo_name, 'package.json'), 'w') { |f| f.write(<<EOF) }
|
30
|
+
{
|
31
|
+
"name": "#{use_kata_name}",
|
32
|
+
"version": "0.0.1",
|
33
|
+
"dependencies": {
|
34
|
+
"jasmine-node": "latest"
|
35
|
+
},
|
36
|
+
"private": true
|
37
|
+
}
|
38
|
+
EOF
|
39
|
+
end
|
40
|
+
|
41
|
+
def base_class
|
42
|
+
# create the base class file
|
43
|
+
File.open(File.join(repo_name, 'lib', "#{use_kata_name}.js"), 'w') {|f| f.write <<EOF}
|
44
|
+
var expression = null;
|
45
|
+
|
46
|
+
exports.getExpr = function() {
|
47
|
+
return this.expression;
|
48
|
+
};
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
52
|
+
def kata_spec
|
53
|
+
File.open(File.join(repo_name, 'spec', "#{use_kata_name}_spec.js"), 'w') {|f| f.write <<EOF}
|
54
|
+
var #{use_kata_name} = require("../lib/#{use_kata_name}");
|
55
|
+
|
56
|
+
describe("#{class_name}", function() {
|
57
|
+
it("sets the expression", function() {
|
58
|
+
var expectation = "1,2";
|
59
|
+
#{use_kata_name}.setExpr(expectation);
|
60
|
+
var expr = #{use_kata_name}.getExpr();
|
61
|
+
expect(expr).toBe(expectation);
|
62
|
+
});
|
63
|
+
});
|
64
|
+
EOF
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/lib/kata/setup/ruby.rb
CHANGED
@@ -15,14 +15,6 @@ module Kata
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def use_kata_name
|
19
|
-
kata_name.gsub(/( |-)\1?/, '_').downcase
|
20
|
-
end
|
21
|
-
|
22
|
-
def class_name
|
23
|
-
kata_name.split(/ |-|_/).map(&:capitalize).join
|
24
|
-
end
|
25
|
-
|
26
18
|
def tree(path)
|
27
19
|
full_path = case path
|
28
20
|
when "lib"
|
@@ -39,12 +31,6 @@ module Kata
|
|
39
31
|
end
|
40
32
|
|
41
33
|
# Using here docs for a cheap templating system
|
42
|
-
def readme
|
43
|
-
File.open(File.join(repo_name, 'README'), 'w') { |f| f.write(<<EOF) }
|
44
|
-
Leveling up my ruby awesomeness!
|
45
|
-
EOF
|
46
|
-
end
|
47
|
-
|
48
34
|
def base_class
|
49
35
|
# create the base class file
|
50
36
|
File.open(File.join(repo_name, 'lib', "#{use_kata_name}.rb"), 'w') {|f| f.write <<EOF}
|
@@ -79,7 +65,7 @@ describe #{class_name} do
|
|
79
65
|
it "instantiates" do
|
80
66
|
expect {
|
81
67
|
#{class_name}.new
|
82
|
-
}.to_not
|
68
|
+
}.to_not raise_error
|
83
69
|
end
|
84
70
|
end
|
85
71
|
end
|
@@ -90,7 +76,7 @@ EOF
|
|
90
76
|
File.open(File.join(repo_name, 'spec', 'support', 'matchers', "#{use_kata_name}.rb"), 'w') {|f| f.write <<EOF}
|
91
77
|
RSpec::Matchers.define :your_method do |expected|
|
92
78
|
match do |your_match|
|
93
|
-
#your_match.method_on_object_to_execute
|
79
|
+
#expect(your_match.method_on_object_to_execute).to eq(expected)
|
94
80
|
end
|
95
81
|
end
|
96
82
|
EOF
|
data/lib/kata/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "kata/setup/javascript"
|
3
|
+
require "fakefs/spec_helpers"
|
4
|
+
|
5
|
+
module Kata
|
6
|
+
module Setup
|
7
|
+
describe Javascript do
|
8
|
+
describe "#build_tree" do
|
9
|
+
include FakeFS::SpecHelpers
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
subject.build_tree
|
13
|
+
@use_dir = File.join("/", subject.repo_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "creates lib dir" do
|
17
|
+
expect(File.directory?(File.join(@use_dir, "lib"))).to be true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "creates spec dir" do
|
21
|
+
expect(File.directory?(File.join(@use_dir, "spec"))).to be true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "creates README file" do
|
25
|
+
expect(File.exists?(File.join(@use_dir, "README"))).to be true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "create base class file" do
|
29
|
+
expect(File.exists?(File.join(@use_dir, "lib", "#{subject.kata_name}.js"))).to be true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "creates base spec file" do
|
33
|
+
expect(File.exists?(File.join(@use_dir, "spec", "#{subject.kata_name}_spec.js"))).to be true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -66,11 +66,13 @@ files:
|
|
66
66
|
- lib/kata.rb
|
67
67
|
- lib/kata/base.rb
|
68
68
|
- lib/kata/setup/base.rb
|
69
|
+
- lib/kata/setup/javascript.rb
|
69
70
|
- lib/kata/setup/ruby.rb
|
70
71
|
- lib/kata/version.rb
|
71
72
|
- spec/kata_base_spec.rb
|
72
73
|
- spec/kata_spec.rb
|
73
74
|
- spec/setup/base_spec.rb
|
75
|
+
- spec/setup/javascript_spec.rb
|
74
76
|
- spec/setup/ruby_spec.rb
|
75
77
|
- spec/spec_helper.rb
|
76
78
|
- spec/support/helpers/stdout_helper.rb
|
@@ -102,6 +104,7 @@ test_files:
|
|
102
104
|
- spec/kata_base_spec.rb
|
103
105
|
- spec/kata_spec.rb
|
104
106
|
- spec/setup/base_spec.rb
|
107
|
+
- spec/setup/javascript_spec.rb
|
105
108
|
- spec/setup/ruby_spec.rb
|
106
109
|
- spec/spec_helper.rb
|
107
110
|
- spec/support/helpers/stdout_helper.rb
|