objenealogist 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/objenealogist/version.rb +1 -1
- data/lib/objenealogist.rb +29 -33
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 951cc96c6057b240c86ebcaba995b6635945e80a6a124bdbf6b0aadeb44832fa
|
|
4
|
+
data.tar.gz: c4401fde554422a401cbd2f28c64748f2453c06a120585914fa6fc895add4dad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 596794eddd578b8f476b4eb18a173d2da6b12a6db44cde8feb03fc55468811ac99b0c96b6503ebc0b91f7d57e7792ed5223f43afefead7a9370970f8b708d53b
|
|
7
|
+
data.tar.gz: ba3ee209ea35ad5644f0ec2ba0591b8ecd54a04cea0daab6383e5b1ab56218249bf074500f226c417fbe150f0708403213f3573cb248a68eac9fdf7cb0345901
|
data/lib/objenealogist.rb
CHANGED
|
@@ -36,30 +36,35 @@ class Objenealogist
|
|
|
36
36
|
locations = location_map[clazz.to_s.to_sym]
|
|
37
37
|
|
|
38
38
|
result << "#{indent}C #{clazz}#{format_locations(locations, show_locations:, target: clazz.to_s)}" if indent == ""
|
|
39
|
-
if
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
m, path, line = method
|
|
44
|
-
mark = locations[:methods].size - 1 == index ? "└" : "├"
|
|
45
|
-
result << "#{indent}│ #{mark} #{m}#{format_locations("#{path}:#{line}", show_locations:, target: clazz.to_s)}"
|
|
39
|
+
if show_methods
|
|
40
|
+
methods = class << clazz; public_instance_methods(false).map { |m| instance_method(m) }; end
|
|
41
|
+
methods += clazz.public_instance_methods(false).map do |m|
|
|
42
|
+
clazz.instance_method(m)
|
|
46
43
|
end
|
|
47
|
-
|
|
44
|
+
methods.compact.sort { |a, b| a.name <=> b.name }.each_with_index do |method, index|
|
|
45
|
+
path, line = method.source_location
|
|
46
|
+
mark = methods.size - 1 == index ? "└" : "├"
|
|
47
|
+
result << "#{indent}│ #{mark} #{method.name}#{format_locations("#{path}:#{line}", show_locations:,
|
|
48
|
+
target: clazz.to_s)}"
|
|
49
|
+
end
|
|
50
|
+
result << "#{indent}│" if methods.any?
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
(clazz.included_modules - (clazz.superclass&.included_modules || [])).each do |mod|
|
|
51
54
|
locations = location_map[mod.to_s.to_sym]
|
|
52
55
|
result << "#{indent}├── M #{mod}#{format_locations(locations, show_locations:, target: mod.to_s)}"
|
|
53
|
-
if
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
if show_methods && mod != ::Kernel # rubocop:disable Style/Next
|
|
57
|
+
methods = class << mod; public_instance_methods(false).map { |m| instance_method(m) }; end
|
|
58
|
+
methods += mod.public_instance_methods(false).map do |m|
|
|
59
|
+
clazz.instance_method(m)
|
|
60
|
+
end
|
|
61
|
+
methods.compact.sort { |a, b| a.name <=> b.name }.each_with_index do |method, index|
|
|
62
|
+
path, line = method.source_location
|
|
63
|
+
mark = methods.size - 1 == index ? "└" : "├"
|
|
64
|
+
result << "#{indent}│ #{mark} #{method.name}#{format_locations("#{path}:#{line}", show_locations:,
|
|
65
|
+
target: mod.to_s)}"
|
|
61
66
|
end
|
|
62
|
-
result << "#{indent}
|
|
67
|
+
result << "#{indent}│" if methods.any?
|
|
63
68
|
end
|
|
64
69
|
end
|
|
65
70
|
|
|
@@ -67,7 +72,11 @@ class Objenealogist
|
|
|
67
72
|
locations = location_map[clazz.superclass.to_s.to_sym]
|
|
68
73
|
result << "#{indent}└── C #{clazz.superclass}#{format_locations(locations, show_locations:,
|
|
69
74
|
target: clazz.superclass.to_s)}"
|
|
70
|
-
|
|
75
|
+
if clazz.superclass != ::BasicObject
|
|
76
|
+
process_one(clazz.superclass, result, location_map, " #{indent}", show_methods:, show_locations:)
|
|
77
|
+
else
|
|
78
|
+
result
|
|
79
|
+
end
|
|
71
80
|
else
|
|
72
81
|
result
|
|
73
82
|
end
|
|
@@ -78,7 +87,7 @@ class Objenealogist
|
|
|
78
87
|
return "" if show_locations.is_a?(Regexp) && show_locations !~ target
|
|
79
88
|
|
|
80
89
|
if locations.is_a?(String)
|
|
81
|
-
if locations != ":
|
|
90
|
+
if locations != ":" && show_locations
|
|
82
91
|
" (location: #{locations})"
|
|
83
92
|
else
|
|
84
93
|
""
|
|
@@ -111,22 +120,9 @@ class Objenealogist
|
|
|
111
120
|
(location_map[name] ||= { name: name, locations: [], methods: [] })[:locations] << [path, def_location]
|
|
112
121
|
end
|
|
113
122
|
end
|
|
114
|
-
source_locations.uniq(&:join).each do |m, method_path, line|
|
|
115
|
-
locations = location_map.values.find do |location|
|
|
116
|
-
location[:locations].any? do |source_path, loc|
|
|
117
|
-
method_path == source_path && loc.start_line <= line && line <= loc.end_line
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
if locations
|
|
121
|
-
locations[:methods] << [m, method_path, line]
|
|
122
|
-
else
|
|
123
|
-
location_map[clazz.to_s.to_sym]&.[](:methods)&.<< [m, nil, 0]
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
123
|
# {M1:
|
|
127
124
|
# {name: :M1,
|
|
128
|
-
# locations: [["objenealogist.rb", (122,0)-(124,3)]]
|
|
129
|
-
# methods: [[:m1, "objenealogist.rb", 123]]}}
|
|
125
|
+
# locations: [["objenealogist.rb", (122,0)-(124,3)]]}
|
|
130
126
|
location_map
|
|
131
127
|
end
|
|
132
128
|
end
|