pocky 1.9.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/pocky/packwerk.rb +35 -11
- data/lib/pocky/version.rb +1 -1
- data/pocky.gemspec +0 -1
- 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: 8ad303bcc76eff49ab35053c61a7ad277165d40b999fcadac1d310be525ab69b
|
4
|
+
data.tar.gz: 16e002a3989465994fa932da11696b166468da711336f354fae58ece194087c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bc982c815e4becd96436596522ea9adf543ec3830e04e812185a452a263ee8715572dd260d2b912d2fd7ffaa2f2866ab5d9445b3ea841fa6486a9fd4bc1880e
|
7
|
+
data.tar.gz: 82a64fb0e51915f78085510a3b1aa78ea1e9a9b48a2a163f29610b280e613e2cfccfb7fb9e1bd6ff59df7b053b8decbcfd389f73d4aa96b0b2785aab318cb692
|
data/README.md
CHANGED
@@ -10,9 +10,12 @@ Invoke from irb or code, only `root_path` is required.
|
|
10
10
|
```ruby
|
11
11
|
Pocky::Packwerk.generate(
|
12
12
|
root_path: 'path/to/app/packages',
|
13
|
-
default_package: 'app', # The default package listed as "." in deprecated_references.yml
|
13
|
+
default_package: 'app', # The default package listed as "." in package.yml and deprecated_references.yml
|
14
14
|
filename: 'packwerk-viz.png', # Name of output file
|
15
|
-
dpi: 100
|
15
|
+
dpi: 100, # Output file resolution
|
16
|
+
package_color: 'darkgray', # color name or hex color, see https://graphviz.org/doc/info/colors.html for more details
|
17
|
+
deprecated_reference_edge: 'black',
|
18
|
+
dependency_edge: 'darkgreen',
|
16
19
|
)
|
17
20
|
```
|
18
21
|
|
data/lib/pocky/packwerk.rb
CHANGED
@@ -21,7 +21,10 @@ module Pocky
|
|
21
21
|
root_path:,
|
22
22
|
default_package: 'app',
|
23
23
|
filename: 'packwerk-viz.png',
|
24
|
-
dpi: 100
|
24
|
+
dpi: 100,
|
25
|
+
package_color: 'darkgray',
|
26
|
+
dependency_edge: 'green3',
|
27
|
+
deprecated_reference_edge: 'black'
|
25
28
|
)
|
26
29
|
@root_paths = [*root_path]
|
27
30
|
raise InvalidRootPathError, 'root_path is required' if @root_paths.empty?
|
@@ -32,6 +35,23 @@ module Pocky
|
|
32
35
|
@deprecated_references = {}
|
33
36
|
@package_dependencies = {}
|
34
37
|
@nodes = {}
|
38
|
+
|
39
|
+
@node_options = {
|
40
|
+
fontsize: 26.0,
|
41
|
+
fontcolor: 'white',
|
42
|
+
fillcolor: package_color,
|
43
|
+
color: package_color,
|
44
|
+
style: 'filled, rounded',
|
45
|
+
shape: 'box',
|
46
|
+
}
|
47
|
+
|
48
|
+
@deprecated_references_edge_options = {
|
49
|
+
color: deprecated_reference_edge,
|
50
|
+
}
|
51
|
+
|
52
|
+
@dependency_edge_options = {
|
53
|
+
color: dependency_edge
|
54
|
+
}
|
35
55
|
end
|
36
56
|
|
37
57
|
def generate
|
@@ -51,14 +71,15 @@ module Pocky
|
|
51
71
|
|
52
72
|
def draw_dependencies
|
53
73
|
@package_dependencies.each do |package, file|
|
54
|
-
@nodes[package] ||= @graph.add_nodes(package)
|
55
|
-
file
|
74
|
+
@nodes[package] ||= @graph.add_nodes(package, **@node_options)
|
75
|
+
file.each do |provider|
|
56
76
|
provider_package = package_name_for_dependency(provider)
|
57
|
-
@nodes[provider_package] ||= @graph.add_nodes(provider_package)
|
77
|
+
@nodes[provider_package] ||= @graph.add_nodes(provider_package, **@node_options)
|
58
78
|
|
59
79
|
@graph.add_edges(
|
60
80
|
@nodes[package],
|
61
|
-
@nodes[provider_package]
|
81
|
+
@nodes[provider_package],
|
82
|
+
**@dependency_edge_options
|
62
83
|
)
|
63
84
|
end
|
64
85
|
end
|
@@ -66,15 +87,15 @@ module Pocky
|
|
66
87
|
|
67
88
|
def draw_deprecated_references
|
68
89
|
@deprecated_references.each do |package, references|
|
69
|
-
@nodes[package] ||= @graph.add_nodes(package)
|
90
|
+
@nodes[package] ||= @graph.add_nodes(package, **@node_options)
|
70
91
|
references.each do |provider, invocations|
|
71
92
|
provider_package = package_name_for_dependency(provider)
|
72
|
-
@nodes[provider_package] ||= @graph.add_nodes(provider_package)
|
93
|
+
@nodes[provider_package] ||= @graph.add_nodes(provider_package, **@node_options)
|
73
94
|
|
74
95
|
@graph.add_edges(
|
75
96
|
@nodes[package],
|
76
97
|
@nodes[provider_package],
|
77
|
-
|
98
|
+
**@deprecated_references_edge_options.merge(penwidth: edge_width(invocations.length)),
|
78
99
|
)
|
79
100
|
end
|
80
101
|
end
|
@@ -104,7 +125,10 @@ module Pocky
|
|
104
125
|
|
105
126
|
dependencies_files.each do |filename|
|
106
127
|
package = parse_package_name(filename)
|
107
|
-
@package_dependencies[package] ||=
|
128
|
+
@package_dependencies[package] ||= begin
|
129
|
+
yml = YAML.load_file(filename) || {}
|
130
|
+
yml['dependencies'] || []
|
131
|
+
end
|
108
132
|
end
|
109
133
|
end
|
110
134
|
|
@@ -124,8 +148,8 @@ module Pocky
|
|
124
148
|
def package_name_for_dependency(name)
|
125
149
|
return @default_package if name == '.'
|
126
150
|
|
127
|
-
reference_filename =
|
128
|
-
ref.match(/#{name}\/#{
|
151
|
+
reference_filename = deprecated_references_files.find do |ref|
|
152
|
+
ref.match(/#{name}\/#{DEPRECATED_REFERENCES_FILENAME}$/)
|
129
153
|
end
|
130
154
|
|
131
155
|
if reference_filename
|
data/lib/pocky/version.rb
CHANGED
data/pocky.gemspec
CHANGED
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
16
|
|
17
|
-
|
18
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
18
|
spec.metadata["source_code_uri"] = "https://github.com/mquan/pocky"
|
20
19
|
spec.metadata["changelog_uri"] = "https://github.com/mquan/pocky"
|