goku 0.4 → 0.4.1
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 +5 -4
- data/lib/goku/cli.rb +4 -27
- data/lib/goku/element_factory.rb +35 -0
- data/lib/goku/{factories → elements}/base.rb +1 -1
- data/lib/goku/{factories → elements}/class.rb +2 -2
- data/lib/goku/{factories → elements}/method.rb +1 -1
- data/lib/goku/{factories → elements}/module.rb +1 -1
- data/lib/goku/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c34932ce0351902f05dcb2d3d022919a0b961b3
|
4
|
+
data.tar.gz: 19b0e917d94ead942e9289ac026f58f81516dedf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73aaba8d52c105791319d9c37dfc21500fb9e04e456dcffc4bcee128a62c024cc07b1e10e9df7eecc1b7afca20eb1a0563c28c31a22c716f81da13bd8d12d645
|
7
|
+
data.tar.gz: 4e7e0d417549068ec0e8c13b245a32553b82d42d6daca407e31fc45b68850f6791252d8e2ade839fd4345345b1c524b8bf47b91efde3a177100ae17f3e8df6a0
|
data/lib/goku.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "active_support/all"
|
3
3
|
|
4
|
-
require "goku/
|
5
|
-
require "goku/
|
6
|
-
require "goku/
|
7
|
-
require "goku/
|
4
|
+
require "goku/elements/base"
|
5
|
+
require "goku/elements/method"
|
6
|
+
require "goku/elements/class"
|
7
|
+
require "goku/elements/module"
|
8
|
+
require "goku/element_factory"
|
8
9
|
|
9
10
|
require "goku/path"
|
10
11
|
require "goku/version"
|
data/lib/goku/cli.rb
CHANGED
@@ -2,40 +2,17 @@ module Goku
|
|
2
2
|
class CLI < Thor
|
3
3
|
|
4
4
|
desc "c PATH", "Create a class"
|
5
|
-
def c(
|
6
|
-
|
7
|
-
|
8
|
-
modules = create_modules(path)
|
9
|
-
|
10
|
-
modules.last.add(Goku::Factories::Class.new(path.filename))
|
11
|
-
|
12
|
-
puts modules.first.to_s
|
5
|
+
def c(path)
|
6
|
+
puts Goku::ElementFactory.new(path).create_class.to_s
|
13
7
|
end
|
14
8
|
|
15
9
|
desc "m PATH", "Create a module"
|
16
|
-
def m(
|
17
|
-
|
18
|
-
|
19
|
-
modules = create_modules(path)
|
20
|
-
|
21
|
-
modules.last.add(Goku::Factories::Module.new(path.filename))
|
22
|
-
|
23
|
-
puts modules.first.to_s
|
10
|
+
def m(path)
|
11
|
+
puts Goku::ElementFactory.new(path).create_module.to_s
|
24
12
|
end
|
25
13
|
|
26
14
|
map "module" => "m"
|
27
15
|
map "class" => "m"
|
28
16
|
|
29
|
-
private
|
30
|
-
|
31
|
-
def create_modules(path)
|
32
|
-
modules = path.directories.drop(1).map { |m| Goku::Factories::Module.new(m) }
|
33
|
-
|
34
|
-
modules.reverse.each_cons(2) do |submodule, parent_module|
|
35
|
-
parent_module.add(submodule)
|
36
|
-
end
|
37
|
-
|
38
|
-
modules
|
39
|
-
end
|
40
17
|
end
|
41
18
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Goku
|
2
|
+
class ElementFactory
|
3
|
+
|
4
|
+
attr_reader :path
|
5
|
+
|
6
|
+
def initialize(raw_path)
|
7
|
+
@path = Goku::Path.new(raw_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_class
|
11
|
+
nested(Goku::Elements::Class.new(path.filename))
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_module
|
15
|
+
nested(Goku::Elements::Module.new(path.filename))
|
16
|
+
end
|
17
|
+
|
18
|
+
def ancestors
|
19
|
+
@ancestors ||= ancestor_names.map { |m| Goku::Elements::Module.new(m) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def ancestor_names
|
23
|
+
@ancestor_names ||= @path.directories.drop(1).reverse
|
24
|
+
end
|
25
|
+
|
26
|
+
def nested(element)
|
27
|
+
ancestors.each_cons(2) { |sub, parent| parent.add(sub) }
|
28
|
+
|
29
|
+
ancestors.first.add(element)
|
30
|
+
|
31
|
+
ancestors.last
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/lib/goku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -102,7 +102,6 @@ executables:
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
-
- ".byebug_history"
|
106
105
|
- ".gitignore"
|
107
106
|
- ".rspec"
|
108
107
|
- CODE_OF_CONDUCT.md
|
@@ -116,10 +115,11 @@ files:
|
|
116
115
|
- goku.gemspec
|
117
116
|
- lib/goku.rb
|
118
117
|
- lib/goku/cli.rb
|
119
|
-
- lib/goku/
|
120
|
-
- lib/goku/
|
121
|
-
- lib/goku/
|
122
|
-
- lib/goku/
|
118
|
+
- lib/goku/element_factory.rb
|
119
|
+
- lib/goku/elements/base.rb
|
120
|
+
- lib/goku/elements/class.rb
|
121
|
+
- lib/goku/elements/method.rb
|
122
|
+
- lib/goku/elements/module.rb
|
123
123
|
- lib/goku/path.rb
|
124
124
|
- lib/goku/version.rb
|
125
125
|
homepage: https://github.com/shiroyasha/goku
|