mini_mindmap 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f406880d5f25e79b0f9c3522afbd2ae7ae75e9da002f71b19443211dbd8271fa
4
- data.tar.gz: e53d91bc604687a0fa05fb1d124793d67ce8002ec280ef8dfbd822a046c61ce0
3
+ metadata.gz: 1f24a2e0b808b8387d32b02a04baa1eb6fa570955125ac4c88fdc076bb68d065
4
+ data.tar.gz: 24e0d5afa135f91a32acfa90d1a2553892c275ba48428c78f950763ffcf17b19
5
5
  SHA512:
6
- metadata.gz: e9213b5bec48e3a74f7ba089d12c139b1bb88dd33dc2c3bbd728a2a9bf37c46a1bcb98811008e96fe74cb8b647fd316de04468e2eb1a09ee6b9ea100307bb122
7
- data.tar.gz: e290f4c98f793e96495d5262cb99ec03dc6653e927c1703436ae925812d0d0ba7a527de7ae7c19d3b3439e6ce7fbc4cb7b8709cc0a8fffec721eda68b2cc66b7
6
+ metadata.gz: bde88c6ffc6e8e375c393d71222c20bdf6d46cd397b503e946d7ca4b711f11e09c4bbb27f9024403bf5ca7982f6fdccb6d95e5e74670a2666b03ecab71b7968b
7
+ data.tar.gz: ebc14a4a642135b11980befe86dbb25ecea1a2c8b485b6875ed38a7675b540168d456f11c22149a37df8ff6f805fdc70107c2bdde0dc77f6f0b79880bae91396
@@ -1,6 +1,10 @@
1
+ ## 0.3.0
2
+
3
+ * Change to node style to export dotfile.
4
+
1
5
  ## 0.2.0
2
6
 
3
- * Export mindmap
7
+ * Export mindmap.
4
8
 
5
9
  ## 0.1.0
6
10
 
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # MiniMindmap
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mini_mindmap`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ## Prepare
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ You need install graphviz first.
6
+
7
+ [graphviz download](http://www.graphviz.org/download/)
6
8
 
7
9
  ## Installation
8
10
 
@@ -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[2]} -> #{current[2]}"
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[2]} -> #{current[2]}"
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
@@ -1,3 +1,3 @@
1
1
  module MiniMindmap
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_mindmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark24