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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6655cbb07b2f7220d53af06fbe613c97ca457360f36d9fbbc03bb8fa409fdcf6
4
- data.tar.gz: f28064b42af7819dec8e73266e902217b399cbec08552c02ace05c311d8080fa
3
+ metadata.gz: 065c1db111e1a4716755a68ff69bce287b3192d4939f86cd2913d67ff8aaa0ad
4
+ data.tar.gz: 3440f90a823b7fe3c4a1b236f39948a237ecc645ca0e86fcf7cf5b82ea78d864
5
5
  SHA512:
6
- metadata.gz: 21021c4540db60df784411e44e360268fb52ceb3f097407053597a089a783bd72af4ed64c188e4069921807797637eca87f508a0c9a4ebf7a644585313880725
7
- data.tar.gz: 9b7c47fb8d402cb7b3c01a4604dfd3327e7355c326f38ab68f7da3c25db6ee3f6b9b72dca465fc95c94297b54096c9c51304bfb1c02918a16ef310bc9270c511
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 = Node.new(name: c.children.last, type: :decision)
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 = Node.new(name: AstHelper.new(c).description, type: :decision)
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
@@ -1,4 +1,5 @@
1
1
  require "parser/current"
2
+ require_relative "parser/conditions"
2
3
  require_relative "parser/base"
3
4
  require_relative "parser/or"
4
5
  require_relative "parser/and"
@@ -1,3 +1,3 @@
1
1
  module VisualizeRuby
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  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.7.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