diver_down 0.0.1.alpha16 → 0.0.1.alpha17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/diver_down_web +1 -0
- data/lib/diver_down/trace/ignored_method_ids.rb +21 -18
- data/lib/diver_down/trace/session.rb +9 -4
- data/lib/diver_down/trace/tracer.rb +1 -1
- data/lib/diver_down/version.rb +1 -1
- data/lib/diver_down/web/action.rb +17 -3
- data/lib/diver_down/web/metadata.rb +8 -14
- data/lib/diver_down/web.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2f7ed8cc7afd42927d7456860430b3349c9a597925bfbf50a8510da47051dc
|
4
|
+
data.tar.gz: 6f204f7954c88becbedf9a04983a4be8b195ac4ef45d2e7dc8ec50f5d80094de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7653069f6d81577ce96f4b4488d194e625562056f98dbf366b87700fa50eb1444ae0eea53ef6307c9879a326e0962c6bb1f654bdf1220d9983166422a092a0a0
|
7
|
+
data.tar.gz: 6449971ce4909626c376a1f36efc233b3995f05f6d3bed73dab792791fc645be56e02425578b3bd3e7d29c66b1b4b702609af7de46ada16bcea6a262e27e0cc3
|
data/exe/diver_down_web
CHANGED
@@ -3,34 +3,41 @@
|
|
3
3
|
module DiverDown
|
4
4
|
module Trace
|
5
5
|
class IgnoredMethodIds
|
6
|
+
VALID_VALUE = %i[
|
7
|
+
single
|
8
|
+
all
|
9
|
+
].freeze
|
10
|
+
|
6
11
|
def initialize(ignored_methods)
|
7
12
|
# Ignore all methods in the module
|
8
|
-
# Hash{ Module =>
|
13
|
+
# Hash{ Module => Symbol }
|
9
14
|
@ignored_modules = {}
|
10
15
|
|
11
16
|
# Ignore all methods in the class
|
12
|
-
# Hash{ Module => Hash{ Symbol =>
|
17
|
+
# Hash{ Module => Hash{ Symbol => Symbol } }
|
13
18
|
@ignored_class_method_id = Hash.new { |h, k| h[k] = {} }
|
14
19
|
|
15
20
|
# Ignore all methods in the instance
|
16
|
-
# Hash{ Module => Hash{ Symbol =>
|
21
|
+
# Hash{ Module => Hash{ Symbol => Symbol } }
|
17
22
|
@ignored_instance_method_id = Hash.new { |h, k| h[k] = {} }
|
18
23
|
|
19
|
-
ignored_methods.each do |ignored_method|
|
24
|
+
ignored_methods.each do |ignored_method, value|
|
25
|
+
raise ArgumentError, "Invalid value: #{value}. valid values are #{VALID_VALUE}" unless VALID_VALUE.include?(value)
|
26
|
+
|
20
27
|
if ignored_method.include?('.')
|
21
28
|
# instance method
|
22
29
|
class_name, method_id = ignored_method.split('.')
|
23
30
|
mod = DiverDown::Helper.constantize(class_name)
|
24
|
-
@ignored_class_method_id[mod][method_id.to_sym] =
|
31
|
+
@ignored_class_method_id[mod][method_id.to_sym] = value
|
25
32
|
elsif ignored_method.include?('#')
|
26
33
|
# class method
|
27
34
|
class_name, method_id = ignored_method.split('#')
|
28
35
|
mod = DiverDown::Helper.constantize(class_name)
|
29
|
-
@ignored_instance_method_id[mod][method_id.to_sym] =
|
36
|
+
@ignored_instance_method_id[mod][method_id.to_sym] = value
|
30
37
|
else
|
31
38
|
# module
|
32
39
|
mod = DiverDown::Helper.constantize(ignored_method)
|
33
|
-
@ignored_modules[mod] =
|
40
|
+
@ignored_modules[mod] = value
|
34
41
|
end
|
35
42
|
end
|
36
43
|
end
|
@@ -38,14 +45,14 @@ module DiverDown
|
|
38
45
|
# @param mod [Module]
|
39
46
|
# @param is_class [Boolean] class is true, instance is false
|
40
47
|
# @param method_id [Symbol]
|
41
|
-
# @return [
|
42
|
-
def ignored
|
43
|
-
ignored_module
|
48
|
+
# @return [Symbol, false] VALID_VALUE
|
49
|
+
def ignored(mod, is_class, method_id)
|
50
|
+
ignored_module(mod) || ignored_method(mod, is_class, method_id)
|
44
51
|
end
|
45
52
|
|
46
53
|
private
|
47
54
|
|
48
|
-
def ignored_module
|
55
|
+
def ignored_module(mod)
|
49
56
|
unless @ignored_modules.key?(mod)
|
50
57
|
dig_superclass(mod)
|
51
58
|
end
|
@@ -53,7 +60,7 @@ module DiverDown
|
|
53
60
|
@ignored_modules.fetch(mod)
|
54
61
|
end
|
55
62
|
|
56
|
-
def ignored_method
|
63
|
+
def ignored_method(mod, is_class, method_id)
|
57
64
|
store = if is_class
|
58
65
|
# class methods
|
59
66
|
@ignored_class_method_id
|
@@ -96,10 +103,8 @@ module DiverDown
|
|
96
103
|
end
|
97
104
|
|
98
105
|
# Convert nil to boolean
|
99
|
-
ignored = !!ignored
|
100
|
-
|
101
106
|
stack.each do
|
102
|
-
@ignored_modules[_1] = ignored
|
107
|
+
@ignored_modules[_1] = ignored || false
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
@@ -125,10 +130,8 @@ module DiverDown
|
|
125
130
|
end
|
126
131
|
|
127
132
|
# Convert nil to boolean
|
128
|
-
ignored = !!ignored
|
129
|
-
|
130
133
|
stack.each do
|
131
|
-
store[_1][method_id] = ignored
|
134
|
+
store[_1][method_id] = ignored || false
|
132
135
|
end
|
133
136
|
end
|
134
137
|
end
|
@@ -38,13 +38,15 @@ module DiverDown
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def build_trace_point
|
41
|
-
|
41
|
+
call_stacks = {}
|
42
42
|
|
43
43
|
TracePoint.new(*DiverDown::Trace::Tracer.trace_events) do |tp|
|
44
44
|
# Skip the trace of the library itself
|
45
45
|
next if tp.path&.start_with?(DiverDown::LIB_DIR)
|
46
46
|
next if TracePoint == tp.defined_class
|
47
47
|
|
48
|
+
call_stack = call_stacks[Thread.current] ||= DiverDown::Trace::CallStack.new
|
49
|
+
|
48
50
|
case tp.event
|
49
51
|
when :b_call
|
50
52
|
call_stack.push
|
@@ -64,9 +66,12 @@ module DiverDown
|
|
64
66
|
next
|
65
67
|
end
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
ignored = @ignored_method_ids.ignored(mod, DiverDown::Helper.module?(tp.self), tp.method_id) if @ignored_method_ids
|
70
|
+
|
71
|
+
if ignored
|
72
|
+
# If ignored is :all, the call stack is ignored until the method returns.
|
73
|
+
# If ignored is :single, the call stack is ignored only current call.
|
74
|
+
call_stack.push(ignored: ignored == :all)
|
70
75
|
next
|
71
76
|
end
|
72
77
|
|
@@ -24,7 +24,7 @@ module DiverDown
|
|
24
24
|
|
25
25
|
# @param module_set [DiverDown::Trace::ModuleSet, Array<Module, String>]
|
26
26
|
# @param caller_paths [Array<String>, nil] if nil, trace all files
|
27
|
-
# @param ignored_method_ids [
|
27
|
+
# @param ignored_method_ids [Hash{ String => Symbol }, nil]
|
28
28
|
# @param filter_method_id_path [#call, nil] filter method_id.path
|
29
29
|
# @param module_set [DiverDown::Trace::ModuleSet, nil] for optimization
|
30
30
|
def initialize(module_set: {}, caller_paths: nil, ignored_method_ids: nil, filter_method_id_path: nil)
|
data/lib/diver_down/version.rb
CHANGED
@@ -21,9 +21,8 @@ module DiverDown
|
|
21
21
|
def initialize(store:, metadata:)
|
22
22
|
@store = store
|
23
23
|
@metadata = metadata
|
24
|
-
|
25
|
-
|
26
|
-
@module_dependency_map_cache_id = nil
|
24
|
+
|
25
|
+
reload
|
27
26
|
end
|
28
27
|
|
29
28
|
# GET /api/source_aliases.json
|
@@ -327,6 +326,7 @@ module DiverDown
|
|
327
326
|
if found_source
|
328
327
|
@metadata.source(source_name).module = modulee
|
329
328
|
@metadata.flush
|
329
|
+
reload
|
330
330
|
|
331
331
|
json({})
|
332
332
|
else
|
@@ -348,6 +348,7 @@ module DiverDown
|
|
348
348
|
if found_source
|
349
349
|
@metadata.source(source_name).memo = memo
|
350
350
|
@metadata.flush
|
351
|
+
reload
|
351
352
|
|
352
353
|
json({})
|
353
354
|
else
|
@@ -355,6 +356,13 @@ module DiverDown
|
|
355
356
|
end
|
356
357
|
end
|
357
358
|
|
359
|
+
# @return [Array[Integer, Hash, Array]]
|
360
|
+
def reload_cache
|
361
|
+
@metadata.reload
|
362
|
+
reload
|
363
|
+
json({})
|
364
|
+
end
|
365
|
+
|
358
366
|
# @return [Array[Integer, Hash, Array]]
|
359
367
|
def not_found
|
360
368
|
[404, { 'content-type' => 'text/plain' }, ['not found']]
|
@@ -445,6 +453,12 @@ module DiverDown
|
|
445
453
|
|
446
454
|
@module_dependency_map
|
447
455
|
end
|
456
|
+
|
457
|
+
def reload
|
458
|
+
@source_alias_resolver = DiverDown::Web::SourceAliasResolver.new(@metadata.source_alias)
|
459
|
+
@module_dependency_map = nil
|
460
|
+
@module_dependency_map_cache_id = nil
|
461
|
+
end
|
448
462
|
end
|
449
463
|
end
|
450
464
|
end
|
@@ -6,12 +6,12 @@ module DiverDown
|
|
6
6
|
require 'diver_down/web/metadata/source_metadata'
|
7
7
|
require 'diver_down/web/metadata/source_alias'
|
8
8
|
|
9
|
-
attr_reader :source_alias
|
9
|
+
attr_reader :path, :source_alias
|
10
10
|
|
11
11
|
# @param path [String]
|
12
12
|
def initialize(path)
|
13
13
|
@path = path
|
14
|
-
|
14
|
+
reload
|
15
15
|
end
|
16
16
|
|
17
17
|
# @param source_name [String]
|
@@ -41,25 +41,19 @@ module DiverDown
|
|
41
41
|
File.write(@path, to_h.to_yaml)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
def
|
44
|
+
# Reload metadata from file
|
45
|
+
# @return [void]
|
46
|
+
def reload
|
47
47
|
@source_map = Hash.new { |h, source_name| h[source_name] = DiverDown::Web::Metadata::SourceMetadata.new }
|
48
48
|
@source_alias = DiverDown::Web::Metadata::SourceAlias.new
|
49
49
|
|
50
|
-
loaded = YAML.load_file(@path)
|
50
|
+
loaded = YAML.load_file(@path) if File.exist?(@path)
|
51
51
|
|
52
52
|
return if loaded.nil?
|
53
53
|
|
54
|
-
|
55
|
-
(loaded[:sources] || loaded || []).each do |source_name, source_hash|
|
54
|
+
loaded[:sources]&.each do |source_name, source_hash|
|
56
55
|
source(source_name).memo = source_hash[:memo] if source_hash[:memo]
|
57
|
-
|
58
|
-
if source_hash[:modules].is_a?(Array)
|
59
|
-
source(source_name).module = source_hash[:modules][0]
|
60
|
-
elsif source_hash[:module]
|
61
|
-
source(source_name).module = source_hash[:module]
|
62
|
-
end
|
56
|
+
source(source_name).module = source_hash[:module] if source_hash[:module]
|
63
57
|
end
|
64
58
|
|
65
59
|
loaded[:source_alias]&.each do |alias_name, source_names|
|
data/lib/diver_down/web.rb
CHANGED
@@ -78,6 +78,8 @@ module DiverDown
|
|
78
78
|
in ['GET', %r{\A/api/sources/(?<source>[^/]+)\.json\z}]
|
79
79
|
source = Regexp.last_match[:source]
|
80
80
|
@action.source(source)
|
81
|
+
in ['GET', %r{\A/api/reload\.json\z}]
|
82
|
+
@action.reload_cache
|
81
83
|
in ['POST', %r{\A/api/sources/(?<source>[^/]+)/module.json\z}]
|
82
84
|
source = Regexp.last_match[:source]
|
83
85
|
modulee = request.params['module'] || ''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diver_down
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.alpha17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alpaca-tc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.5.
|
112
|
+
rubygems_version: 3.5.18
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: dynamically analyze application dependencies and generate a comprehensive
|