kata 1.5.0 → 1.6.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 +3 -1
- data/lib/kata.rb +2 -1
- data/lib/kata/base.rb +13 -11
- data/lib/kata/setup/base.rb +63 -25
- data/lib/kata/setup/{javascript.rb → node.rb} +11 -17
- data/lib/kata/setup/php.rb +87 -0
- data/lib/kata/setup/ruby.rb +36 -40
- data/lib/kata/version.rb +1 -1
- data/spec/setup/base_spec.rb +59 -0
- data/spec/setup/{javascript_spec.rb → node_spec.rb} +12 -4
- data/spec/setup/php_spec.rb +43 -0
- data/spec/setup/ruby_spec.rb +7 -15
- data/spec/spec_helper.rb +8 -5
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f38d529f6814fb12f472bb2bfa479f7a00a334d
|
4
|
+
data.tar.gz: 2bd597620a28cc985ce3ce8e18215d193e3e1339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea74244753c10614fce17195944dd29a75db466c4a0eb57362ce2e4635bed0e74e8ef51529a021ae6a79489d7ae6a30a6729f810ee45d34ff6e047ae2b26f635
|
7
|
+
data.tar.gz: b5513df5b97f52c2e9f71ade69caba49137845cae21242c0d9a999fdc667854e5d330af8eca1008f4deb378f4a74c565e7c89804d6f7a1a2301c14cf44c4b052
|
data/bin/kata
CHANGED
@@ -21,6 +21,7 @@ PRIMARY COMMANDS
|
|
21
21
|
|
22
22
|
--no-repo - Add the directory tree and files to the current repo if possible
|
23
23
|
--language=option - Define the programming language for the directory tree that is built
|
24
|
+
VALID OPTIONS [ruby,node,php]
|
24
25
|
file - Path to the code kata source file for the practice session
|
25
26
|
|
26
27
|
kata take file
|
@@ -48,7 +49,7 @@ OptionParser.new do |opts|
|
|
48
49
|
options.repo = false
|
49
50
|
end
|
50
51
|
|
51
|
-
opts.on('-l
|
52
|
+
opts.on('-l', '--language [LANG]', 'Setup the kata file tree using the specified language') do |lang|
|
52
53
|
options.language = lang
|
53
54
|
end
|
54
55
|
end.parse!
|
@@ -64,6 +65,7 @@ options.file = ARGV.shift
|
|
64
65
|
case options.action
|
65
66
|
when :setup
|
66
67
|
raise(ArgumentError, 'No kata source file specified') unless options.file && File.exists?(options.file)
|
68
|
+
raise(ArgumentError, 'Invalid language option') unless %w{ruby node php}.include?(options.language)
|
67
69
|
|
68
70
|
name = nil
|
69
71
|
|
data/lib/kata.rb
CHANGED
data/lib/kata/base.rb
CHANGED
@@ -66,13 +66,16 @@ module Kata
|
|
66
66
|
def complete(status = true)
|
67
67
|
return if @@times.size == 0
|
68
68
|
|
69
|
-
formatter = lambda do |sec|
|
70
|
-
use = sec.round
|
71
|
-
[use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
|
72
|
-
end
|
73
|
-
|
74
69
|
suppress_output
|
70
|
+
report
|
71
|
+
content = capture_output
|
72
|
+
|
73
|
+
File.open('report.txt', 'w').write(content)
|
74
|
+
|
75
|
+
puts content
|
76
|
+
end
|
75
77
|
|
78
|
+
def report
|
76
79
|
table :border => true do
|
77
80
|
row :header => true do
|
78
81
|
column 'Requirement', :color => 'red', :width => 80
|
@@ -82,16 +85,15 @@ module Kata
|
|
82
85
|
@@times.each do |t|
|
83
86
|
row do
|
84
87
|
column t[:title]
|
85
|
-
column
|
88
|
+
column format_time(t[:time])
|
86
89
|
end
|
87
90
|
end
|
88
91
|
end
|
92
|
+
end
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
puts report
|
94
|
+
def format_time(sec)
|
95
|
+
use = sec.round
|
96
|
+
[use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
|
95
97
|
end
|
96
98
|
|
97
99
|
def ancestry
|
data/lib/kata/setup/base.rb
CHANGED
@@ -28,13 +28,21 @@ module Kata
|
|
28
28
|
case type
|
29
29
|
when 'ruby'
|
30
30
|
Kata::Setup::Ruby.new(kata_name).build_tree
|
31
|
-
when '
|
32
|
-
Kata::Setup::
|
31
|
+
when 'node'
|
32
|
+
Kata::Setup::Node.new(kata_name).build_tree
|
33
|
+
when 'php'
|
34
|
+
Kata::Setup::Php.new(kata_name).build_tree
|
35
|
+
else
|
36
|
+
raise(ArgumentError, "Invalid language type #{type}")
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
40
|
private
|
37
41
|
|
42
|
+
def tree(path)
|
43
|
+
FileUtils.mkdir_p(File.join(repo_name, path))
|
44
|
+
end
|
45
|
+
|
38
46
|
def use_kata_name
|
39
47
|
kata_name.gsub(/( |-)\1?/, '_').downcase
|
40
48
|
end
|
@@ -43,8 +51,15 @@ module Kata
|
|
43
51
|
kata_name.split(/ |-|_/).map(&:capitalize).join
|
44
52
|
end
|
45
53
|
|
54
|
+
def write_repo_file(use_file, use_contents, permissions = 0644)
|
55
|
+
File.open(File.join(repo_name, use_file), 'w') do |f|
|
56
|
+
f.write(use_contents)
|
57
|
+
f.chmod(permissions) rescue Exception
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
46
61
|
def readme
|
47
|
-
|
62
|
+
write_repo_file('README',<<EOF)
|
48
63
|
Leveling up my coding awesomeness!
|
49
64
|
EOF
|
50
65
|
end
|
@@ -55,28 +70,46 @@ EOF
|
|
55
70
|
|
56
71
|
@github ||=
|
57
72
|
begin
|
58
|
-
|
73
|
+
struct = OpenStruct.new
|
74
|
+
|
75
|
+
struct.token = %x{git config --get github.token}.chomp
|
59
76
|
|
60
77
|
github_user = %x{git config --get github.user}.chomp
|
61
78
|
shell_user = ENV['USER']
|
62
79
|
|
63
|
-
|
80
|
+
struct.user = github_user.empty? ? shell_user : github_user
|
64
81
|
|
65
|
-
|
82
|
+
struct
|
83
|
+
end
|
84
|
+
end
|
66
85
|
|
67
|
-
|
68
|
-
|
86
|
+
def client_factory
|
87
|
+
if github.token
|
88
|
+
# nothing to do
|
89
|
+
elsif github.user
|
90
|
+
get_password
|
91
|
+
get_token
|
92
|
+
else
|
93
|
+
raise Exception, 'Unable to determine github.token or github.user' if github.user.empty?
|
94
|
+
end
|
69
95
|
|
70
|
-
|
71
|
-
end
|
96
|
+
client.access_token = github.token
|
72
97
|
end
|
73
98
|
|
74
99
|
def client
|
75
|
-
@client ||= Octokit::Client.new
|
100
|
+
@client ||= Octokit::Client.new
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_password
|
104
|
+
print 'Github account password: '
|
105
|
+
github.password = STDIN.noecho(&:gets).chomp
|
76
106
|
end
|
77
107
|
|
78
|
-
def
|
79
|
-
|
108
|
+
def get_token
|
109
|
+
client.login = github.user
|
110
|
+
client.password = github.password
|
111
|
+
|
112
|
+
authorization = client.create_authorization({:scopes => ['public_repo'], :note => 'Code Kata'})
|
80
113
|
|
81
114
|
github.token = authorization.token
|
82
115
|
|
@@ -85,29 +118,34 @@ EOF
|
|
85
118
|
end
|
86
119
|
|
87
120
|
def create_remote_repo
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
121
|
+
client_factory
|
122
|
+
|
123
|
+
begin
|
124
|
+
print "Creating remote repo..."
|
125
|
+
client.create_repo "#{repo_name}"
|
126
|
+
rescue Exception
|
127
|
+
puts "\nError: unable to create the git repo."
|
128
|
+
print 'Proceeding...'
|
129
|
+
ensure
|
130
|
+
puts "done"
|
131
|
+
end
|
93
132
|
end
|
94
133
|
|
95
134
|
def push_local_repo(new_repo)
|
96
|
-
print "creating files for repo and initializing..."
|
97
|
-
|
98
135
|
cmd = "cd #{repo_name} &&"
|
99
136
|
|
100
137
|
if new_repo
|
101
|
-
cmd << "git init
|
102
|
-
cmd << "git add README .rspec lib/ spec/
|
138
|
+
cmd << "git init &&"
|
139
|
+
#cmd << "git add README .rspec lib/ spec/ &&"
|
140
|
+
cmd << "git add . &&"
|
103
141
|
else
|
104
|
-
cmd << "git add #{ENV['PWD']}/#{repo_name}
|
142
|
+
cmd << "git add #{ENV['PWD']}/#{repo_name};"
|
105
143
|
end
|
106
144
|
|
107
|
-
cmd << "git commit -m 'starting kata'
|
145
|
+
cmd << "git commit -m 'starting kata';"
|
108
146
|
|
109
147
|
if new_repo
|
110
|
-
cmd << "git remote add origin git@github.com:#{github.user}/#{repo_name}.git
|
148
|
+
cmd << "git remote add origin git@github.com:#{github.user}/#{repo_name}.git &&"
|
111
149
|
end
|
112
150
|
|
113
151
|
cmd << 'git push origin master'
|
@@ -2,31 +2,21 @@ require 'kata/setup/base'
|
|
2
2
|
|
3
3
|
module Kata
|
4
4
|
module Setup
|
5
|
-
class
|
5
|
+
class Node < Kata::Setup::Base
|
6
6
|
def build_tree
|
7
7
|
%w{lib spec}.each { |path| tree(path) }
|
8
8
|
readme
|
9
9
|
package_json
|
10
|
-
|
10
|
+
autotest
|
11
|
+
kata_file
|
11
12
|
kata_spec
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
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
17
|
# Using here docs for a cheap templating system
|
28
18
|
def package_json
|
29
|
-
|
19
|
+
write_repo_file('package.json',<<EOF)
|
30
20
|
{
|
31
21
|
"name": "#{use_kata_name}",
|
32
22
|
"version": "0.0.1",
|
@@ -38,9 +28,13 @@ module Kata
|
|
38
28
|
EOF
|
39
29
|
end
|
40
30
|
|
41
|
-
def
|
31
|
+
def autotest
|
32
|
+
write_repo_file('autotest',"./node_modules/jasmine-node/bin/jasmine-node --autotest --color spec/", 0755)
|
33
|
+
end
|
34
|
+
|
35
|
+
def kata_file
|
42
36
|
# create the base class file
|
43
|
-
|
37
|
+
write_repo_file(File.join('lib', "#{use_kata_name}.js"),<<EOF)
|
44
38
|
var expression = null;
|
45
39
|
|
46
40
|
exports.getExpr = function() {
|
@@ -50,7 +44,7 @@ EOF
|
|
50
44
|
end
|
51
45
|
|
52
46
|
def kata_spec
|
53
|
-
|
47
|
+
write_repo_file(File.join('spec', "#{use_kata_name}_spec.js"),<<EOF)
|
54
48
|
var #{use_kata_name} = require("../lib/#{use_kata_name}");
|
55
49
|
|
56
50
|
describe("#{class_name}", function() {
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'kata/setup/base'
|
2
|
+
|
3
|
+
module Kata
|
4
|
+
module Setup
|
5
|
+
class Php < Kata::Setup::Base
|
6
|
+
def build_tree
|
7
|
+
%w{src test}.each { |path| tree(path) }
|
8
|
+
readme
|
9
|
+
bootstrap
|
10
|
+
composer_json
|
11
|
+
base_class
|
12
|
+
php_test
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# Using here docs for a cheap templating system
|
18
|
+
def bootstrap
|
19
|
+
write_repo_file('bootstrap.h',<<EOF)
|
20
|
+
#!/bin/sh
|
21
|
+
|
22
|
+
php_version=$(php -v | head -1 | awk '{print $2}' | sed 's/\\.//g')
|
23
|
+
composer_version=5320
|
24
|
+
|
25
|
+
if [[ $php_version -gt $composer_version ]]; then
|
26
|
+
curl -sS https://getcomposer.org/installer | php
|
27
|
+
mv composer.phar composer
|
28
|
+
chmod 755 composer
|
29
|
+
./composer install
|
30
|
+
export PATH=vendor/bin:$PATH
|
31
|
+
else
|
32
|
+
curl -O https://phar.phpunit.de/phpunit.phar
|
33
|
+
mv phpunit.phar phpunit
|
34
|
+
chmod 755 phpunit
|
35
|
+
fi
|
36
|
+
EOF
|
37
|
+
end
|
38
|
+
|
39
|
+
def composer_json
|
40
|
+
write_repo_file('composer.json',<<EOF)
|
41
|
+
{
|
42
|
+
"require-dev": {
|
43
|
+
"phpunit/phpunit": "4.1.*"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
EOF
|
47
|
+
end
|
48
|
+
|
49
|
+
def base_class
|
50
|
+
write_repo_file(File.join('src', "#{class_name}.php"),<<EOF)
|
51
|
+
<?php
|
52
|
+
|
53
|
+
class #{class_name} {
|
54
|
+
|
55
|
+
public function __construct() { }
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
?>
|
60
|
+
EOF
|
61
|
+
end
|
62
|
+
|
63
|
+
def php_test
|
64
|
+
write_repo_file(File.join('test', "#{class_name}Test.php"),<<EOF)
|
65
|
+
<?php
|
66
|
+
|
67
|
+
require 'src/#{class_name}.php';
|
68
|
+
|
69
|
+
class #{class_name}Test extends PHPUnit_Framework_TestCase {
|
70
|
+
|
71
|
+
public function testInstatiate#{class_name}() {
|
72
|
+
try {
|
73
|
+
$calc = new #{class_name}();
|
74
|
+
} catch (Exception $e) {
|
75
|
+
$this->fail();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
?>
|
82
|
+
EOF
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
data/lib/kata/setup/ruby.rb
CHANGED
@@ -4,30 +4,43 @@ module Kata
|
|
4
4
|
module Setup
|
5
5
|
class Ruby < Kata::Setup::Base
|
6
6
|
def build_tree
|
7
|
-
%w{lib spec
|
7
|
+
%w{lib spec}.each { |path| tree(path) }
|
8
8
|
readme
|
9
|
+
bootstrap
|
10
|
+
gemfile
|
9
11
|
base_class
|
10
|
-
|
11
|
-
spec_helper
|
12
|
+
dot_files
|
12
13
|
kata_spec
|
13
|
-
spec_matcher
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
def bootstrap
|
19
|
+
write_repo_file('bootstrap.sh',<<EOF)
|
20
|
+
#!/bin/bash
|
21
|
+
gem install bundler
|
22
|
+
bundle install
|
23
|
+
EOF
|
24
|
+
end
|
25
|
+
|
26
|
+
def gemfile
|
27
|
+
write_repo_file('Gemfile',<<EOF)
|
28
|
+
source 'http://rubygems.org'
|
29
29
|
|
30
|
-
|
30
|
+
gem 'kata'
|
31
|
+
|
32
|
+
group :test do
|
33
|
+
gem 'rspec'
|
34
|
+
gem 'autotest'
|
35
|
+
gem 'autotest-growl'
|
36
|
+
gem 'rspec-autotest'
|
37
|
+
end
|
38
|
+
|
39
|
+
group :development do
|
40
|
+
gem 'debugger'
|
41
|
+
gem 'pry'
|
42
|
+
end
|
43
|
+
EOF
|
31
44
|
end
|
32
45
|
|
33
46
|
# Using here docs for a cheap templating system
|
@@ -39,25 +52,18 @@ end
|
|
39
52
|
EOF
|
40
53
|
end
|
41
54
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
File.open(File.join(repo_name, 'spec', 'spec_helper.rb'), 'w') {|f| f.write <<EOF}
|
50
|
-
$: << '.' << File.join(File.dirname(__FILE__), '..', 'lib')
|
51
|
-
|
52
|
-
require 'rspec'
|
53
|
-
|
54
|
-
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
55
|
+
def dot_files
|
56
|
+
write_repo_file('.rspec', '--color --format d')
|
57
|
+
write_repo_file('.ruby-version', 'ruby-2.0.0-p481')
|
58
|
+
write_repo_file('.ruby-gemset', "kata-#{use_kata_name}")
|
59
|
+
write_repo_file('.autotest', <<EOF)
|
60
|
+
require 'autotest'
|
61
|
+
require 'autotest-growl'
|
55
62
|
EOF
|
56
63
|
end
|
57
64
|
|
58
65
|
def kata_spec
|
59
66
|
File.open(File.join(repo_name, 'spec', "#{use_kata_name}_spec.rb"), 'w') {|f| f.write <<EOF}
|
60
|
-
require 'spec_helper'
|
61
67
|
require '#{use_kata_name}'
|
62
68
|
|
63
69
|
describe #{class_name} do
|
@@ -69,16 +75,6 @@ describe #{class_name} do
|
|
69
75
|
end
|
70
76
|
end
|
71
77
|
end
|
72
|
-
EOF
|
73
|
-
end
|
74
|
-
|
75
|
-
def spec_matcher
|
76
|
-
File.open(File.join(repo_name, 'spec', 'support', 'matchers', "#{use_kata_name}.rb"), 'w') {|f| f.write <<EOF}
|
77
|
-
RSpec::Matchers.define :your_method do |expected|
|
78
|
-
match do |your_match|
|
79
|
-
#expect(your_match.method_on_object_to_execute).to eq(expected)
|
80
|
-
end
|
81
|
-
end
|
82
78
|
EOF
|
83
79
|
end
|
84
80
|
end
|
data/lib/kata/version.rb
CHANGED
data/spec/setup/base_spec.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'kata/setup/base'
|
3
|
+
require 'kata/setup/ruby'
|
4
|
+
require 'kata/setup/node'
|
5
|
+
require 'kata/setup/php'
|
3
6
|
|
4
7
|
module Kata
|
5
8
|
module Setup
|
@@ -14,6 +17,62 @@ module Kata
|
|
14
17
|
expect(s.kata_name).to eq('my-kata')
|
15
18
|
end
|
16
19
|
end
|
20
|
+
|
21
|
+
describe '#create_repo' do
|
22
|
+
#subject {Kata::Setup::Base.new}
|
23
|
+
|
24
|
+
let(:no_repo) {OpenStruct.new(:repo => false)}
|
25
|
+
let(:with_repo) {OpenStruct.new(:repo => true)}
|
26
|
+
|
27
|
+
it 'only creates if specified' do
|
28
|
+
expect(subject).to_not receive(:create_remote_repo)
|
29
|
+
expect(subject).to receive(:push_local_repo)
|
30
|
+
|
31
|
+
subject.create_repo(no_repo)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'creates when specified' do
|
35
|
+
expect(subject).to receive(:create_remote_repo)
|
36
|
+
expect(subject).to receive(:push_local_repo)
|
37
|
+
|
38
|
+
subject.create_repo(with_repo)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#build_tree" do
|
43
|
+
subject {Kata::Setup::Base.new}
|
44
|
+
|
45
|
+
let(:ruby_setup) {Kata::Setup::Ruby.new('kata')}
|
46
|
+
let(:node_setup) {Kata::Setup::Node.new('kata')}
|
47
|
+
let(:php_setup) {Kata::Setup::Php.new('kata')}
|
48
|
+
|
49
|
+
it 'invokes the ruby setup' do
|
50
|
+
expect(Kata::Setup::Ruby).to receive(:new).and_return(ruby_setup)
|
51
|
+
expect(ruby_setup).to receive(:build_tree)
|
52
|
+
|
53
|
+
subject.build_tree 'ruby'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'invokes the node setup' do
|
57
|
+
expect(Kata::Setup::Node).to receive(:new).and_return(node_setup)
|
58
|
+
expect(node_setup).to receive(:build_tree)
|
59
|
+
|
60
|
+
subject.build_tree 'node'
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'invokes the php setup' do
|
64
|
+
expect(Kata::Setup::Php).to receive(:new).and_return(php_setup)
|
65
|
+
expect(php_setup).to receive(:build_tree)
|
66
|
+
|
67
|
+
subject.build_tree 'php'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'rejects invalid language types' do
|
71
|
+
expect {
|
72
|
+
subject.build_tree 'asdf'
|
73
|
+
}.to raise_error
|
74
|
+
end
|
75
|
+
end
|
17
76
|
end
|
18
77
|
end
|
19
78
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "kata/setup/
|
2
|
+
require "kata/setup/node"
|
3
3
|
require "fakefs/spec_helpers"
|
4
4
|
|
5
5
|
module Kata
|
6
6
|
module Setup
|
7
|
-
describe
|
7
|
+
describe Node do
|
8
8
|
describe "#build_tree" do
|
9
9
|
include FakeFS::SpecHelpers
|
10
10
|
|
@@ -25,11 +25,19 @@ module Kata
|
|
25
25
|
expect(File.exists?(File.join(@use_dir, "README"))).to be true
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "creates package.json file" do
|
29
|
+
expect(File.exists?(File.join(@use_dir, "package.json"))).to be true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "creates autotest file" do
|
33
|
+
expect(File.exists?(File.join(@use_dir, "autotest"))).to be true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "create kata main file" do
|
29
37
|
expect(File.exists?(File.join(@use_dir, "lib", "#{subject.kata_name}.js"))).to be true
|
30
38
|
end
|
31
39
|
|
32
|
-
it "creates
|
40
|
+
it "creates kata spec file" do
|
33
41
|
expect(File.exists?(File.join(@use_dir, "spec", "#{subject.kata_name}_spec.js"))).to be true
|
34
42
|
end
|
35
43
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "kata/setup/php"
|
3
|
+
require "fakefs/spec_helpers"
|
4
|
+
|
5
|
+
module Kata
|
6
|
+
module Setup
|
7
|
+
describe Php 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
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:class_name) {
|
18
|
+
subject.kata_name.split(/ |-|_/).map(&:capitalize).join
|
19
|
+
}
|
20
|
+
|
21
|
+
it "creates src dir" do
|
22
|
+
expect(File.directory?(File.join(@use_dir, "src"))).to be true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "creates test dir" do
|
26
|
+
expect(File.directory?(File.join(@use_dir, "test"))).to be true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "creates README file" do
|
30
|
+
expect(File.exists?(File.join(@use_dir, "README"))).to be true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "create base class file" do
|
34
|
+
expect(File.exists?(File.join(@use_dir, "src", "#{class_name}.php"))).to be true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "creates base test file" do
|
38
|
+
expect(File.exists?(File.join(@use_dir, "test", "#{class_name}Test.php"))).to be true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/setup/ruby_spec.rb
CHANGED
@@ -17,20 +17,20 @@ module Kata
|
|
17
17
|
expect(File.directory?(File.join(@use_dir, "lib"))).to be true
|
18
18
|
end
|
19
19
|
|
20
|
-
it "creates
|
20
|
+
it "creates spec dir" do
|
21
21
|
expect(File.directory?(File.join(@use_dir, "spec"))).to be true
|
22
22
|
end
|
23
23
|
|
24
|
-
it "creates
|
25
|
-
expect(File.
|
24
|
+
it "creates README file" do
|
25
|
+
expect(File.exists?(File.join(@use_dir, "README"))).to be true
|
26
26
|
end
|
27
27
|
|
28
|
-
it "creates
|
29
|
-
expect(File.
|
28
|
+
it "creates bootstrap file" do
|
29
|
+
expect(File.exists?(File.join(@use_dir, "bootstrap.sh"))).to be true
|
30
30
|
end
|
31
31
|
|
32
|
-
it "creates
|
33
|
-
expect(File.exists?(File.join(@use_dir, "
|
32
|
+
it "creates Gemfile file" do
|
33
|
+
expect(File.exists?(File.join(@use_dir, "Gemfile"))).to be true
|
34
34
|
end
|
35
35
|
|
36
36
|
it "create base class file" do
|
@@ -41,17 +41,9 @@ module Kata
|
|
41
41
|
expect(File.exists?(File.join(@use_dir, ".rspec"))).to be true
|
42
42
|
end
|
43
43
|
|
44
|
-
it "creates spec helper file" do
|
45
|
-
expect(File.exists?(File.join(@use_dir, "spec", "spec_helper.rb"))).to be true
|
46
|
-
end
|
47
|
-
|
48
44
|
it "creates base spec file" do
|
49
45
|
expect(File.exists?(File.join(@use_dir, "spec", "#{subject.kata_name}_spec.rb"))).to be true
|
50
46
|
end
|
51
|
-
|
52
|
-
it "creates spec matcher file" do
|
53
|
-
expect(File.exists?(File.join(@use_dir, "spec", "support", "matchers", "#{subject.kata_name}.rb"))).to be true
|
54
|
-
end
|
55
47
|
end
|
56
48
|
end
|
57
49
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
$: <<
|
1
|
+
$: << '.' << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'rspec'
|
4
|
+
require 'kata/base'
|
5
|
+
require 'simplecov'
|
6
|
+
require 'codeclimate-test-reporter'
|
6
7
|
|
7
|
-
|
8
|
+
CodeClimate::TestReporter.start
|
9
|
+
|
10
|
+
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each {|f| require f}
|
8
11
|
|
9
12
|
RSpec.configure do |config|
|
10
13
|
config.before(:each) do
|
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.6.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-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -66,13 +66,15 @@ files:
|
|
66
66
|
- lib/kata.rb
|
67
67
|
- lib/kata/base.rb
|
68
68
|
- lib/kata/setup/base.rb
|
69
|
-
- lib/kata/setup/
|
69
|
+
- lib/kata/setup/node.rb
|
70
|
+
- lib/kata/setup/php.rb
|
70
71
|
- lib/kata/setup/ruby.rb
|
71
72
|
- lib/kata/version.rb
|
72
73
|
- spec/kata_base_spec.rb
|
73
74
|
- spec/kata_spec.rb
|
74
75
|
- spec/setup/base_spec.rb
|
75
|
-
- spec/setup/
|
76
|
+
- spec/setup/node_spec.rb
|
77
|
+
- spec/setup/php_spec.rb
|
76
78
|
- spec/setup/ruby_spec.rb
|
77
79
|
- spec/spec_helper.rb
|
78
80
|
- spec/support/helpers/stdout_helper.rb
|
@@ -104,7 +106,8 @@ test_files:
|
|
104
106
|
- spec/kata_base_spec.rb
|
105
107
|
- spec/kata_spec.rb
|
106
108
|
- spec/setup/base_spec.rb
|
107
|
-
- spec/setup/
|
109
|
+
- spec/setup/node_spec.rb
|
110
|
+
- spec/setup/php_spec.rb
|
108
111
|
- spec/setup/ruby_spec.rb
|
109
112
|
- spec/spec_helper.rb
|
110
113
|
- spec/support/helpers/stdout_helper.rb
|