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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7dc8140161b7b57fd3dc1a901495ba36d90732d2776a52539715ee0896e2b967
4
- data.tar.gz: 61ca79f8bcb6db1b2e1cd0dad2fd66430081081206221c8e631300df44770d3f
3
+ metadata.gz: 42aff0cf1cb4b4868720bf2d0971cc6eb02a80dc6979844758b5539a147f7455
4
+ data.tar.gz: c4ee3b3c26a3433bc5384caf93d62d1af0b77ee76379588558b33823cb67a58f
5
5
  SHA512:
6
- metadata.gz: 26d7fc98735bb0c54791a8832893a75f96ee593c31d24ddf1c40791530d4ce4a18098eac1a51919b8afbce2fe5c25b18835f9e7800455c76ce367e62814baf03
7
- data.tar.gz: 11c7b12979bacdc38bb4e195d17c8e3ebe192f680ee3e958e5f9fda30048b15153c0c587330884ccf466286cfa9c7abaa4238f1d4b3a8b5a2a51c6aa5d27c300
6
+ metadata.gz: 20f2ab9110e69b5195954c15e945d40fd0f5c163e4db650f84958e23742897a8ff855c9748cd543dbfa775bd8c9f0d1980572df99f7c980972b0600594cfccf6
7
+ data.tar.gz: ff42e7f1b061dabcbb9099ca75aa7369b2e87c3660a00da9c7d76d869c259a4c8a24d083d2284f5c4243ecdbd7209dc566c5dddccdce17380ce52404b970512b
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ Gemfile.lock
1
2
  *.gem
2
3
  .ruby-version
3
4
  .ruby-gemset
data/.rubocop.yml CHANGED
@@ -12,3 +12,7 @@ Metrics/BlockLength:
12
12
  Enabled: true
13
13
  Exclude:
14
14
  - spec/**/*
15
+
16
+ Style/SpaceInsideHashLiteralBraces:
17
+ Enabled: true
18
+ EnforcedStyle: no_space
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imagen
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -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
- module: Imagen::Node::Module,
9
+ def: Imagen::Node::IMethod,
9
10
  defs: Imagen::Node::CMethod,
10
- def: Imagen::Node::IMethod
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.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-13 00:00:00.000000000 Z
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