ruby_ast_visualizer 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/README.md +6 -6
- data/bin/ruby_ast_visualizer +7 -2
- data/lib/ruby_ast_visualizer.rb +5 -10
- data/lib/ruby_ast_visualizer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1696695ee0506076fd3cc5ef7135c80194b19162
|
4
|
+
data.tar.gz: ac777855cc5d0ff1571c7c48839462bb382aeec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ddc501e00200655cbe90c9a7db85bc3982f3b33a4504d655a39bf5370c46900d03866445bb7b379575fd3fd543d2f51e7b56ae83f5f9c25083a2d6200aa3cc
|
7
|
+
data.tar.gz: d53e2d540287c2c30b15230eede0b3758d9ca943578b3ca569975ce4b620f37ceeceb72c62cb7f4123e7de6cd2f2bb9c6c28b9259920534157a089f438022034
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Ruby AST Visualizer. Based on [Parser](https://github.com/whitequark/parser).
|
|
6
6
|
|
7
7
|
An example `ruby_ast_visualizer` command.
|
8
8
|
|
9
|
-
```
|
9
|
+
```sh
|
10
10
|
$ cat hello.rb
|
11
11
|
puts 'hello, world'
|
12
12
|
$ ruby_ast_visualizer hello.rb
|
@@ -14,7 +14,7 @@ $ ruby_ast_visualizer hello.rb
|
|
14
14
|
|
15
15
|
or
|
16
16
|
|
17
|
-
```
|
17
|
+
```sh
|
18
18
|
$ ruby_ast_visualizer -e 'puts "hello, world"'
|
19
19
|
```
|
20
20
|
|
@@ -26,7 +26,7 @@ AST image file is generated.
|
|
26
26
|
|
27
27
|
You can specify output path in the `-o` option. That value is default a.png.
|
28
28
|
|
29
|
-
```
|
29
|
+
```sh
|
30
30
|
$ ruby_ast_visualizer -o path/to/file -e 'puts "hello, world"'
|
31
31
|
```
|
32
32
|
|
@@ -38,19 +38,19 @@ $ ruby_ast_visualizer -o path/to/file -e 'puts "hello, world"'
|
|
38
38
|
|
39
39
|
Add these lines to your application's Gemfile:
|
40
40
|
|
41
|
-
```
|
41
|
+
```sh
|
42
42
|
gem 'ruby_ast_visualizer'
|
43
43
|
```
|
44
44
|
|
45
45
|
And then execute:
|
46
46
|
|
47
|
-
```
|
47
|
+
```sh
|
48
48
|
$ bundle
|
49
49
|
```
|
50
50
|
|
51
51
|
Or install it yourself as:
|
52
52
|
|
53
|
-
```
|
53
|
+
```sh
|
54
54
|
$ gem install ruby_ast_visualizer
|
55
55
|
```
|
56
56
|
|
data/bin/ruby_ast_visualizer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# USAGE:
|
4
4
|
#
|
5
|
-
# ruby_ast_visualizer [-o path/to/file] 'array.sort { |a, b| a.to_s <=> b.to_s }'
|
5
|
+
# ruby_ast_visualizer [-o path/to/file] -e 'array.sort { |a, b| a.to_s <=> b.to_s }'
|
6
6
|
#
|
7
7
|
lib_path = File.expand_path('../../lib', __FILE__)
|
8
8
|
$:.unshift(lib_path)
|
@@ -10,6 +10,7 @@ $:.unshift(lib_path)
|
|
10
10
|
require 'ruby_ast_visualizer'
|
11
11
|
require 'ruby_ast_visualizer/version'
|
12
12
|
require 'optparse'
|
13
|
+
require 'parser/current'
|
13
14
|
|
14
15
|
Version = RubyAstVisualizer::VERSION
|
15
16
|
|
@@ -33,7 +34,11 @@ begin
|
|
33
34
|
|
34
35
|
file_name = options[:output] || 'a.png'
|
35
36
|
|
36
|
-
|
37
|
+
ast = Parser::CurrentRuby.parse(source)
|
38
|
+
|
39
|
+
puts "\n#{ast}\n\n"
|
40
|
+
|
41
|
+
result = RubyAstVisualizer::Core.new(ast).visualize
|
37
42
|
|
38
43
|
result.output(png: file_name)
|
39
44
|
|
data/lib/ruby_ast_visualizer.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
require 'graphviz'
|
2
|
-
require 'parser/current'
|
3
2
|
|
4
3
|
module RubyAstVisualizer
|
5
4
|
class Core
|
6
|
-
def initialize(
|
5
|
+
def initialize(ast)
|
7
6
|
@node_id = 0
|
8
|
-
@
|
7
|
+
@ast = ast
|
9
8
|
end
|
10
9
|
|
11
10
|
def visualize
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
reconfigure(g, node)
|
17
|
-
|
18
|
-
g
|
11
|
+
GraphViz.new(:G, type: :digraph) {|g|
|
12
|
+
reconfigure(g, @ast)
|
13
|
+
}
|
19
14
|
end
|
20
15
|
|
21
16
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_ast_visualizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi ITO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.5.
|
74
|
+
rubygems_version: 2.5.2
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Ruby AST Visualizer.
|