visualize_ruby 0.7.0 → 0.8.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 +4 -0
- data/lib/visualize_ruby/parser/and.rb +2 -1
- data/lib/visualize_ruby/parser/conditions.rb +13 -0
- data/lib/visualize_ruby/parser/if.rb +1 -8
- data/lib/visualize_ruby/parser/or.rb +2 -3
- data/lib/visualize_ruby/parser.rb +1 -0
- data/lib/visualize_ruby/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 065c1db111e1a4716755a68ff69bce287b3192d4939f86cd2913d67ff8aaa0ad
|
4
|
+
data.tar.gz: 3440f90a823b7fe3c4a1b236f39948a237ecc645ca0e86fcf7cf5b82ea78d864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8179f8b332606875a3fde94e873abee27aa5eb3edb68a3d210a9eef522ba6431013d83be06d77061a31f58eca6d032404d67529b8537c96e9898f8cff6d8d0c3
|
7
|
+
data.tar.gz: be6299a6bbcf6f6e61e552f050a78ee8710190b4eb4afcbdf0a329bea2ef320cb33aa67ce4b27ed6db0c7532c68f724ae50346f05e1a3ed65da27ecb4754070a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## 0.8.0 - 2018-07-17
|
5
|
+
### Enhancement
|
6
|
+
* Better handle conditions outside of if statements.
|
7
|
+
|
4
8
|
## 0.7.0 - 2018-07-17
|
5
9
|
### Fix
|
6
10
|
* Ruby types like Hash and Array causing error. Now render as code.
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module VisualizeRuby
|
2
2
|
class Parser
|
3
3
|
class And < Base
|
4
|
+
include Conditions
|
4
5
|
# @return [Array<VisualizeRuby::Node>, Array<VisualizeRuby::Edge>]
|
5
6
|
def parse
|
6
7
|
last_node = nil
|
7
8
|
edges = []
|
8
9
|
nodes = @ast.children.reverse.map do |c|
|
9
|
-
node =
|
10
|
+
node = set_conditions(c).first
|
10
11
|
edges << Edge.new(name: "AND", nodes: [node, last_node]) if last_node
|
11
12
|
last_node = node
|
12
13
|
node
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module VisualizeRuby
|
2
|
+
class Parser
|
3
|
+
module Conditions
|
4
|
+
def set_conditions(condition)
|
5
|
+
condition_nodes, condition_edges = Parser.new(ast: condition).parse
|
6
|
+
condition_nodes.first.type = :decision
|
7
|
+
nodes.concat(condition_nodes)
|
8
|
+
edges.concat(condition_edges)
|
9
|
+
condition_nodes
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module VisualizeRuby
|
2
2
|
class Parser
|
3
3
|
class If < Base
|
4
|
+
include Conditions
|
4
5
|
# @return [Array<VisualizeRuby::Node>, Array<VisualizeRuby::Edge>]
|
5
6
|
def parse
|
6
7
|
break_ast
|
@@ -27,14 +28,6 @@ module VisualizeRuby
|
|
27
28
|
|
28
29
|
private
|
29
30
|
|
30
|
-
def set_conditions(condition)
|
31
|
-
condition_nodes, condition_edges = Parser.new(ast: condition).parse
|
32
|
-
condition_nodes.first.type = :decision
|
33
|
-
nodes.concat(condition_nodes)
|
34
|
-
edges.concat(condition_edges)
|
35
|
-
condition_nodes
|
36
|
-
end
|
37
|
-
|
38
31
|
attr_reader :condition, :on_true, :on_false
|
39
32
|
|
40
33
|
def break_ast
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module VisualizeRuby
|
2
2
|
class Parser
|
3
3
|
class Or < Base
|
4
|
-
|
4
|
+
include Conditions
|
5
5
|
# @return [Array<VisualizeRuby::Node>, Array<VisualizeRuby::Edge>]
|
6
6
|
def parse
|
7
7
|
last_node = nil
|
8
8
|
@ast.children.reverse.map do |c|
|
9
|
-
node =
|
9
|
+
node = set_conditions(c).first
|
10
10
|
edges << Edge.new(name: "OR", nodes: [node, last_node]) if last_node
|
11
11
|
last_node = node
|
12
|
-
nodes << node
|
13
12
|
end
|
14
13
|
return nodes.reverse, edges
|
15
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visualize_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/visualize_ruby/parser/begin.rb
|
140
140
|
- lib/visualize_ruby/parser/block.rb
|
141
141
|
- lib/visualize_ruby/parser/case.rb
|
142
|
+
- lib/visualize_ruby/parser/conditions.rb
|
142
143
|
- lib/visualize_ruby/parser/false.rb
|
143
144
|
- lib/visualize_ruby/parser/if.rb
|
144
145
|
- lib/visualize_ruby/parser/or.rb
|