goku 0.4.1 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/goku.rb +2 -0
- data/lib/goku/cli.rb +10 -2
- data/lib/goku/element_factory.rb +8 -4
- data/lib/goku/elements/method_spec.rb +11 -0
- data/lib/goku/elements/spec.rb +19 -0
- data/lib/goku/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0d25d655bc72bc176f604e3ceae388bcd41651e
|
4
|
+
data.tar.gz: bba176c04c19d67b1099c4cd9ea38f4edbbda315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea5333b4dd4aa3382af39bc535b94b12c86cf560246a2b0b542613b62c714fd4dd269a44845f24d0bec43d1b2439d5cdf46ed4c6b58d61333b06916234287926
|
7
|
+
data.tar.gz: aa4eaded1b969ad8fa0f7abaa17eb403bff15617666f6cef0db6ddc86ebb1ef497e96533a9bc983a64ef3dfe54cb146a765a27de60fb9eac2902e31e0d880c1c
|
data/lib/goku.rb
CHANGED
data/lib/goku/cli.rb
CHANGED
@@ -3,12 +3,20 @@ module Goku
|
|
3
3
|
|
4
4
|
desc "c PATH", "Create a class"
|
5
5
|
def c(path)
|
6
|
-
|
6
|
+
factory = Goku::ElementFactory.new(path)
|
7
|
+
|
8
|
+
puts factory.create_class.to_s
|
9
|
+
puts "---------------------"
|
10
|
+
puts factory.create_spec.to_s
|
7
11
|
end
|
8
12
|
|
9
13
|
desc "m PATH", "Create a module"
|
10
14
|
def m(path)
|
11
|
-
|
15
|
+
factory = Goku::ElementFactory.new(path)
|
16
|
+
|
17
|
+
puts factory.create_module.to_s
|
18
|
+
puts "---------------------"
|
19
|
+
puts factory.create_spec.to_s
|
12
20
|
end
|
13
21
|
|
14
22
|
map "module" => "m"
|
data/lib/goku/element_factory.rb
CHANGED
@@ -15,20 +15,24 @@ module Goku
|
|
15
15
|
nested(Goku::Elements::Module.new(path.filename))
|
16
16
|
end
|
17
17
|
|
18
|
+
def create_spec
|
19
|
+
Goku::Elements::Spec.new(path.filename, ancestor_names)
|
20
|
+
end
|
21
|
+
|
18
22
|
def ancestors
|
19
23
|
@ancestors ||= ancestor_names.map { |m| Goku::Elements::Module.new(m) }
|
20
24
|
end
|
21
25
|
|
22
26
|
def ancestor_names
|
23
|
-
@ancestor_names ||= @path.directories.drop(1)
|
27
|
+
@ancestor_names ||= @path.directories.drop(1)
|
24
28
|
end
|
25
29
|
|
26
30
|
def nested(element)
|
27
|
-
ancestors.each_cons(2) { |
|
31
|
+
ancestors.each_cons(2) { |parent, sub| parent.add(sub) }
|
28
32
|
|
29
|
-
ancestors.
|
33
|
+
ancestors.last.add(element)
|
30
34
|
|
31
|
-
ancestors.
|
35
|
+
ancestors.first
|
32
36
|
end
|
33
37
|
|
34
38
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Goku
|
2
|
+
module Elements
|
3
|
+
class Spec < Base
|
4
|
+
|
5
|
+
def initialize(name, ancestor_names)
|
6
|
+
super(name)
|
7
|
+
|
8
|
+
@ancestor_names = ancestor_names
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
full_name = (@ancestor_names + [name]).map(&:camelcase).join("::")
|
13
|
+
|
14
|
+
"describe #{full_name} do\n#{super}\nend"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
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: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
@@ -119,7 +119,9 @@ files:
|
|
119
119
|
- lib/goku/elements/base.rb
|
120
120
|
- lib/goku/elements/class.rb
|
121
121
|
- lib/goku/elements/method.rb
|
122
|
+
- lib/goku/elements/method_spec.rb
|
122
123
|
- lib/goku/elements/module.rb
|
124
|
+
- lib/goku/elements/spec.rb
|
123
125
|
- lib/goku/path.rb
|
124
126
|
- lib/goku/version.rb
|
125
127
|
homepage: https://github.com/shiroyasha/goku
|