diver_down 0.0.1.alpha8 → 0.0.1.alpha10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diver_down/trace/session.rb +4 -0
- data/lib/diver_down/trace/tracer.rb +10 -1
- data/lib/diver_down/trace.rb +1 -5
- data/lib/diver_down/version.rb +1 -1
- data/lib/diver_down/web/action.rb +38 -7
- data/lib/diver_down/web/definition_to_dot.rb +7 -6
- data/lib/diver_down/web/module_store.rb +27 -6
- data/lib/diver_down/web.rb +5 -1
- data/web/assets/bundle.js +87 -84
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45734000dad7ab44ca75037957b39dc6caae34d1189864f563ec251453972db8
|
4
|
+
data.tar.gz: bf21e0f1faeaa051f6fc4e001ff0544570994fc98d8cc75da92c8fd5f6e5d294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3060ddaba43ef6d91c01e9eb5b9ede908a61629e563d2dfef6b2775a59843cd3cd4e34c0505320ffc035e04459dc00744cf0dc58f8302de812a7b15d2b6b357c
|
7
|
+
data.tar.gz: bb258e2b3e308848e9debee4acd34930dbe375bc07ec639daeac97d24ff514f4e03a8f3b2cee8717ffb29d10b3600a97a645a9104b3481b4153c2f8ab0ce7ad9
|
@@ -3,9 +3,18 @@
|
|
3
3
|
module DiverDown
|
4
4
|
module Trace
|
5
5
|
class Tracer
|
6
|
+
DEFAULT_TRACE_EVENTS = %i[
|
7
|
+
call
|
8
|
+
return
|
9
|
+
c_call
|
10
|
+
c_return
|
11
|
+
b_call
|
12
|
+
b_return
|
13
|
+
].freeze
|
14
|
+
|
6
15
|
# @return [Array<Symbol>]
|
7
16
|
def self.trace_events
|
8
|
-
@trace_events ||
|
17
|
+
@trace_events || DEFAULT_TRACE_EVENTS
|
9
18
|
end
|
10
19
|
|
11
20
|
# @param events [Array<Symbol>]
|
data/lib/diver_down/trace.rb
CHANGED
@@ -11,16 +11,12 @@ module DiverDown
|
|
11
11
|
require 'diver_down/trace/redefine_ruby_methods'
|
12
12
|
require 'diver_down/trace/ignored_method_ids'
|
13
13
|
|
14
|
-
@trace_events = %i[
|
15
|
-
call c_call return c_return
|
16
|
-
]
|
17
|
-
|
18
14
|
# Trace only Ruby-implemented methods because tracing C-implemented methods is very slow
|
19
15
|
# Override Ruby only with the minimal set of methods needed to trace dependencies.
|
20
16
|
#
|
21
17
|
# @return [void]
|
22
18
|
def self.trace_only_ruby_world!(map = DiverDown::Trace::RedefineRubyMethods::DEFAULT_METHODS)
|
23
|
-
DiverDown::Trace::Tracer.trace_events = %i[
|
19
|
+
DiverDown::Trace::Tracer.trace_events = DiverDown::Trace::Tracer::DEFAULT_TRACE_EVENTS - %i[c_call c_return]
|
24
20
|
DiverDown::Trace::RedefineRubyMethods.redefine_c_methods(map)
|
25
21
|
end
|
26
22
|
end
|
data/lib/diver_down/version.rb
CHANGED
@@ -33,12 +33,19 @@ module DiverDown
|
|
33
33
|
end
|
34
34
|
# rubocop:enable Style/HashEachMethods
|
35
35
|
|
36
|
+
classified_sources_count = source_names.count { @module_store.classified?(_1) }
|
37
|
+
|
36
38
|
json(
|
37
39
|
sources: source_names.sort.map do |source_name|
|
38
40
|
{
|
39
41
|
source_name:,
|
42
|
+
memo: @module_store.get_memo(source_name),
|
43
|
+
modules: @module_store.get_modules(source_name).map do |module_name|
|
44
|
+
{ module_name: }
|
45
|
+
end,
|
40
46
|
}
|
41
|
-
end
|
47
|
+
end,
|
48
|
+
classified_sources_count:
|
42
49
|
)
|
43
50
|
end
|
44
51
|
|
@@ -50,7 +57,7 @@ module DiverDown
|
|
50
57
|
# rubocop:disable Style/HashEachMethods
|
51
58
|
@store.each do |_, definition|
|
52
59
|
definition.sources.each do |source|
|
53
|
-
modules = @module_store.
|
60
|
+
modules = @module_store.get_modules(source.source_name)
|
54
61
|
module_set.add(modules) unless modules.empty?
|
55
62
|
end
|
56
63
|
end
|
@@ -77,7 +84,7 @@ module DiverDown
|
|
77
84
|
# rubocop:disable Style/HashEachMethods
|
78
85
|
@store.each do |_, definition|
|
79
86
|
definition.sources.each do |source|
|
80
|
-
source_module_names = @module_store.
|
87
|
+
source_module_names = @module_store.get_modules(source.source_name)
|
81
88
|
|
82
89
|
next unless source_module_names[0..module_names.size - 1] == module_names
|
83
90
|
|
@@ -102,6 +109,7 @@ module DiverDown
|
|
102
109
|
sources: source_names.sort.map do |source_name|
|
103
110
|
{
|
104
111
|
source_name:,
|
112
|
+
memo: @module_store.get_memo(source_name),
|
105
113
|
}
|
106
114
|
end,
|
107
115
|
related_definitions: related_definitions.map do |definition|
|
@@ -131,7 +139,7 @@ module DiverDown
|
|
131
139
|
definition_group: definition.definition_group,
|
132
140
|
title: definition.title,
|
133
141
|
sources_count: definition.sources.size,
|
134
|
-
unclassified_sources_count: definition.sources.reject { @module_store.
|
142
|
+
unclassified_sources_count: definition.sources.reject { @module_store.classified?(_1.source_name) }.size,
|
135
143
|
}
|
136
144
|
end,
|
137
145
|
pagination: pagination.to_h
|
@@ -189,7 +197,8 @@ module DiverDown
|
|
189
197
|
sources: definition.sources.map do
|
190
198
|
{
|
191
199
|
source_name: _1.source_name,
|
192
|
-
|
200
|
+
memo: @module_store.get_memo(_1.source_name),
|
201
|
+
modules: @module_store.get_modules(_1.source_name).map do |module_name|
|
193
202
|
{ module_name: }
|
194
203
|
end,
|
195
204
|
}
|
@@ -240,11 +249,12 @@ module DiverDown
|
|
240
249
|
[]
|
241
250
|
else
|
242
251
|
source = DiverDown::Definition::Source.combine(*found_sources)
|
243
|
-
@module_store.
|
252
|
+
@module_store.get_modules(source.source_name)
|
244
253
|
end
|
245
254
|
|
246
255
|
json(
|
247
256
|
source_name:,
|
257
|
+
memo: @module_store.get_memo(source_name),
|
248
258
|
modules: module_names.map do
|
249
259
|
{ module_name: _1 }
|
250
260
|
end,
|
@@ -281,7 +291,28 @@ module DiverDown
|
|
281
291
|
end
|
282
292
|
|
283
293
|
if found_source
|
284
|
-
@module_store.
|
294
|
+
@module_store.set_modules(source_name, modules)
|
295
|
+
@module_store.flush
|
296
|
+
|
297
|
+
json({})
|
298
|
+
else
|
299
|
+
not_found
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
# POST /api/sources/:source_name/memo.json
|
304
|
+
#
|
305
|
+
# @param source_name [String]
|
306
|
+
# @param memo [String]
|
307
|
+
def set_memo(source_name, memo)
|
308
|
+
found_source = @store.any? do |_, definition|
|
309
|
+
definition.sources.any? do |source|
|
310
|
+
source.source_name == source_name
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
if found_source
|
315
|
+
@module_store.set_memo(source_name, memo)
|
285
316
|
@module_store.flush
|
286
317
|
|
287
318
|
json({})
|
@@ -31,7 +31,7 @@ module DiverDown
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def source_to_h
|
34
|
-
modules = module_store.
|
34
|
+
modules = module_store.get_modules(data.source_name).map do
|
35
35
|
{
|
36
36
|
module_name: _1,
|
37
37
|
}
|
@@ -41,6 +41,7 @@ module DiverDown
|
|
41
41
|
id:,
|
42
42
|
type: 'source',
|
43
43
|
source_name: data.source_name,
|
44
|
+
memo: module_store.get_memo(data.source_name),
|
44
45
|
modules:,
|
45
46
|
}
|
46
47
|
end
|
@@ -185,11 +186,11 @@ module DiverDown
|
|
185
186
|
dependency_map = Hash.new { |h, k| h[k] = Hash.new { |hi, ki| hi[ki] = [] } }
|
186
187
|
|
187
188
|
definition.sources.sort_by(&:source_name).each do |source|
|
188
|
-
source_modules = module_store.
|
189
|
+
source_modules = module_store.get_modules(source.source_name)
|
189
190
|
next if source_modules.empty?
|
190
191
|
|
191
192
|
source.dependencies.each do |dependency|
|
192
|
-
dependency_modules = module_store.
|
193
|
+
dependency_modules = module_store.get_modules(dependency.source_name)
|
193
194
|
next if dependency_modules.empty?
|
194
195
|
|
195
196
|
dependency_map[source_modules][dependency_modules].push(dependency)
|
@@ -268,7 +269,7 @@ module DiverDown
|
|
268
269
|
|
269
270
|
def render_sources
|
270
271
|
by_modules = definition.sources.group_by do |source|
|
271
|
-
module_store.
|
272
|
+
module_store.get_modules(source.source_name)
|
272
273
|
end
|
273
274
|
|
274
275
|
# Remove duplicated prefix modules
|
@@ -326,8 +327,8 @@ module DiverDown
|
|
326
327
|
def insert_dependencies(source)
|
327
328
|
source.dependencies.each do
|
328
329
|
attributes = {}
|
329
|
-
ltail = module_label(*module_store.
|
330
|
-
lhead = module_label(*module_store.
|
330
|
+
ltail = module_label(*module_store.get_modules(source.source_name))
|
331
|
+
lhead = module_label(*module_store.get_modules(_1.source_name))
|
331
332
|
|
332
333
|
if @compound && (ltail || lhead)
|
333
334
|
# Rendering of dependencies between modules is done only once
|
@@ -6,6 +6,7 @@ module DiverDown
|
|
6
6
|
class Web
|
7
7
|
class ModuleStore
|
8
8
|
BLANK_ARRAY = [].freeze
|
9
|
+
BLANK_MEMO = ''
|
9
10
|
BLANK_RE = /\A\s*\z/
|
10
11
|
|
11
12
|
private_constant(:BLANK_RE)
|
@@ -17,22 +18,42 @@ module DiverDown
|
|
17
18
|
|
18
19
|
# @param source_name [String]
|
19
20
|
# @param module_names [Array<String>]
|
20
|
-
def
|
21
|
-
@store[source_name]
|
21
|
+
def set_modules(source_name, module_names)
|
22
|
+
source = (@store[source_name] ||= {})
|
23
|
+
|
24
|
+
source[:modules] = module_names.dup.reject do
|
22
25
|
BLANK_RE.match?(_1)
|
23
26
|
end.freeze
|
24
27
|
end
|
25
28
|
|
26
29
|
# @param source_name [String]
|
27
30
|
# @return [Array<Module>]
|
28
|
-
def
|
29
|
-
@store
|
31
|
+
def get_modules(source_name)
|
32
|
+
return BLANK_ARRAY unless @store.key?(source_name)
|
33
|
+
|
34
|
+
@store[source_name][:modules] || BLANK_ARRAY
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param source_name [String]
|
38
|
+
# @param memo [String]
|
39
|
+
# @return [void]
|
40
|
+
def set_memo(source_name, memo)
|
41
|
+
source = (@store[source_name] ||= {})
|
42
|
+
source[:memo] = memo.strip
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param source_name [String]
|
46
|
+
# @return [String]
|
47
|
+
def get_memo(source_name)
|
48
|
+
return BLANK_MEMO unless @store.key?(source_name)
|
49
|
+
|
50
|
+
@store[source_name][:memo] || BLANK_MEMO
|
30
51
|
end
|
31
52
|
|
32
53
|
# @param source_name [String]
|
33
54
|
# @return [Boolean]
|
34
|
-
def
|
35
|
-
|
55
|
+
def classified?(source_name)
|
56
|
+
get_modules(source_name).any?
|
36
57
|
end
|
37
58
|
|
38
59
|
# @return [Hash]
|
data/lib/diver_down/web.rb
CHANGED
@@ -53,7 +53,7 @@ module DiverDown
|
|
53
53
|
in ['GET', %r{\A/api/modules\.json\z}]
|
54
54
|
action.modules
|
55
55
|
in ['GET', %r{\A/api/modules/(?<module_names>.+)\.json\z}]
|
56
|
-
module_names = Regexp.last_match[:module_names].split('/')
|
56
|
+
module_names = CGI.unescape(Regexp.last_match[:module_names]).split('/')
|
57
57
|
action.module(module_names)
|
58
58
|
in ['GET', %r{\A/api/definitions/(?<bit_id>\d+)\.json\z}]
|
59
59
|
bit_id = Regexp.last_match[:bit_id].to_i
|
@@ -68,6 +68,10 @@ module DiverDown
|
|
68
68
|
source = Regexp.last_match[:source]
|
69
69
|
modules = request.params['modules'] || []
|
70
70
|
action.set_modules(source, modules)
|
71
|
+
in ['POST', %r{\A/api/sources/(?<source>[^/]+)/memo.json\z}]
|
72
|
+
source = Regexp.last_match[:source]
|
73
|
+
memo = request.params['memo'] || ''
|
74
|
+
action.set_memo(source, memo)
|
71
75
|
in ['GET', %r{\A/api/pid\.json\z}]
|
72
76
|
action.pid
|
73
77
|
in ['GET', %r{\A/api/initialization_status\.json\z}]
|