graphwerk 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/graphwerk.rb +1 -0
- data/lib/graphwerk/builders/graph.rb +21 -4
- data/lib/graphwerk/deprecated_references_loader.rb +31 -0
- data/lib/graphwerk/presenters/package.rb +11 -7
- data/lib/graphwerk/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7af64b8123b10c0d175ca2b59b321cd0a5140ce3216dfc1d2bd5851f362b5642
|
4
|
+
data.tar.gz: 05c51382e40bc20ebf51deb955a2bf6b715ee3992f7ceb379d638233cfe998c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cef57b21fe954604e46777f4a35a8200c0bf33f4b0b7a36345faf6a38eb1af2ddbe86462cb79a9bd3ddf90fa3fc7845168b317f59fbd717f1f54e1cda5e88e8
|
7
|
+
data.tar.gz: fdd4b9b472b4ea595f0e13929448459a7524d10e2edf9efa2f5ef77afc77df2c61e1fe99af2f6bb66b2178974c954e9a823d02301fa71beacaaec8c1228f9bff
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,7 @@ graph = Graphwerk::Builders::Graph.new(
|
|
40
40
|
Packwerk::PackageSet.load_all_from("."),
|
41
41
|
options: {
|
42
42
|
layout: Graphwerk::Layout::Twopi,
|
43
|
+
deprecated_references_color: 'yellow',
|
43
44
|
graph: { overlap: true },
|
44
45
|
node: { fillcolor: '#000000' },
|
45
46
|
edges: { len: '3.0' }
|
data/lib/graphwerk.rb
CHANGED
@@ -8,6 +8,7 @@ require 'active_support/core_ext/hash/deep_merge'
|
|
8
8
|
require 'graphwerk/version'
|
9
9
|
require 'graphwerk/constants'
|
10
10
|
require 'graphwerk/layout'
|
11
|
+
require 'graphwerk/deprecated_references_loader'
|
11
12
|
require 'graphwerk/presenters/package'
|
12
13
|
require 'graphwerk/builders/graph'
|
13
14
|
require 'graphwerk/railtie' if defined?(Rails)
|
@@ -9,6 +9,7 @@ module Graphwerk
|
|
9
9
|
OptionsShape = T.type_alias {
|
10
10
|
{
|
11
11
|
layout: Graphwerk::Layout,
|
12
|
+
deprecated_references_color: String,
|
12
13
|
application: T::Hash[Symbol, Object],
|
13
14
|
graph: T::Hash[Symbol, Object],
|
14
15
|
node: T::Hash[Symbol, Object],
|
@@ -18,6 +19,7 @@ module Graphwerk
|
|
18
19
|
|
19
20
|
DEFAULT_OPTIONS = T.let({
|
20
21
|
layout: Graphwerk::Layout::Dot,
|
22
|
+
deprecated_references_color: 'red',
|
21
23
|
application: {
|
22
24
|
style: 'filled',
|
23
25
|
fillcolor: '#333333',
|
@@ -41,10 +43,11 @@ module Graphwerk
|
|
41
43
|
}
|
42
44
|
}, OptionsShape)
|
43
45
|
|
44
|
-
sig { params(package_set: Packwerk::PackageSet, options: T::Hash[Symbol, Object]).void }
|
45
|
-
def initialize(package_set, options: {})
|
46
|
+
sig { params(package_set: Packwerk::PackageSet, options: T::Hash[Symbol, Object], root_path: Pathname).void }
|
47
|
+
def initialize(package_set, options: {}, root_path: Pathname.new(ENV['PWD']))
|
46
48
|
@package_set = package_set
|
47
49
|
@options = T.let(DEFAULT_OPTIONS.deep_merge(options), OptionsShape)
|
50
|
+
@root_path = root_path
|
48
51
|
@graph = T.let(build_empty_graph, GraphViz)
|
49
52
|
@nodes = T.let(build_empty_nodes, T::Hash[String, GraphViz::Node])
|
50
53
|
end
|
@@ -85,7 +88,10 @@ module Graphwerk
|
|
85
88
|
|
86
89
|
sig { void }
|
87
90
|
def add_package_dependencies_to_graph
|
88
|
-
packages.each
|
91
|
+
packages.each do |package|
|
92
|
+
draw_dependencies(package)
|
93
|
+
draw_deprecated_references(package)
|
94
|
+
end
|
89
95
|
end
|
90
96
|
|
91
97
|
sig { void }
|
@@ -102,10 +108,21 @@ module Graphwerk
|
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
111
|
+
sig { params(package: Presenters::Package).void }
|
112
|
+
def draw_deprecated_references(package)
|
113
|
+
package.deprecated_references.each do |reference|
|
114
|
+
@graph.add_edges(
|
115
|
+
@nodes[package.name],
|
116
|
+
@nodes[reference],
|
117
|
+
color: @options[:deprecated_references_color]
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
105
122
|
sig { returns(T::Array[Presenters::Package]) }
|
106
123
|
def packages
|
107
124
|
@packages = T.let(@packages, T.nilable(T::Array[Presenters::Package]))
|
108
|
-
@packages ||= @package_set.map { |package| Presenters::Package.new(package) }
|
125
|
+
@packages ||= @package_set.map { |package| Presenters::Package.new(package, @root_path) }
|
109
126
|
end
|
110
127
|
end
|
111
128
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Graphwerk
|
5
|
+
class DeprecatedReferencesLoader
|
6
|
+
extend T::Sig
|
7
|
+
|
8
|
+
sig { params(package: Packwerk::Package, root_path: Pathname).void }
|
9
|
+
def initialize(package, root_path)
|
10
|
+
@package = package
|
11
|
+
@root_path = root_path
|
12
|
+
end
|
13
|
+
|
14
|
+
sig { returns(T::Array[String]) }
|
15
|
+
def load
|
16
|
+
return [] if !deprecated_references_file.exist?
|
17
|
+
|
18
|
+
(YAML.load_file(deprecated_references_file) || {}).keys
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
DEPRECATED_REFERENCES_FILENAME = 'deprecated_references.yml'
|
24
|
+
|
25
|
+
sig { returns(Pathname) }
|
26
|
+
def deprecated_references_file
|
27
|
+
@deprecated_references_file = T.let(@deprecated_references_file, T.nilable(Pathname))
|
28
|
+
@deprecated_references_file ||= @root_path.join(@package.name, DEPRECATED_REFERENCES_FILENAME)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -6,9 +6,10 @@ module Graphwerk
|
|
6
6
|
class Package
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
-
sig { params(package: Packwerk::Package).void }
|
10
|
-
def initialize(package)
|
9
|
+
sig { params(package: Packwerk::Package, root_path: Pathname).void }
|
10
|
+
def initialize(package, root_path)
|
11
11
|
@package = package
|
12
|
+
@root_path = root_path
|
12
13
|
end
|
13
14
|
|
14
15
|
sig { returns(String) }
|
@@ -21,6 +22,13 @@ module Graphwerk
|
|
21
22
|
@package.dependencies.map { |dependency| Name.new(dependency).node_name }
|
22
23
|
end
|
23
24
|
|
25
|
+
sig { returns(T::Array[String]) }
|
26
|
+
def deprecated_references
|
27
|
+
DeprecatedReferencesLoader.new(@package, @root_path).load.map do |reference|
|
28
|
+
Name.new(reference).node_name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
24
32
|
ROOT_COLOR = 'black'
|
25
33
|
COMPONENT_COLOR = 'azure4'
|
26
34
|
|
@@ -54,11 +62,9 @@ module Graphwerk
|
|
54
62
|
Constants::ROOT_PACKAGE_NAME
|
55
63
|
end
|
56
64
|
|
57
|
-
ROOT_PACKAGE = '.'
|
58
|
-
|
59
65
|
sig { returns(T::Boolean) }
|
60
66
|
def root?
|
61
|
-
@package_name ==
|
67
|
+
@package_name == Packwerk::Package::ROOT_PACKAGE_NAME
|
62
68
|
end
|
63
69
|
|
64
70
|
private
|
@@ -67,8 +73,6 @@ module Graphwerk
|
|
67
73
|
def without_root_package
|
68
74
|
T.must(@package_name.split('/', 2).last)
|
69
75
|
end
|
70
|
-
|
71
|
-
private_constant :ROOT_PACKAGE
|
72
76
|
end
|
73
77
|
|
74
78
|
private_constant :ROOT_COLOR,
|
data/lib/graphwerk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Giles
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10
|
11
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/graphwerk.rb
|
173
173
|
- lib/graphwerk/builders/graph.rb
|
174
174
|
- lib/graphwerk/constants.rb
|
175
|
+
- lib/graphwerk/deprecated_references_loader.rb
|
175
176
|
- lib/graphwerk/layout.rb
|
176
177
|
- lib/graphwerk/presenters/package.rb
|
177
178
|
- lib/graphwerk/railtie.rb
|