goku 0.5 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -10
- data/goku.gemspec +1 -0
- data/lib/goku.rb +2 -0
- data/lib/goku/cli.rb +33 -8
- data/lib/goku/element_factory.rb +2 -2
- data/lib/goku/elements/spec.rb +1 -1
- data/lib/goku/path.rb +4 -0
- data/lib/goku/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ee8f922500529f81d6cf4be309ec63bd5ad6bb
|
4
|
+
data.tar.gz: 4a6d935ec336a507dd209b4ca8f0ad209ce33d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 919400e3de020691a36ea252da2b11b8faec6b8161b44430b2c2f36b03fe32ecc92ce15ab2b549c999f97f0f29a0f44c99891edb332488e33010376f9e6d8ecb
|
7
|
+
data.tar.gz: c6f87e36d5ad17520abc44ecc89c9eb21495c065350c8fc42d00fd6fcd001174079570d9ffee74e927b6e472a1b18f1613a3b234e440bd506f2f62b4b95de313
|
data/README.md
CHANGED
@@ -24,14 +24,14 @@ Or install it yourself as:
|
|
24
24
|
## Usage
|
25
25
|
|
26
26
|
``` sh
|
27
|
-
goku class lib/users/signup.rb
|
27
|
+
$ goku class lib/users/signup.rb
|
28
|
+
Creating lib/users/signup.rb
|
29
|
+
Creating spec/lib/users/signup_spec.rb
|
28
30
|
```
|
29
31
|
|
30
|
-
Creates a class in
|
32
|
+
Creates a class in `lib/users/signup.rb`:
|
31
33
|
|
32
34
|
``` ruby
|
33
|
-
# lib/users/signup.rb
|
34
|
-
|
35
35
|
module Users
|
36
36
|
class Signup
|
37
37
|
|
@@ -42,17 +42,13 @@ module Users
|
|
42
42
|
end
|
43
43
|
```
|
44
44
|
|
45
|
-
And a
|
45
|
+
And a RSpec test file `spec/lib/users/signup_spec.rb`:
|
46
46
|
|
47
47
|
``` ruby
|
48
|
-
# spec/lib/users/signup_spec.rb
|
49
|
-
|
50
48
|
require "spec_helper"
|
51
49
|
|
52
|
-
|
53
|
-
RSpec.describe Signup do
|
50
|
+
describe Users::Signup do
|
54
51
|
|
55
|
-
end
|
56
52
|
end
|
57
53
|
```
|
58
54
|
## Development
|
data/goku.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "thor", "~> 0.19"
|
22
22
|
spec.add_dependency "activesupport", "~> 4.2"
|
23
|
+
spec.add_dependency "colorize", "~> 0.7"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.11"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/goku.rb
CHANGED
data/lib/goku/cli.rb
CHANGED
@@ -2,25 +2,50 @@ module Goku
|
|
2
2
|
class CLI < Thor
|
3
3
|
|
4
4
|
desc "c PATH", "Create a class"
|
5
|
-
def c(
|
5
|
+
def c(raw_path)
|
6
|
+
path = Goku::Path.new(raw_path)
|
6
7
|
factory = Goku::ElementFactory.new(path)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
implementation = factory.create_class.to_s
|
10
|
+
spec = factory.create_spec.to_s
|
11
|
+
|
12
|
+
save(path, implementation, spec)
|
11
13
|
end
|
12
14
|
|
13
15
|
desc "m PATH", "Create a module"
|
14
|
-
def m(
|
16
|
+
def m(raw_path)
|
17
|
+
path = Goku::Path.new(raw_path)
|
15
18
|
factory = Goku::ElementFactory.new(path)
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
implementation = factory.create_module.to_s
|
21
|
+
spec = factory.create_spec.to_s
|
22
|
+
|
23
|
+
save(path, implementation, spec)
|
20
24
|
end
|
21
25
|
|
22
26
|
map "module" => "m"
|
23
27
|
map "class" => "m"
|
24
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def save(path, implementation, spec)
|
32
|
+
failure("File #{path.full.colorize(:red)} already exists") if path.exists?
|
33
|
+
failure("Spec #{path.to_spec.full.colorize(:red)} already exists") if path.to_spec.exists?
|
34
|
+
|
35
|
+
puts "Creating #{path.full.colorize(:green)}"
|
36
|
+
FileUtils.mkdir_p(File.dirname(path.full))
|
37
|
+
File.write(path.full, implementation)
|
38
|
+
|
39
|
+
puts "Creating #{path.to_spec.full.colorize(:green)}"
|
40
|
+
FileUtils.mkdir_p(File.dirname(path.to_spec.full))
|
41
|
+
File.write(path.to_spec.full, spec)
|
42
|
+
end
|
43
|
+
|
44
|
+
def failure(message)
|
45
|
+
puts message
|
46
|
+
|
47
|
+
exit(1)
|
48
|
+
end
|
49
|
+
|
25
50
|
end
|
26
51
|
end
|
data/lib/goku/element_factory.rb
CHANGED
data/lib/goku/elements/spec.rb
CHANGED
data/lib/goku/path.rb
CHANGED
data/lib/goku/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|