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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab45111779ec64a861557a7efeb7fefb02a255e0aa34ab791b8ae747475e7614
4
- data.tar.gz: e9b23a9174780956f67ab1db2746050e94649b7a56243b8a201598e18cb49181
3
+ metadata.gz: 8ad303bcc76eff49ab35053c61a7ad277165d40b999fcadac1d310be525ab69b
4
+ data.tar.gz: 16e002a3989465994fa932da11696b166468da711336f354fae58ece194087c4
5
5
  SHA512:
6
- metadata.gz: 29bcf083442dfe4e2267b8475fcc872a90161f6ee9a0bc4321fec130acfaad2598557ebd2084ef106ea41887a9d86de9e35c36e2c73b74690c2b4bd1f567a3ca
7
- data.tar.gz: c843b24dcc15b025d7426821abfd58da27dcfdef877752e75c53b6750dce4783a618ba7a1df0125658888c6b1c688ef8fe1cd35b82a5fab522e25d754ebde013
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 # Output file resolution
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
 
@@ -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['dependencies'].each do |provider|
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
- pendwidth: edge_width(invocations.length)
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] ||= YAML.load_file(filename) || {}
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 = deprecated_references.find do |ref|
128
- ref.match(/#{name}\/#{REFERENCE_FILE_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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pocky
4
- VERSION = "1.9.1"
4
+ VERSION = "1.9.2"
5
5
  end
@@ -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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pocky
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quan Nguyen