better_rails_debugger 0.0.4 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/better_rails_debugger/group_instances_controller.rb +0 -2
- data/app/jobs/better_rails_debugger/code_analizer_job.rb +9 -0
- data/app/models/better_rails_debugger/analysis_group.rb +0 -3
- data/lib/better_rails_debugger/parser/all.rb +6 -0
- data/lib/better_rails_debugger/parser/analyzer.rb +42 -0
- data/lib/better_rails_debugger/parser/base.rb +11 -0
- data/lib/better_rails_debugger/parser/ruby/basic_extensions/context_definer.rb +281 -0
- data/lib/better_rails_debugger/parser/ruby/context_runner.rb +16 -0
- data/lib/better_rails_debugger/parser/ruby/extension.rb +50 -0
- data/lib/better_rails_debugger/parser/ruby/module_detector.rb +5 -0
- data/lib/better_rails_debugger/parser/ruby/parser.rb +26 -0
- data/lib/better_rails_debugger/parser/ruby/processor.rb +81 -0
- data/lib/better_rails_debugger/version.rb +1 -1
- data/lib/better_rails_debugger.rb +2 -1
- metadata +40 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df5a043634855d9b65b83b88acc03be073cfb332
|
4
|
+
data.tar.gz: 3faf19fa8112b878dfa0e8581cd7e55164ffd1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa232ee5c81f0a4a8c9b8f5f29f1c22c0641a89ede2c6b52bc7a7490c4efd120b9807b276dce4448c968b273192cf25cedbbfd41f478f891d9797ece3488692b
|
7
|
+
data.tar.gz: 8e3b3231772ddcf096b1bb3d6daec4cd461c055c872be21e8b5f67123ed15144a408ffdf0ed0fda9666abdc11d131c9f90bc8f8c219084cdc75699252cf8ee41
|
@@ -71,7 +71,6 @@ module BetterRailsDebugger
|
|
71
71
|
{source_line: /.*#{params[:filter]}.*/i},
|
72
72
|
{memsize: /.*#{params[:filter]}.*/i},
|
73
73
|
{class_name: /.*#{params[:filter]}.*/i})
|
74
|
-
pp @objects
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
@@ -88,7 +87,6 @@ module BetterRailsDebugger
|
|
88
87
|
{source_line: /.*#{params[:filter]}.*/i},
|
89
88
|
{memsize: /.*#{params[:filter]}.*/i},
|
90
89
|
{class_name: /.*#{params[:filter]}.*/i})
|
91
|
-
pp @objects
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
@@ -35,13 +35,10 @@ module BetterRailsDebugger
|
|
35
35
|
end
|
36
36
|
|
37
37
|
record_objects_in.to_s.split(/\n/).each do |line|
|
38
|
-
pp 'Line', line
|
39
38
|
line = line.strip
|
40
39
|
# Check if file exist
|
41
40
|
if File.exist? line
|
42
|
-
pp 'File exist'
|
43
41
|
if File.directory? line
|
44
|
-
pp 'File is a dir'
|
45
42
|
analise_paths << /#{line}.*/
|
46
43
|
elsif File.file? line
|
47
44
|
analise_paths << /#{line}$/
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require "better_rails_debugger/parser/base"
|
2
|
+
require "better_rails_debugger/parser/ruby/context_runner"
|
3
|
+
require "better_rails_debugger/parser/ruby/processor"
|
4
|
+
require "better_rails_debugger/parser/ruby/extension"
|
5
|
+
require "better_rails_debugger/parser/ruby/parser"
|
6
|
+
require "better_rails_debugger/parser/analyzer"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Include all language parsers here
|
2
|
+
module BetterRailsDebugger::Parser
|
3
|
+
class Analyzer
|
4
|
+
def initialize(path, options)
|
5
|
+
@path = path
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.analise(path, options)
|
10
|
+
self.new(path, options).run
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
# Check if file exist or not
|
15
|
+
raise ArgumentError.new "File #{@path} does not exist" if !File.exist? @path
|
16
|
+
# Detect lang by file ext
|
17
|
+
lang = get_lang_from_path
|
18
|
+
raise ArgumentError.new "Sorry, we do not support that language" if lang != 'ruby' # Only ruby by the moment
|
19
|
+
# Create lang instance with options
|
20
|
+
lang_instance = get_lang_instance lang
|
21
|
+
# parse
|
22
|
+
end
|
23
|
+
|
24
|
+
# get file ext and return language as 'ruby', 'javascript', 'php' or nil if unknown
|
25
|
+
def get_lang_from_path
|
26
|
+
case File.extname(@path).downcase
|
27
|
+
when '.rb'
|
28
|
+
'ruby'
|
29
|
+
when '.js'
|
30
|
+
'javascript'
|
31
|
+
when '.php'
|
32
|
+
'php'
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_lang_instance(lang)
|
39
|
+
"BetterRailsDebugger::#{lang.classify}::Parser".constantize.new @path, @options
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,281 @@
|
|
1
|
+
module BetterRailsDebugger::Parser::Ruby
|
2
|
+
module ProcessorExtension
|
3
|
+
def get_full_context_name(node)
|
4
|
+
if node.type.to_s == 'class'
|
5
|
+
get_full_class_name node
|
6
|
+
elsif node.type.to_s == 'module'
|
7
|
+
module_t, _ = *node
|
8
|
+
super_module, module_name = *module_t
|
9
|
+
if super_module.present?
|
10
|
+
"#{super_module.to_sexp_array[2]}::#{module_name}"
|
11
|
+
else
|
12
|
+
module_name
|
13
|
+
end
|
14
|
+
elsif node.type.to_s == 'const'
|
15
|
+
pre, name = *node
|
16
|
+
if pre.present?
|
17
|
+
"#{get_full_context_name pre}::#{name}"
|
18
|
+
else
|
19
|
+
name.to_s
|
20
|
+
end
|
21
|
+
# send are superclass
|
22
|
+
elsif node.type.to_s == 'send'
|
23
|
+
n, name, extra = *node
|
24
|
+
if extra
|
25
|
+
"#{name}::#{get_full_context_name(extra)}"
|
26
|
+
else
|
27
|
+
name.to_s
|
28
|
+
end
|
29
|
+
elsif node.type.to_s == 'sym'
|
30
|
+
name = *node
|
31
|
+
name.first.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_full_class_name(node)
|
36
|
+
klass, superclass, _ = *node
|
37
|
+
|
38
|
+
klass_name = klass.to_sexp_array[2].to_s
|
39
|
+
|
40
|
+
# Base case
|
41
|
+
return klass_name unless klass.to_sexp_array[1].present?
|
42
|
+
"#{get_full_context_name(superclass)}::#{klass_name}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def params_to_hash(node)
|
46
|
+
args = *node
|
47
|
+
args.map do |arg|
|
48
|
+
type, value = arg.type, *arg
|
49
|
+
if type == :optarg
|
50
|
+
[type, value, arg.to_sexp_array[2]]
|
51
|
+
else
|
52
|
+
[type, value]
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
Processor.include ProcessorExtension
|
59
|
+
|
60
|
+
module ContextRunnerExtension
|
61
|
+
|
62
|
+
def current_context
|
63
|
+
_context = get 'context'
|
64
|
+
if !_context
|
65
|
+
_context = Hash.new
|
66
|
+
end
|
67
|
+
_context['current'] ||= []
|
68
|
+
end
|
69
|
+
|
70
|
+
def push_context(value)
|
71
|
+
_context = get 'context'
|
72
|
+
if !_context
|
73
|
+
_context = Hash.new
|
74
|
+
end
|
75
|
+
_context['current'] ||= []
|
76
|
+
_context['current'] << value
|
77
|
+
|
78
|
+
set 'context', _context
|
79
|
+
end
|
80
|
+
|
81
|
+
def pop_context
|
82
|
+
_context = get 'context'
|
83
|
+
if !_context
|
84
|
+
_context = Hash.new
|
85
|
+
set 'context', _context
|
86
|
+
end
|
87
|
+
|
88
|
+
# get basic information
|
89
|
+
_context['current'] ||= []
|
90
|
+
_context['current'].pop
|
91
|
+
set 'context', _context
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
ContextRunner.include ContextRunnerExtension
|
96
|
+
|
97
|
+
class ContextDefiner < Extension
|
98
|
+
position 100
|
99
|
+
def setup
|
100
|
+
# Module
|
101
|
+
processor.subscribe_signal :begin_module do
|
102
|
+
full_name = processor.get_full_context_name(node)
|
103
|
+
full_name.split('::').each do |name|
|
104
|
+
push_context name
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
processor.subscribe_signal :end_module do
|
109
|
+
full_name = processor.get_full_context_name(node)
|
110
|
+
full_name.split('::').size.times do
|
111
|
+
pop_context
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# CLASS
|
116
|
+
processor.subscribe_signal :begin_class do
|
117
|
+
klass, superclass, _ = *node
|
118
|
+
|
119
|
+
full_name = processor.get_full_context_name(klass)
|
120
|
+
|
121
|
+
# get basic information
|
122
|
+
before_context = (current_context || []).join('::')
|
123
|
+
if full_name['::'].present?
|
124
|
+
complete_current_context = "#{before_context}::#{full_name}"
|
125
|
+
else
|
126
|
+
complete_current_context = full_name
|
127
|
+
end
|
128
|
+
|
129
|
+
class_info = (get complete_current_context) || HashWithIndifferentAccess.new
|
130
|
+
class_info[:type] = 'class'
|
131
|
+
class_info[:full_type] = 'class'
|
132
|
+
class_info[:location] = klass.loc
|
133
|
+
|
134
|
+
# Detect superclass
|
135
|
+
class_info[:superclass] = processor.get_full_context_name superclass
|
136
|
+
full_name.split('::').each do |name|
|
137
|
+
push_context name
|
138
|
+
end
|
139
|
+
set complete_current_context, class_info
|
140
|
+
end
|
141
|
+
|
142
|
+
processor.subscribe_signal :end_class do
|
143
|
+
full_name = processor.get_full_context_name(node)
|
144
|
+
full_name.split('::').size.times do
|
145
|
+
pop_context
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# SELF CLASS(class << self; end)
|
150
|
+
processor.subscribe_signal :begin_sclass do
|
151
|
+
# get basic information
|
152
|
+
before_context = current_context.join('::')
|
153
|
+
# set current context and information about it
|
154
|
+
push_context 'self'
|
155
|
+
if before_context.present?
|
156
|
+
complete_current_context = "#{before_context}::self"
|
157
|
+
else
|
158
|
+
complete_current_context = 'self'
|
159
|
+
end
|
160
|
+
class_info = (get complete_current_context) || HashWithIndifferentAccess.new
|
161
|
+
class_info[:type] = 'class'
|
162
|
+
class_info[:full_type] = 'sclass'
|
163
|
+
class_info[:location] = node.loc
|
164
|
+
|
165
|
+
set complete_current_context, class_info
|
166
|
+
end
|
167
|
+
|
168
|
+
processor.subscribe_signal :end_sclass do
|
169
|
+
pop_context
|
170
|
+
end
|
171
|
+
|
172
|
+
# def
|
173
|
+
processor.subscribe_signal :begin_def do
|
174
|
+
name, args, _ = *node
|
175
|
+
|
176
|
+
# Class or module method
|
177
|
+
if current_context.present?
|
178
|
+
method_context = current_context.join('::')
|
179
|
+
info = (get method_context) || HashWithIndifferentAccess.new
|
180
|
+
info[:methods] ||= HashWithIndifferentAccess.new
|
181
|
+
info[:methods][name] ||= HashWithIndifferentAccess.new
|
182
|
+
info[:methods][name][:location] = node.loc
|
183
|
+
info[:methods][name][:arguments] = processor.params_to_hash(args)
|
184
|
+
else # Global methods
|
185
|
+
method_context = "##{name}"
|
186
|
+
|
187
|
+
info = HashWithIndifferentAccess.new
|
188
|
+
info[:location] = node.loc
|
189
|
+
info[:arguments] = processor.params_to_hash(args)
|
190
|
+
|
191
|
+
set method_context, info
|
192
|
+
end
|
193
|
+
# set current context and information about it
|
194
|
+
push_context "##{name}"
|
195
|
+
end
|
196
|
+
|
197
|
+
processor.subscribe_signal :end_def do
|
198
|
+
pop_context
|
199
|
+
end
|
200
|
+
|
201
|
+
# defs (def self.method_name)
|
202
|
+
processor.subscribe_signal :begin_defs do
|
203
|
+
_, name, _, args= *node
|
204
|
+
|
205
|
+
# Class or module method
|
206
|
+
if current_context.present?
|
207
|
+
# Push the method inside self definition, this is MyClass::Self methods => []
|
208
|
+
method_context = current_context.join('::') + '::self'
|
209
|
+
info = (get method_context) || HashWithIndifferentAccess.new
|
210
|
+
info[:methods] ||= HashWithIndifferentAccess.new
|
211
|
+
info[:methods][name] ||= HashWithIndifferentAccess.new
|
212
|
+
info[:methods][name][:location] = node.loc
|
213
|
+
|
214
|
+
info[:methods][name][:arguments] = processor.params_to_hash(args)
|
215
|
+
else # Global methods
|
216
|
+
method_context = "##{name}"
|
217
|
+
|
218
|
+
info = HashWithIndifferentAccess.new
|
219
|
+
info[:location] = node.loc
|
220
|
+
info[:arguments] = processor.params_to_hash(args)
|
221
|
+
|
222
|
+
set method_context, info
|
223
|
+
end
|
224
|
+
# set current context and information about it
|
225
|
+
push_context 'self'
|
226
|
+
push_context "##{name}"
|
227
|
+
end
|
228
|
+
|
229
|
+
processor.subscribe_signal :end_defs do
|
230
|
+
pop_context # method name
|
231
|
+
pop_context # self
|
232
|
+
end
|
233
|
+
|
234
|
+
# block (like map, each lambda or any other block param)
|
235
|
+
# Context format $block#<method name, like each, map or lambda>
|
236
|
+
processor.subscribe_signal :begin_block do
|
237
|
+
method, _, _ = *node
|
238
|
+
push_context "$block##{method.to_sexp_array[2]}"
|
239
|
+
end
|
240
|
+
|
241
|
+
processor.subscribe_signal :end_block do
|
242
|
+
pop_context
|
243
|
+
end
|
244
|
+
|
245
|
+
# lambda (TODO)
|
246
|
+
processor.subscribe_signal :begin_lambda do
|
247
|
+
end
|
248
|
+
|
249
|
+
processor.subscribe_signal :end_lambda do
|
250
|
+
end
|
251
|
+
|
252
|
+
# while
|
253
|
+
processor.subscribe_signal :begin_while do
|
254
|
+
push_context '$while'
|
255
|
+
end
|
256
|
+
|
257
|
+
processor.subscribe_signal :end_while do
|
258
|
+
pop_context
|
259
|
+
end
|
260
|
+
|
261
|
+
# until
|
262
|
+
processor.subscribe_signal :begin_until do
|
263
|
+
push_context '$until'
|
264
|
+
end
|
265
|
+
|
266
|
+
processor.subscribe_signal :end_until do
|
267
|
+
pop_context
|
268
|
+
end
|
269
|
+
|
270
|
+
# for
|
271
|
+
processor.subscribe_signal :begin_for do
|
272
|
+
push_context '$for'
|
273
|
+
end
|
274
|
+
|
275
|
+
processor.subscribe_signal :end_for do
|
276
|
+
pop_context
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module BetterRailsDebugger::Parser::Ruby
|
2
|
+
class ContextRunner
|
3
|
+
attr_accessor :node, :processor
|
4
|
+
def initialize(_processor)
|
5
|
+
@processor = _processor
|
6
|
+
end
|
7
|
+
|
8
|
+
def set(key, value)
|
9
|
+
@processor.information[key] = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(key)
|
13
|
+
@processor.information[key]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module BetterRailsDebugger::Parser::Ruby
|
2
|
+
class Extension
|
3
|
+
@@classes = Hash.new(ActiveSupport::HashWithIndifferentAccess.new)
|
4
|
+
# Define the position of the extension. The position define when should be executed, if for example we have Ext1 and
|
5
|
+
# Ext2, with position 2 and 1, then Ext2 it's going to be executed before Ext1. This is useful for an extension that
|
6
|
+
# depends of another one
|
7
|
+
def self.position(position)
|
8
|
+
# TODO: Allow to set position before another extension of after that one
|
9
|
+
raise ArgumentError.new "Expected Integer or Float" unless position.kind_of? Integer or position.kind_of? Float
|
10
|
+
@@classes[self.class][:position] = position
|
11
|
+
end
|
12
|
+
|
13
|
+
# Define the name of the extension.
|
14
|
+
def self.name(extension_name)
|
15
|
+
raise ArgumentError.new "Argument must define to_s method" unless extension_name.respond_to? :to_s
|
16
|
+
@@classes[self.class][:name] = extension_name.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.config_for(klass)
|
20
|
+
@@classes[klass]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.sorted_extensions
|
24
|
+
::BetterRailsDebugger::Parser::Ruby::Extension.descendants.sort_by do |klass|
|
25
|
+
config = config_for klass
|
26
|
+
# Classes without position goes at bottom
|
27
|
+
config[:position] || Float::INFINITY
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(processor)
|
32
|
+
@processor = processor
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def run()
|
40
|
+
raise ScriptError.new "Please, define run method"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def processor
|
46
|
+
@processor
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
require_relative 'basic_extensions/context_definer'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'parser/current'
|
2
|
+
module BetterRailsDebugger::Parser::Ruby
|
3
|
+
class Parser < BetterRailsDebugger::Parser::Base
|
4
|
+
def analise
|
5
|
+
# Use some setting to select ruby version
|
6
|
+
@node_tree = ::Parser::CurrentRuby.parse(File.read(@path)).to_sexp_array
|
7
|
+
@status = ContextRunner.new
|
8
|
+
@klasses = Extension.sorted_extensions
|
9
|
+
analise_node_tree(@node_tree)
|
10
|
+
end
|
11
|
+
|
12
|
+
def analise_node_tree(tree)
|
13
|
+
add_context
|
14
|
+
tree.each do |node_item|
|
15
|
+
if node_item.kind_of? Array
|
16
|
+
analise_node_tree node_item
|
17
|
+
else
|
18
|
+
push_to_context node_item
|
19
|
+
@klasses.each do |klass|
|
20
|
+
klass.run node_item, @status
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module BetterRailsDebugger::Parser::Ruby
|
2
|
+
class Processor < ::Parser::AST::Processor
|
3
|
+
attr_reader :information
|
4
|
+
def initialize
|
5
|
+
@information = ActiveSupport::HashWithIndifferentAccess.new
|
6
|
+
end
|
7
|
+
# Call all subscriptions for the given signal
|
8
|
+
# @param signal_name Symbol
|
9
|
+
# @param args Hash
|
10
|
+
def emit_signal(signal_name, node)
|
11
|
+
@subscriptions ||= Hash.new()
|
12
|
+
@runner ||= BetterRailsDebugger::Parser::Ruby::ContextRunner.new self
|
13
|
+
(@subscriptions[signal_name] || {}).values.each do |block|
|
14
|
+
@runner.node = node
|
15
|
+
@runner.instance_eval &block
|
16
|
+
# block.call(node)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Subscribe to a particular signal
|
21
|
+
# @param signal_name Symbol
|
22
|
+
# @param block Proc
|
23
|
+
def subscribe_signal(signal_name, &block)
|
24
|
+
key = SecureRandom.hex(5)
|
25
|
+
@subscriptions ||= Hash.new()
|
26
|
+
@subscriptions[signal_name] ||= Hash.new
|
27
|
+
@subscriptions[signal_name][key] = block
|
28
|
+
key
|
29
|
+
end
|
30
|
+
|
31
|
+
def unsubscribe(signal_name, hash)
|
32
|
+
@subscriptions ||= Hash.new()
|
33
|
+
@subscriptions[signal_name] ||= Hash.new
|
34
|
+
@subscriptions[signal_name].delete hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def cleanup_subscriptions
|
38
|
+
@subscriptions = Hash.new()
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup
|
42
|
+
(@extensions = ::BetterRailsDebugger::Parser::Ruby::Extension.sorted_extensions).map do |klass|
|
43
|
+
instance = klass.new self
|
44
|
+
instance.setup
|
45
|
+
instance
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# ON Methods
|
50
|
+
#https://github.com/whitequark/parser/blob/7d72eba571b8684ff452dd9c1885ea8c43698442/lib/parser/ast/processor.rb
|
51
|
+
|
52
|
+
[:on_dstr, :on_dsym, :on_regexp, :on_xstr, :on_splat, :on_array, :on_pair, :on_hash, :on_irange, :on_erange, :on_var,
|
53
|
+
:on_lvar, :on_ivar, :on_gvar, :on_cvar, :on_back_ref, :on_nth_ref, :on_vasgn, :on_lvasgn, :on_ivasgn, :on_gvasgn,
|
54
|
+
:on_cvasgn, :on_and_asgn, :on_or_asgn, :on_op_asgn, :on_mlhs, :on_masgn, :on_const, :on_casgn, :on_args, :on_argument,
|
55
|
+
:on_arg, :on_optarg, :on_restarg, :on_blockarg, :on_shadowarg, :on_kwarg, :on_kwoptarg, :on_kwrestarg, :on_procarg0,
|
56
|
+
:on_arg_expr, :on_restarg_expr, :on_blockarg_expr, :on_block_pass, :on_undef, :on_alias, :on_send, :on_csend,
|
57
|
+
:on_index, :on_indexasgn, :on_return, :on_break, :on_next, :on_redo, :on_retry, :on_super, :on_yield, :on_defined?,
|
58
|
+
:on_not, :on_and, :on_or, :on_if, :on_when, :on_case, :on_iflipflop, :on_eflipflop, :on_match_current_line,
|
59
|
+
:on_match_with_lvasgn, :on_preexe, :on_postexe
|
60
|
+
].each do |method|
|
61
|
+
define_method method do |node|
|
62
|
+
emit_signal method.to_s.gsub('on_', '').to_sym, node
|
63
|
+
emit_signal :all, node
|
64
|
+
super node
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# signals where the node contains body, like methods, classes or modules
|
69
|
+
[:on_module, :on_class, :on_sclass, :on_def, :on_defs, :on_block, :on_lambda, :on_while, :on_while_post, :on_until,
|
70
|
+
:on_until_post, :on_for, :on_resbody, :on_rescue, :on_ensure, :on_begin, :on_kwbegin].each do |method|
|
71
|
+
define_method method do |node|
|
72
|
+
emit_signal "begin_#{method.to_s.gsub('on_', '')}".to_sym, node
|
73
|
+
emit_signal :begin_all, node
|
74
|
+
result = super node
|
75
|
+
emit_signal "end_#{method.to_s.gsub('on_', '')}".to_sym, node
|
76
|
+
emit_signal :end_all, node
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -4,10 +4,11 @@ require "haml"
|
|
4
4
|
require "will_paginate_mongoid"
|
5
5
|
require "will_paginate-bootstrap4"
|
6
6
|
require "font-awesome-rails"
|
7
|
+
require "parser/all"
|
7
8
|
|
8
9
|
require "better_rails_debugger/config"
|
9
10
|
require "better_rails_debugger/analyzer"
|
10
|
-
|
11
|
+
require "better_rails_debugger/parser/all"
|
11
12
|
Haml.init_rails(binding)
|
12
13
|
|
13
14
|
module BetterRailsDebugger
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_rails_debugger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andres Jose Borek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 5.1.5
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '6.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 5.1.5
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '6.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: haml-rails
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -37,9 +31,6 @@ dependencies:
|
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: '1.0'
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '2.0'
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +38,6 @@ dependencies:
|
|
47
38
|
- - "~>"
|
48
39
|
- !ruby/object:Gem::Version
|
49
40
|
version: '1.0'
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '2.0'
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: mongoid
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,9 +45,6 @@ dependencies:
|
|
57
45
|
- - ">="
|
58
46
|
- !ruby/object:Gem::Version
|
59
47
|
version: 7.0.0.beta
|
60
|
-
- - "<"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '8.0'
|
63
48
|
type: :runtime
|
64
49
|
prerelease: false
|
65
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -67,9 +52,6 @@ dependencies:
|
|
67
52
|
- - ">="
|
68
53
|
- !ruby/object:Gem::Version
|
69
54
|
version: 7.0.0.beta
|
70
|
-
- - "<"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '8.0'
|
73
55
|
- !ruby/object:Gem::Dependency
|
74
56
|
name: will_paginate_mongoid
|
75
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,6 +94,20 @@ dependencies:
|
|
112
94
|
- - ">="
|
113
95
|
- !ruby/object:Gem::Version
|
114
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: parser
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.5'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.5'
|
115
111
|
- !ruby/object:Gem::Dependency
|
116
112
|
name: sqlite3
|
117
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,6 +122,20 @@ dependencies:
|
|
126
122
|
- - ">="
|
127
123
|
- !ruby/object:Gem::Version
|
128
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
129
139
|
description: Better rails debugger can analyze memory issues only by the moment, but
|
130
140
|
performance is planned.
|
131
141
|
email:
|
@@ -181,6 +191,7 @@ files:
|
|
181
191
|
- app/helpers/better_rails_debugger/memory_helper.rb
|
182
192
|
- app/jobs/better_rails_debugger/analysis_recorder_job.rb
|
183
193
|
- app/jobs/better_rails_debugger/application_job.rb
|
194
|
+
- app/jobs/better_rails_debugger/code_analizer_job.rb
|
184
195
|
- app/mailers/better_rails_debugger/application_mailer.rb
|
185
196
|
- app/models/better_rails_debugger/analysis_group.rb
|
186
197
|
- app/models/better_rails_debugger/application_record.rb
|
@@ -210,6 +221,15 @@ files:
|
|
210
221
|
- lib/better_rails_debugger/analyzer.rb
|
211
222
|
- lib/better_rails_debugger/config.rb
|
212
223
|
- lib/better_rails_debugger/engine.rb
|
224
|
+
- lib/better_rails_debugger/parser/all.rb
|
225
|
+
- lib/better_rails_debugger/parser/analyzer.rb
|
226
|
+
- lib/better_rails_debugger/parser/base.rb
|
227
|
+
- lib/better_rails_debugger/parser/ruby/basic_extensions/context_definer.rb
|
228
|
+
- lib/better_rails_debugger/parser/ruby/context_runner.rb
|
229
|
+
- lib/better_rails_debugger/parser/ruby/extension.rb
|
230
|
+
- lib/better_rails_debugger/parser/ruby/module_detector.rb
|
231
|
+
- lib/better_rails_debugger/parser/ruby/parser.rb
|
232
|
+
- lib/better_rails_debugger/parser/ruby/processor.rb
|
213
233
|
- lib/better_rails_debugger/version.rb
|
214
234
|
- lib/tasks/better_rails_debugger_tasks.rake
|
215
235
|
homepage: ''
|