pocky 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pocky.rb +1 -0
- data/lib/pocky/package.rb +33 -0
- data/lib/pocky/packwerk.rb +41 -40
- data/lib/pocky/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de11dcff9a0765101df1f14137880873958a8049
|
4
|
+
data.tar.gz: 17ee8cd45457cf323bc2edc65fa97863798825ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36777289020339a7899b4d830e7dea1b3d2b4c693df77c9419c9468e358cf068343a83d872ab99d41d6989c1961041c27e05d7cb8d7a25d591f0aa26fcc99f7a
|
7
|
+
data.tar.gz: d68f933f49969f5c375614aea01c8f40d7802a9a90cd2fac8d8f4c789bbacf217a98c547400883baaed98f0a971b83e3bc2cf83693d23c382b76b45be5a25e93
|
data/lib/pocky.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Pocky
|
6
|
+
class Package
|
7
|
+
attr_reader :name, :dependencies, :enforce_privacy, :deprecated_references
|
8
|
+
|
9
|
+
def initialize(name:, filename: nil)
|
10
|
+
@name = name
|
11
|
+
@filename = filename
|
12
|
+
@dependencies = yml['dependencies'] || []
|
13
|
+
@enforce_privacy = yml['enforce_privacy'] || false
|
14
|
+
@deprecated_references = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_deprecated_references(reference_filename)
|
18
|
+
@deprecated_references = YAML.load_file(reference_filename) || {}
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def yml
|
24
|
+
@yml ||= begin
|
25
|
+
if @filename
|
26
|
+
YAML.load_file(@filename) || {}
|
27
|
+
else
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/pocky/packwerk.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pathname'
|
4
|
-
require 'yaml'
|
5
4
|
require 'ruby-graphviz'
|
6
5
|
|
7
6
|
module Pocky
|
8
|
-
class InvalidRootPathError < StandardError
|
9
|
-
end
|
10
|
-
|
11
7
|
class Packwerk
|
12
8
|
DEPENDENCIES_FILENAME = 'package.yml'
|
13
9
|
DEPRECATED_REFERENCES_FILENAME = 'deprecated_references.yml'
|
@@ -35,10 +31,9 @@ module Pocky
|
|
35
31
|
@default_package = default_package
|
36
32
|
@filename = filename
|
37
33
|
@analyze_sizes = analyze_sizes
|
38
|
-
|
39
34
|
@dpi = dpi.to_i
|
40
|
-
|
41
|
-
@
|
35
|
+
|
36
|
+
@packages = {}
|
42
37
|
@nodes = {}
|
43
38
|
|
44
39
|
@node_options = {
|
@@ -73,54 +68,57 @@ module Pocky
|
|
73
68
|
if file_size < 10
|
74
69
|
{ fontsize: 26 }
|
75
70
|
elsif file_size < 100
|
76
|
-
{ fontsize: 26 *
|
71
|
+
{ fontsize: 26 * 2, margin: 0.2 }
|
77
72
|
elsif file_size < 1000
|
78
|
-
{ fontsize: 26 *
|
73
|
+
{ fontsize: 26 * 4, margin: 0.4 }
|
79
74
|
elsif file_size < 10_000
|
80
|
-
{ fontsize: 26 *
|
75
|
+
{ fontsize: 26 * 8, margin: 0.8 }
|
81
76
|
else
|
82
|
-
{ fontsize: 26 *
|
77
|
+
{ fontsize: 26 * 16, margin: 1.0 }
|
83
78
|
end
|
84
79
|
end
|
85
80
|
|
86
81
|
def draw_node(package)
|
87
|
-
package_name = package_name_for_dependency(package)
|
88
|
-
path = package == '.' ? @root_path : @root_path.join(package)
|
82
|
+
package_name = package_name_for_dependency(package.name)
|
83
|
+
path = package.name == '.' ? @root_path : @root_path.join(package.name)
|
89
84
|
file_size = @analyze_sizes ? RubyFileSize.compute(path.to_s) : 1
|
90
|
-
|
85
|
+
node_label = "#{package_name}#{' (Þ)' if package.enforce_privacy}"
|
86
|
+
|
87
|
+
@graph.add_nodes(
|
88
|
+
package_name,
|
89
|
+
**@node_options.merge(
|
90
|
+
**node_overrides(file_size),
|
91
|
+
label: node_label
|
92
|
+
)
|
93
|
+
)
|
91
94
|
end
|
92
95
|
|
93
96
|
def build_directed_graph
|
94
97
|
@graph = GraphViz.new(:G, type: :digraph, dpi: @dpi)
|
95
|
-
|
96
|
-
draw_deprecated_references
|
98
|
+
draw_packages
|
97
99
|
@graph.output(png: @filename)
|
98
100
|
end
|
99
101
|
|
100
|
-
def
|
101
|
-
@
|
102
|
-
@nodes[package] ||= draw_node(package)
|
103
|
-
|
104
|
-
|
102
|
+
def draw_packages
|
103
|
+
@packages.each do |_name, package|
|
104
|
+
@nodes[package.name] ||= draw_node(package)
|
105
|
+
|
106
|
+
package.dependencies.each do |dependency|
|
107
|
+
@nodes[dependency] ||= draw_node(@packages[dependency])
|
105
108
|
|
106
109
|
@graph.add_edges(
|
107
|
-
@nodes[package],
|
108
|
-
@nodes[
|
110
|
+
@nodes[package.name],
|
111
|
+
@nodes[dependency],
|
109
112
|
**@dependency_edge_options
|
110
113
|
)
|
111
114
|
end
|
112
|
-
end
|
113
|
-
end
|
114
115
|
|
115
|
-
|
116
|
-
|
117
|
-
@nodes[package] ||= draw_node(package)
|
118
|
-
references.each do |provider, invocations|
|
119
|
-
@nodes[provider] ||= draw_node(provider)
|
116
|
+
package.deprecated_references.each do |provider_name, invocations|
|
117
|
+
@nodes[provider_name] ||= draw_node(@packages[provider_name])
|
120
118
|
|
121
119
|
@graph.add_edges(
|
122
|
-
@nodes[package],
|
123
|
-
@nodes[
|
120
|
+
@nodes[package.name],
|
121
|
+
@nodes[provider_name],
|
124
122
|
**@deprecated_references_edge_options.merge(
|
125
123
|
penwidth: edge_width(invocations.length),
|
126
124
|
),
|
@@ -160,11 +158,8 @@ module Pocky
|
|
160
158
|
return if dependencies_files.empty?
|
161
159
|
|
162
160
|
dependencies_files.each do |filename|
|
163
|
-
|
164
|
-
@
|
165
|
-
yml = YAML.load_file(filename) || {}
|
166
|
-
yml['dependencies'] || []
|
167
|
-
end
|
161
|
+
package_name = parse_package_name(filename)
|
162
|
+
@packages[package_name] ||= Pocky::Package.new(name: package_name, filename: filename)
|
168
163
|
end
|
169
164
|
end
|
170
165
|
|
@@ -172,14 +167,20 @@ module Pocky
|
|
172
167
|
return if deprecated_references_files.empty?
|
173
168
|
|
174
169
|
deprecated_references_files.each do |filename|
|
175
|
-
|
176
|
-
@
|
170
|
+
package_name = parse_package_name(filename)
|
171
|
+
@packages[package_name] ||= Pocky::Package.new(name: package_name)
|
172
|
+
@packages[package_name].add_deprecated_references(filename)
|
173
|
+
|
174
|
+
# Walk the references to create referenced packages
|
175
|
+
@packages[package_name].deprecated_references.each do |provider_name, _violations|
|
176
|
+
@packages[provider_name] ||= Pocky::Package.new(name: provider_name)
|
177
|
+
end
|
177
178
|
end
|
178
179
|
end
|
179
180
|
|
180
181
|
def parse_package_name(filename)
|
181
182
|
name = File.dirname(filename).gsub(@root_path.to_s, '')
|
182
|
-
name == '' ?
|
183
|
+
name == '' ? '.' : name.gsub(/^\//, '')
|
183
184
|
end
|
184
185
|
|
185
186
|
def package_name_for_dependency(name)
|
data/lib/pocky/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pocky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quan Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-graphviz
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- bin/setup
|
43
43
|
- lib/pocky.rb
|
44
44
|
- lib/pocky/Rakefile
|
45
|
+
- lib/pocky/package.rb
|
45
46
|
- lib/pocky/packwerk.rb
|
46
47
|
- lib/pocky/railtie.rb
|
47
48
|
- lib/pocky/ruby_file_size.rb
|