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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c34932ce0351902f05dcb2d3d022919a0b961b3
4
- data.tar.gz: 19b0e917d94ead942e9289ac026f58f81516dedf
3
+ metadata.gz: c0d25d655bc72bc176f604e3ceae388bcd41651e
4
+ data.tar.gz: bba176c04c19d67b1099c4cd9ea38f4edbbda315
5
5
  SHA512:
6
- metadata.gz: 73aaba8d52c105791319d9c37dfc21500fb9e04e456dcffc4bcee128a62c024cc07b1e10e9df7eecc1b7afca20eb1a0563c28c31a22c716f81da13bd8d12d645
7
- data.tar.gz: 4e7e0d417549068ec0e8c13b245a32553b82d42d6daca407e31fc45b68850f6791252d8e2ade839fd4345345b1c524b8bf47b91efde3a177100ae17f3e8df6a0
6
+ metadata.gz: ea5333b4dd4aa3382af39bc535b94b12c86cf560246a2b0b542613b62c714fd4dd269a44845f24d0bec43d1b2439d5cdf46ed4c6b58d61333b06916234287926
7
+ data.tar.gz: aa4eaded1b969ad8fa0f7abaa17eb403bff15617666f6cef0db6ddc86ebb1ef497e96533a9bc983a64ef3dfe54cb146a765a27de60fb9eac2902e31e0d880c1c
@@ -5,6 +5,8 @@ require "goku/elements/base"
5
5
  require "goku/elements/method"
6
6
  require "goku/elements/class"
7
7
  require "goku/elements/module"
8
+ require "goku/elements/spec"
9
+ require "goku/elements/method_spec"
8
10
  require "goku/element_factory"
9
11
 
10
12
  require "goku/path"
@@ -3,12 +3,20 @@ module Goku
3
3
 
4
4
  desc "c PATH", "Create a class"
5
5
  def c(path)
6
- puts Goku::ElementFactory.new(path).create_class.to_s
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
- puts Goku::ElementFactory.new(path).create_module.to_s
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"
@@ -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).reverse
27
+ @ancestor_names ||= @path.directories.drop(1)
24
28
  end
25
29
 
26
30
  def nested(element)
27
- ancestors.each_cons(2) { |sub, parent| parent.add(sub) }
31
+ ancestors.each_cons(2) { |parent, sub| parent.add(sub) }
28
32
 
29
- ancestors.first.add(element)
33
+ ancestors.last.add(element)
30
34
 
31
- ancestors.last
35
+ ancestors.first
32
36
  end
33
37
 
34
38
  end
@@ -0,0 +1,11 @@
1
+ module Goku
2
+ module Elements
3
+ class MethodSpec < Base
4
+
5
+ def to_s
6
+ "\ndescribe \"##{name}\" do\nend\n"
7
+ end
8
+
9
+ end
10
+ end
11
+ 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
@@ -1,3 +1,3 @@
1
1
  module Goku
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5"
3
3
  end
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.1
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