pocky 1.9.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -10
- data/lib/pocky/packwerk.rb +23 -22
- data/lib/pocky/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 817ec28553db2266db7aad79d4a6a007c185f72e07473e08f3cd406bd55da240
|
4
|
+
data.tar.gz: 1f35a2c830b7462c57a1860c851a349d11f5387d1ba9f04b0e91a44615ef8270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec156a41900ee641e2a71e1745c90196d7a7b4e7ee11fc0a8da50311462baa83559746244e3f548646aa26d14d1c619a12908b03353ea219f647baf289db853
|
7
|
+
data.tar.gz: 42bf0e9dd7c5bbee96cbb6756ef1d42dc5ecb49002dd9cdcad615a008f1e2e2ab995d50f04a705ac3094316ac389f31bf6d0eadd21cc0629f0012ca184964c46
|
data/README.md
CHANGED
@@ -2,18 +2,28 @@
|
|
2
2
|
|
3
3
|
Pocky generates dependency graphs for your packwerk packages. The gem is named after pocky, a beloved Japanese snack that comes in small packages.
|
4
4
|
|
5
|
-
![Pocky](https://user-images.githubusercontent.com/138784/103248942-c141de80-4921-11eb-99bd-3744816abc37.png)
|
6
5
|
|
7
6
|
## Usage
|
8
7
|
|
9
|
-
Invoke from irb or code
|
8
|
+
Invoke from irb or code.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
Pocky::Packwerk.generate
|
12
|
+
```
|
13
|
+
|
14
|
+
Invoke as a rake task:
|
15
|
+
|
16
|
+
$ rake pocky:generate
|
17
|
+
|
18
|
+
|
19
|
+
#### Generate with custom options
|
10
20
|
```ruby
|
11
21
|
Pocky::Packwerk.generate(
|
12
|
-
|
22
|
+
package_path: 'app/packages', # Relative path to packages directory
|
13
23
|
default_package: 'app', # The default package listed as "." in package.yml and deprecated_references.yml
|
14
|
-
filename: 'packwerk
|
24
|
+
filename: 'packwerk.png', # Name of output file
|
15
25
|
dpi: 100, # Output file resolution
|
16
|
-
package_color: '
|
26
|
+
package_color: '#5CC8FF', # color name or hex color, see https://graphviz.org/doc/info/colors.html for more details
|
17
27
|
deprecated_reference_edge: 'black',
|
18
28
|
dependency_edge: 'darkgreen',
|
19
29
|
)
|
@@ -25,7 +35,7 @@ Note that the the bold edges indicate heavier dependencies.
|
|
25
35
|
|
26
36
|
Invoke as a rake task:
|
27
37
|
|
28
|
-
$ rake pocky:generate"[
|
38
|
+
$ rake pocky:generate"[app/packages,Monolith,packages.png,100]"
|
29
39
|
|
30
40
|
|
31
41
|
#### `root_path` as an array
|
@@ -33,16 +43,16 @@ Invoke as a rake task:
|
|
33
43
|
|
34
44
|
```ruby
|
35
45
|
Pocky::Packwerk.generate(
|
36
|
-
|
37
|
-
'
|
38
|
-
'
|
46
|
+
package_path: [
|
47
|
+
'app/packages/a',
|
48
|
+
'app/packages/z',
|
39
49
|
]
|
40
50
|
)
|
41
51
|
```
|
42
52
|
|
43
53
|
Generate the same graph using the rake task:
|
44
54
|
|
45
|
-
$ rake pocky:generate"[
|
55
|
+
$ rake pocky:generate"[app/packages/a app/packages/z]"
|
46
56
|
|
47
57
|
|
48
58
|
## Installation
|
data/lib/pocky/packwerk.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'pathname'
|
3
4
|
require 'yaml'
|
4
5
|
require 'ruby-graphviz'
|
5
6
|
|
@@ -18,16 +19,16 @@ module Pocky
|
|
18
19
|
|
19
20
|
private_class_method :new
|
20
21
|
def initialize(
|
21
|
-
|
22
|
+
package_path: nil,
|
22
23
|
default_package: 'app',
|
23
|
-
filename: 'packwerk
|
24
|
+
filename: 'packwerk.png',
|
24
25
|
dpi: 100,
|
25
|
-
package_color: '
|
26
|
-
dependency_edge: '
|
26
|
+
package_color: '#5CC8FF',
|
27
|
+
dependency_edge: 'darkgreen',
|
27
28
|
deprecated_reference_edge: 'black'
|
28
29
|
)
|
29
|
-
@
|
30
|
-
|
30
|
+
@package_paths = [*package_path] if package_path
|
31
|
+
@root_path = defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)
|
31
32
|
|
32
33
|
@default_package = default_package
|
33
34
|
@filename = filename
|
@@ -41,6 +42,7 @@ module Pocky
|
|
41
42
|
fontcolor: 'white',
|
42
43
|
fillcolor: package_color,
|
43
44
|
color: package_color,
|
45
|
+
height: 1.0,
|
44
46
|
style: 'filled, rounded',
|
45
47
|
shape: 'box',
|
46
48
|
}
|
@@ -109,14 +111,22 @@ module Pocky
|
|
109
111
|
end
|
110
112
|
|
111
113
|
def deprecated_references_files
|
112
|
-
@deprecated_references_files ||=
|
113
|
-
Dir[
|
114
|
+
@deprecated_references_files ||= begin
|
115
|
+
return Dir[@root_path.join('**', DEPRECATED_REFERENCES_FILENAME).to_s] unless @package_paths
|
116
|
+
|
117
|
+
@package_paths.flat_map do |path|
|
118
|
+
Dir[@root_path.join(path, '**', DEPRECATED_REFERENCES_FILENAME).to_s]
|
119
|
+
end
|
114
120
|
end
|
115
121
|
end
|
116
122
|
|
117
123
|
def dependencies_files
|
118
|
-
@dependencies_files ||=
|
119
|
-
Dir[
|
124
|
+
@dependencies_files ||= begin
|
125
|
+
return Dir[@root_path.join('**', DEPENDENCIES_FILENAME).to_s] unless @package_paths
|
126
|
+
|
127
|
+
@package_paths.flat_map do |path|
|
128
|
+
Dir[@root_path.join(path, '**', DEPENDENCIES_FILENAME).to_s]
|
129
|
+
end
|
120
130
|
end
|
121
131
|
end
|
122
132
|
|
@@ -142,21 +152,12 @@ module Pocky
|
|
142
152
|
end
|
143
153
|
|
144
154
|
def parse_package_name(filename)
|
145
|
-
File.
|
155
|
+
name = File.dirname(filename).gsub(@root_path.to_s, '')
|
156
|
+
name == '' ? @default_package : name.gsub(/^\//, '')
|
146
157
|
end
|
147
158
|
|
148
159
|
def package_name_for_dependency(name)
|
149
|
-
|
150
|
-
|
151
|
-
reference_filename = deprecated_references_files.find do |ref|
|
152
|
-
ref.match(/#{name}\/#{DEPRECATED_REFERENCES_FILENAME}$/)
|
153
|
-
end
|
154
|
-
|
155
|
-
if reference_filename
|
156
|
-
parse_package_name(reference_filename)
|
157
|
-
else
|
158
|
-
name
|
159
|
-
end
|
160
|
+
name == '.' ? @default_package : name
|
160
161
|
end
|
161
162
|
end
|
162
163
|
end
|
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:
|
4
|
+
version: 2.0.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-01-
|
11
|
+
date: 2021-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-graphviz
|