pocky 1.6.0 → 1.7.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 +21 -6
- data/lib/pocky/packwerk.rb +26 -20
- data/lib/pocky/tasks/generate.rake +4 -2
- 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: 22de5def074e1cb08bee99280a266ea9ebcf29056ae4dd117f75682e2e3d3221
|
4
|
+
data.tar.gz: 7c8258dbf32e3c30099e7d3b4f7d5b7404c7d28348163b7b9a5f51671b490e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e659f0fd8a2a3c0f4a6c9e0bc195ae7493a0b27d774996c533cedce3898a20d14d7f703a9c6f6715e290175c02435519ddfa486ca6ce506d5ac38d97017f7f80
|
7
|
+
data.tar.gz: a67332ec4f9dc8503b4267fef328a8d98eb0894bd90554867c3b6f299eba35a898f1e42560c190adf94e4748d182bf16b016fccf0636bb1b28c2e6e44edb4432
|
data/README.md
CHANGED
@@ -6,12 +6,11 @@ Pocky generates dependency graphs for your packwerk packages. The gem is named a
|
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
-
Invoke from irb or code
|
9
|
+
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
13
|
default_package: 'Default', # The default package listed as "." in deprecated_references.yml
|
14
|
-
package_prefix: 'app/packages', # this is for matching package names listed in deprecated_references.yml
|
15
14
|
filename: 'packwerk-viz.png', # Name of output file
|
16
15
|
dpi: 150 # Output file resolution
|
17
16
|
)
|
@@ -21,11 +20,27 @@ Pocky::Packwerk.generate(
|
|
21
20
|
|
22
21
|
Note that the the bold edges indicate heavier dependencies.
|
23
22
|
|
24
|
-
Invoke as a rake task
|
23
|
+
Invoke as a rake task:
|
25
24
|
|
25
|
+
$ rake pocky:generate"[path/to/app/packages,Monolith,packages.png,100]"
|
26
|
+
|
27
|
+
|
28
|
+
#### `root_path` as an array
|
29
|
+
`root_path` can also be an array in case your packages are organized in multiple directories. Alternatively, you can also provide paths to individual packages to generate more focused graphs for your package subsystems.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Pocky::Packwerk.generate(
|
33
|
+
root_path: [
|
34
|
+
'path/to/app/packages/a',
|
35
|
+
'path/to/app/packages/z',
|
36
|
+
]
|
37
|
+
)
|
26
38
|
```
|
27
|
-
|
28
|
-
|
39
|
+
|
40
|
+
Generate the same graph using the rake task:
|
41
|
+
|
42
|
+
$ rake pocky:generate"[path/to/app/packages/a path/to/app/packages/z]"
|
43
|
+
|
29
44
|
|
30
45
|
## Installation
|
31
46
|
|
@@ -51,7 +66,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
51
66
|
|
52
67
|
## Contributing
|
53
68
|
|
54
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mquan/pocky.
|
55
70
|
|
56
71
|
## License
|
57
72
|
|
data/lib/pocky/packwerk.rb
CHANGED
@@ -4,7 +4,11 @@ require 'yaml'
|
|
4
4
|
require 'ruby-graphviz'
|
5
5
|
|
6
6
|
module Pocky
|
7
|
+
class InvalidRootPathError < StandardError
|
8
|
+
end
|
9
|
+
|
7
10
|
class Packwerk
|
11
|
+
REFERENCE_FILE_NAME = 'deprecated_references.yml'
|
8
12
|
MAX_EDGE_WIDTH = 5
|
9
13
|
|
10
14
|
def self.generate(params)
|
@@ -15,13 +19,13 @@ module Pocky
|
|
15
19
|
def initialize(
|
16
20
|
root_path:,
|
17
21
|
default_package: 'Default',
|
18
|
-
package_prefix: '',
|
19
22
|
filename: 'packwerk-viz.png',
|
20
23
|
dpi: 150
|
21
24
|
)
|
22
|
-
@
|
25
|
+
@root_paths = [*root_path]
|
26
|
+
raise InvalidRootPathError, 'root_path is required' if @root_paths.empty?
|
27
|
+
|
23
28
|
@default_package = default_package
|
24
|
-
@package_prefix = package_prefix
|
25
29
|
@filename = filename
|
26
30
|
@dpi = dpi.to_i
|
27
31
|
@deprecated_references = {}
|
@@ -29,7 +33,7 @@ module Pocky
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def generate
|
32
|
-
|
36
|
+
load_package_references
|
33
37
|
build_directed_graph
|
34
38
|
end
|
35
39
|
|
@@ -61,33 +65,35 @@ module Pocky
|
|
61
65
|
].min
|
62
66
|
end
|
63
67
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
load_deprecated_references_for_package(elem)
|
68
|
-
end
|
68
|
+
def package_references
|
69
|
+
@package_references ||= @root_paths.flat_map do |path|
|
70
|
+
Dir["#{path}/**/#{REFERENCE_FILE_NAME}"]
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
def load_package_references
|
75
|
+
if package_references.empty?
|
76
|
+
raise InvalidRootPathError, "Cannot find any #{REFERENCE_FILE_NAME} in provided root_path"
|
77
|
+
end
|
78
|
+
|
79
|
+
package_references.each do |filename|
|
80
|
+
package = parse_package_name(filename)
|
81
|
+
@deprecated_references[package] ||= YAML.load_file(filename) || {}
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
def
|
84
|
-
File.
|
85
|
+
def parse_package_name(filename)
|
86
|
+
File.basename(File.dirname(filename))
|
85
87
|
end
|
86
88
|
|
87
89
|
def package_name_for_dependency(name)
|
88
90
|
return @default_package if name == '.'
|
89
91
|
|
90
|
-
|
92
|
+
reference_filename = package_references.find do |ref|
|
93
|
+
ref.match(/#{name}\/#{REFERENCE_FILE_NAME}$/)
|
94
|
+
end
|
95
|
+
|
96
|
+
parse_package_name(reference_filename)
|
91
97
|
end
|
92
98
|
end
|
93
99
|
end
|
@@ -2,7 +2,9 @@ require 'pocky'
|
|
2
2
|
|
3
3
|
namespace :pocky do
|
4
4
|
desc 'Generate dependency graph for packwerk packages'
|
5
|
-
task :generate, [:root_path, :default_package, :
|
6
|
-
Pocky::Packwerk.generate(args
|
5
|
+
task :generate, [:root_path, :default_package, :filename, :dpi] do |_task, args|
|
6
|
+
Pocky::Packwerk.generate(args.merge(
|
7
|
+
root_path: arg[:root_path].split(/\s+/)
|
8
|
+
))
|
7
9
|
end
|
8
10
|
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: 1.
|
4
|
+
version: 1.7.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: 2020-12-
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-graphviz
|