deps_grapher 1.0.0 → 1.0.2
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/CHANGELOG.md +8 -1
- data/README.md +1 -1
- data/deps_grapher.gemspec +1 -0
- data/lib/deps_grapher/ast_processor.rb +1 -1
- data/lib/deps_grapher/configuration.rb +3 -4
- data/lib/deps_grapher/graph.rb +2 -2
- data/lib/deps_grapher/input.rb +19 -17
- data/lib/deps_grapher/layer.rb +0 -2
- data/lib/deps_grapher/source_cache/class_name_extractor.rb +1 -1
- data/lib/deps_grapher/source_cache/registry.rb +10 -15
- data/lib/deps_grapher/source_cache.rb +0 -2
- data/lib/deps_grapher/version.rb +1 -1
- data/lib/deps_grapher.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a737245f2c63696cd2a7f5c492ddb9c049e8f8e9a3e51ee9ce897dc4fb8e593
|
4
|
+
data.tar.gz: dbb1e28028e37ef1d5127ce8e576012057b11518c7253c0dce047097aea8ad2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e8d778b87a6c3e3ce815f2911c47fe7c636c31dc42d7000094e4c2415ab3628377eb235007641386099c07d126489d630bba7785c56318913d613706a0f58b8
|
7
|
+
data.tar.gz: f6f93769c92aaeb8111defca8a6ea1e4781ce711678c2d1e728be33c8fefbb4d6ceec8534078db6937add8942c954225da4867859357d4bc8f65cc7c81042856
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
-
## [1.0.
|
1
|
+
## [1.0.2] - 2024-04-03
|
2
|
+
- Use `prism` gem instead of `parser` gem (parsing process is approximately 30% faster)
|
3
|
+
|
4
|
+
## [1.0.1] - 2024-03-26
|
5
|
+
- Fixed a cache issue
|
6
|
+
- Fixed an issue that `__FILE__` or `__dir__` is nil in the configuration file
|
7
|
+
|
8
|
+
## [1.0.0] - 2024-03-25
|
2
9
|
|
3
10
|
- Initial release
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ A Tool to visualize Ruby class dependencies
|
|
5
5
|
|
6
6
|
## Description
|
7
7
|
|
8
|
-
Deps Grapher is intended for a general understanding of class dependencies through static analysis. It uses `
|
8
|
+
Deps Grapher is intended for a general understanding of class dependencies through static analysis. It uses `prism` gem.
|
9
9
|
|
10
10
|
Please note the following:
|
11
11
|
|
data/deps_grapher.gemspec
CHANGED
@@ -12,6 +12,7 @@ module DepsGrapher
|
|
12
12
|
class_attribute :target_path # target class name on graph
|
13
13
|
class_attribute :clean, default: false
|
14
14
|
class_attribute :logger
|
15
|
+
class_attribute :cache_key
|
15
16
|
class_attribute :cache_dir, default: File.expand_path(File.join("..", "..", "tmp", "deps_grapher", "cache"), __dir__)
|
16
17
|
class_attribute :cache_ttl, default: 60 * 5 # 5 minutes
|
17
18
|
class_attribute :output_dir, default: File.expand_path(File.join("..", "..", "tmp", "deps_grapher", "graph"), __dir__)
|
@@ -75,11 +76,9 @@ module DepsGrapher
|
|
75
76
|
|
76
77
|
content = File.read file
|
77
78
|
|
78
|
-
cache_key = Digest::MD5.hexdigest
|
79
|
+
self.cache_key = Digest::MD5.hexdigest content
|
79
80
|
|
80
|
-
|
81
|
-
DSL.new(self).instance_eval content
|
82
|
-
end
|
81
|
+
DSL.new(self).instance_eval content, file
|
83
82
|
|
84
83
|
return unless dump
|
85
84
|
|
data/lib/deps_grapher/graph.rb
CHANGED
@@ -38,14 +38,14 @@ module DepsGrapher
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def dfs(current, target_path_matcher, visited, path, paths)
|
41
|
-
return if visited[current]
|
42
|
-
|
43
41
|
visited[current] = true
|
44
42
|
|
45
43
|
if target_path_matcher.match?(current.class_name)
|
46
44
|
paths << path
|
47
45
|
else
|
48
46
|
@graph[current]&.each do |node|
|
47
|
+
next if visited[node]
|
48
|
+
|
49
49
|
dfs node, target_path_matcher, visited, path + [node], paths
|
50
50
|
end
|
51
51
|
end
|
data/lib/deps_grapher/input.rb
CHANGED
@@ -9,32 +9,34 @@ module DepsGrapher
|
|
9
9
|
def files
|
10
10
|
FileUtils.rm_rf File.dirname(config.cache_dir) if config.clean
|
11
11
|
|
12
|
-
|
13
|
-
extract_files_from_layers
|
14
|
-
end
|
12
|
+
layer_visibilities = config.visualizer_options[:layers]
|
15
13
|
|
16
|
-
|
14
|
+
files = []
|
17
15
|
|
18
|
-
|
16
|
+
SourceCache::Registry.with_cache config.cache_key do |restored|
|
17
|
+
config.layers.each_value do |layer|
|
18
|
+
name = layer.name
|
19
|
+
source = layer.source
|
19
20
|
|
20
|
-
|
21
|
-
layer_visibility = config.visualizer_options[:layers]
|
21
|
+
layer.visible = layer_visibilities.include? name
|
22
22
|
|
23
|
-
|
24
|
-
layer.visible = layer_visibility.include? layer.name
|
25
|
-
end
|
26
|
-
end
|
23
|
+
SourceCache.register! name, source unless restored
|
27
24
|
|
28
|
-
|
29
|
-
config.layers.values.select(&:visible).each_with_object([]) do |layer, files|
|
30
|
-
source = layer.source
|
25
|
+
next unless layer.visible
|
31
26
|
|
32
|
-
|
33
|
-
|
27
|
+
source.files.each do |file|
|
28
|
+
next if file == config.path
|
34
29
|
|
35
|
-
|
30
|
+
files << file
|
31
|
+
end
|
36
32
|
end
|
37
33
|
end
|
34
|
+
|
35
|
+
files
|
38
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
attr_reader :config
|
39
41
|
end
|
40
42
|
end
|
data/lib/deps_grapher/layer.rb
CHANGED
@@ -26,35 +26,30 @@ module DepsGrapher
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def with_cache(key)
|
29
|
-
restore_cache! key
|
30
|
-
yield
|
31
|
-
persist_cache! key
|
32
|
-
end
|
33
|
-
|
34
|
-
def persist_cache!(key)
|
35
29
|
cache_file = DepsGrapher.cache_file key
|
36
|
-
cache_file
|
30
|
+
restore_cache! cache_file
|
31
|
+
yield @cache_restoration
|
32
|
+
persist_cache! cache_file
|
37
33
|
end
|
38
34
|
|
39
|
-
|
40
|
-
|
35
|
+
private
|
36
|
+
|
37
|
+
def restore_cache!(cache_file)
|
41
38
|
loaded = cache_file.read
|
42
39
|
|
43
40
|
unless loaded
|
44
|
-
@
|
41
|
+
@cache_restoration = false
|
45
42
|
return
|
46
43
|
end
|
47
44
|
|
48
45
|
@registry = loaded
|
49
|
-
@
|
46
|
+
@cache_restoration = true
|
50
47
|
end
|
51
48
|
|
52
|
-
def
|
53
|
-
@
|
49
|
+
def persist_cache!(cache_file)
|
50
|
+
cache_file.write @registry
|
54
51
|
end
|
55
52
|
|
56
|
-
private
|
57
|
-
|
58
53
|
def registry
|
59
54
|
@registry ||= {}
|
60
55
|
end
|
data/lib/deps_grapher/version.rb
CHANGED
data/lib/deps_grapher.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deps_grapher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jk-es335
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03
|
11
|
+
date: 2024-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: prism
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- dev@hacomono.co.jp
|