imagen 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/lib/imagen/node.rb +27 -0
- data/lib/imagen/version.rb +1 -1
- data/lib/imagen/visitor.rb +3 -2
- metadata +2 -3
- data/Gemfile.lock +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42aff0cf1cb4b4868720bf2d0971cc6eb02a80dc6979844758b5539a147f7455
|
4
|
+
data.tar.gz: c4ee3b3c26a3433bc5384caf93d62d1af0b77ee76379588558b33823cb67a58f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f2ab9110e69b5195954c15e945d40fd0f5c163e4db650f84958e23742897a8ff855c9748cd543dbfa775bd8c9f0d1980572df99f7c980972b0600594cfccf6
|
7
|
+
data.tar.gz: ff42e7f1b061dabcbb9099ca75aa7369b2e87c3660a00da9c7d76d869c259a4c8a24d083d2284f5c4243ecdbd7209dc566c5dddccdce17380ce52404b970512b
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/lib/imagen/node.rb
CHANGED
@@ -63,6 +63,12 @@ module Imagen
|
|
63
63
|
class Root < Base
|
64
64
|
attr_reader :dir
|
65
65
|
|
66
|
+
def build_from_file(path)
|
67
|
+
Imagen::Visitor.traverse(Parser::CurrentRuby.parse_file(path), self)
|
68
|
+
rescue Parser::SyntaxError => err
|
69
|
+
warn "#{path}: #{err} #{err.message}"
|
70
|
+
end
|
71
|
+
|
66
72
|
def build_from_dir(dir)
|
67
73
|
@dir = dir
|
68
74
|
list_files.each do |path|
|
@@ -151,5 +157,26 @@ module Imagen
|
|
151
157
|
'instance method'
|
152
158
|
end
|
153
159
|
end
|
160
|
+
|
161
|
+
# Represents a Ruby block
|
162
|
+
class Block < Base
|
163
|
+
def build_from_ast(_ast_node)
|
164
|
+
super
|
165
|
+
tap { @name = ['block', args_list].compact.join(' ') }
|
166
|
+
end
|
167
|
+
|
168
|
+
def human_name
|
169
|
+
'block'
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
|
174
|
+
def args_list
|
175
|
+
arg_nodes = ast_node.children.find { |n| n.type == :args }.children
|
176
|
+
arg_names = arg_nodes.map { |arg| arg.children[0] }
|
177
|
+
return if arg_names.empty?
|
178
|
+
"(#{arg_names.join(', ')})"
|
179
|
+
end
|
180
|
+
end
|
154
181
|
end
|
155
182
|
end
|
data/lib/imagen/version.rb
CHANGED
data/lib/imagen/visitor.rb
CHANGED
@@ -4,10 +4,11 @@ module Imagen
|
|
4
4
|
# AST Traversal that calls respective builder methods from Imagen::Node
|
5
5
|
class Visitor
|
6
6
|
TYPES = {
|
7
|
+
block: Imagen::Node::Block,
|
7
8
|
class: Imagen::Node::Class,
|
8
|
-
|
9
|
+
def: Imagen::Node::IMethod,
|
9
10
|
defs: Imagen::Node::CMethod,
|
10
|
-
|
11
|
+
module: Imagen::Node::Module
|
11
12
|
}.freeze
|
12
13
|
|
13
14
|
attr_reader :root, :current_root, :file_path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Grodowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -136,7 +136,6 @@ files:
|
|
136
136
|
- ".travis.yml"
|
137
137
|
- Dockerfile
|
138
138
|
- Gemfile
|
139
|
-
- Gemfile.lock
|
140
139
|
- LICENSE.txt
|
141
140
|
- README.md
|
142
141
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
imagen (0.1.1)
|
5
|
-
parser
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.0)
|
11
|
-
coderay (1.1.1)
|
12
|
-
diff-lcs (1.3)
|
13
|
-
docile (1.3.0)
|
14
|
-
json (2.1.0)
|
15
|
-
method_source (0.8.2)
|
16
|
-
parallel (1.12.1)
|
17
|
-
parser (2.5.1.0)
|
18
|
-
ast (~> 2.4.0)
|
19
|
-
powerpack (0.1.1)
|
20
|
-
pry (0.10.4)
|
21
|
-
coderay (~> 1.1.0)
|
22
|
-
method_source (~> 0.8.1)
|
23
|
-
slop (~> 3.4)
|
24
|
-
rainbow (3.0.0)
|
25
|
-
rake (10.5.0)
|
26
|
-
rspec (3.6.0)
|
27
|
-
rspec-core (~> 3.6.0)
|
28
|
-
rspec-expectations (~> 3.6.0)
|
29
|
-
rspec-mocks (~> 3.6.0)
|
30
|
-
rspec-core (3.6.0)
|
31
|
-
rspec-support (~> 3.6.0)
|
32
|
-
rspec-expectations (3.6.0)
|
33
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.6.0)
|
35
|
-
rspec-mocks (3.6.0)
|
36
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.6.0)
|
38
|
-
rspec-support (3.6.0)
|
39
|
-
rubocop (0.55.0)
|
40
|
-
parallel (~> 1.10)
|
41
|
-
parser (>= 2.5)
|
42
|
-
powerpack (~> 0.1)
|
43
|
-
rainbow (>= 2.2.2, < 4.0)
|
44
|
-
ruby-progressbar (~> 1.7)
|
45
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
46
|
-
ruby-progressbar (1.9.0)
|
47
|
-
simplecov (0.16.1)
|
48
|
-
docile (~> 1.1)
|
49
|
-
json (>= 1.8, < 3)
|
50
|
-
simplecov-html (~> 0.10.0)
|
51
|
-
simplecov-html (0.10.2)
|
52
|
-
simplecov-lcov (0.7.0)
|
53
|
-
slop (3.6.0)
|
54
|
-
unicode-display_width (1.3.2)
|
55
|
-
|
56
|
-
PLATFORMS
|
57
|
-
ruby
|
58
|
-
|
59
|
-
DEPENDENCIES
|
60
|
-
bundler (~> 1.16)
|
61
|
-
imagen!
|
62
|
-
pry
|
63
|
-
rake (~> 10.0)
|
64
|
-
rspec (~> 3.0)
|
65
|
-
rubocop (~> 0.55.0)
|
66
|
-
simplecov
|
67
|
-
simplecov-lcov
|
68
|
-
|
69
|
-
BUNDLED WITH
|
70
|
-
1.16.1
|