mini_mindmap 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +4 -2
- data/lib/mini_mindmap.rb +12 -4
- data/lib/mini_mindmap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f24a2e0b808b8387d32b02a04baa1eb6fa570955125ac4c88fdc076bb68d065
|
4
|
+
data.tar.gz: 24e0d5afa135f91a32acfa90d1a2553892c275ba48428c78f950763ffcf17b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde88c6ffc6e8e375c393d71222c20bdf6d46cd397b503e946d7ca4b711f11e09c4bbb27f9024403bf5ca7982f6fdccb6d95e5e74670a2666b03ecab71b7968b
|
7
|
+
data.tar.gz: ebc14a4a642135b11980befe86dbb25ecea1a2c8b485b6875ed38a7675b540168d456f11c22149a37df8ff6f805fdc70107c2bdde0dc77f6f0b79880bae91396
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# MiniMindmap
|
2
2
|
|
3
|
-
|
3
|
+
## Prepare
|
4
4
|
|
5
|
-
|
5
|
+
You need install graphviz first.
|
6
|
+
|
7
|
+
[graphviz download](http://www.graphviz.org/download/)
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
data/lib/mini_mindmap.rb
CHANGED
@@ -29,7 +29,7 @@ module MiniMindmap
|
|
29
29
|
yield(self) if block_given?
|
30
30
|
end
|
31
31
|
|
32
|
-
attr_accessor(:name, :dsl, :output, :nodes)
|
32
|
+
attr_accessor(:name, :dsl, :output, :nodes, :declares)
|
33
33
|
|
34
34
|
def compile(code)
|
35
35
|
# TODO 增加拓展语法支持 label等自定义
|
@@ -45,25 +45,32 @@ module MiniMindmap
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def basic_processor
|
48
|
+
declares = [];
|
48
49
|
nodes = []
|
49
50
|
stack = []
|
50
51
|
dsl = @dsl.split("\n")
|
51
52
|
dsl.each_with_index do |code, current_index|
|
52
53
|
|
53
54
|
if not code.strip.empty?
|
55
|
+
current_id = current_index
|
54
56
|
current = self.compile(code)
|
57
|
+
current << current_id
|
58
|
+
|
59
|
+
|
60
|
+
current_declare = "node#{current_id}[label=\"#{current[2]}\"]";
|
61
|
+
declares.push(current_declare)
|
55
62
|
|
56
63
|
unless stack.empty?
|
57
64
|
top = stack.pop
|
58
65
|
if current[1] > top[1]
|
59
|
-
nodes << "#{top[
|
66
|
+
nodes << "node#{top[3]} -> node#{current[3]}"
|
60
67
|
stack.push(top)
|
61
68
|
else
|
62
69
|
while (current[1] <= top[1]) and (not stack.empty?)
|
63
70
|
top = stack.pop
|
64
71
|
end
|
65
72
|
if current[1] > top[1]
|
66
|
-
nodes << "#{top[
|
73
|
+
nodes << "node#{top[3]} -> node#{current[3]}"
|
67
74
|
stack.push top
|
68
75
|
end
|
69
76
|
|
@@ -72,6 +79,7 @@ module MiniMindmap
|
|
72
79
|
stack.push(current)
|
73
80
|
end
|
74
81
|
end
|
82
|
+
@declares = declares
|
75
83
|
@nodes = nodes
|
76
84
|
end
|
77
85
|
|
@@ -80,7 +88,7 @@ module MiniMindmap
|
|
80
88
|
end
|
81
89
|
|
82
90
|
def package_nodes
|
83
|
-
"digraph #{@name} {\n#{@nodes.join("\n")}\n}"
|
91
|
+
"digraph #{@name} {\n#{@declares.join("\n")}\n#{@nodes.join("\n")}\n}"
|
84
92
|
end
|
85
93
|
|
86
94
|
def nodes_to_doc
|
data/lib/mini_mindmap/version.rb
CHANGED