graphwerk 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -4
- data/lib/graphwerk/builders/graph.rb +1 -1
- data/lib/graphwerk/layout.rb +1 -0
- data/lib/graphwerk/presenters/package.rb +40 -17
- data/lib/graphwerk/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: bf78a60a25721799a4c6dc0623fa3678ceead0369974a26a7828ce05b10a81e6
|
4
|
+
data.tar.gz: 877ded46de6dd8a16320e0eca0b0bf4f9cd1bed69e70aaf28b6b37057d25cb8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f0abf8f377d771f2bd7fee6abc0d9872187493cca876b7ebea34511df1ef47b8c7c976f14d6b9671f9e5ad7a0fd3d6bef0aca56a3b199946fdfe73aedc5b009
|
7
|
+
data.tar.gz: be181ec7c607241974d2753cc0bc649a10d880624316a674e671b43bad259e8e56658d886486fb35970766dea95280eb8bfd209138af605da0ad64be299b6e36
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,13 +8,13 @@ The gem builds on top of [Packwerk](https://github.com/Shopify/packwerk) and [Gr
|
|
8
8
|
|
9
9
|
Here's an example application package dependency diagram:
|
10
10
|
|
11
|
-
![example](https://user-images.githubusercontent.com/2643026/
|
11
|
+
![example](https://user-images.githubusercontent.com/2643026/97689408-6ca1f480-1a93-11eb-9999-22e79791b300.png)
|
12
12
|
|
13
13
|
## Install
|
14
14
|
|
15
15
|
Add this line to your application's Gemfile and run `bundle install`:
|
16
16
|
|
17
|
-
`gem 'graphwerk'`
|
17
|
+
`gem 'graphwerk', group: %i[development test]`
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
@@ -24,7 +24,7 @@ For Rails applications a Railtie automatically loads a rake task that makes it e
|
|
24
24
|
bundle exec rake graphwerk:update
|
25
25
|
```
|
26
26
|
|
27
|
-
More advance usage is possible by passing a `Packwerk::PackageSet` directly to `Graphwerk::Builders::Graph` and calling `#build` returning a `Graphviz` instance:
|
27
|
+
More advance usage is possible by passing a [`Packwerk::PackageSet`](https://github.com/Shopify/packwerk/blob/main/lib/packwerk/package_set.rb) directly to `Graphwerk::Builders::Graph` and calling `#build` returning a `Graphviz` instance:
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
graph = Graphwerk::Builders::Graph.new(
|
@@ -33,7 +33,7 @@ graph = Graphwerk::Builders::Graph.new(
|
|
33
33
|
graph.output(svg: 'packwerk.svg')
|
34
34
|
```
|
35
35
|
|
36
|
-
All Graphviz layouts are supported and options for the graph, nodes and edges can be set via an optional `options` argument:
|
36
|
+
All [Graphviz layouts](https://graphviz.org/documentation/#layout-manual-pages) are supported and options for the graph, nodes and edges can be set via an optional `options` argument:
|
37
37
|
|
38
38
|
```ruby
|
39
39
|
graph = Graphwerk::Builders::Graph.new(
|
data/lib/graphwerk/layout.rb
CHANGED
@@ -11,21 +11,14 @@ module Graphwerk
|
|
11
11
|
@package = package
|
12
12
|
end
|
13
13
|
|
14
|
-
WITHOUT_ROOT_FOLDER = T.let(
|
15
|
-
->(package_name) { package_name.split('/', 2).last },
|
16
|
-
T.proc.params(package_name: String).returns(String)
|
17
|
-
)
|
18
|
-
|
19
14
|
sig { returns(String) }
|
20
15
|
def name
|
21
|
-
|
22
|
-
|
23
|
-
Constants::ROOT_PACKAGE_NAME
|
16
|
+
package_name.node_name
|
24
17
|
end
|
25
18
|
|
26
19
|
sig { returns(T::Array[String]) }
|
27
20
|
def dependencies
|
28
|
-
@package.dependencies.map { |dependency|
|
21
|
+
@package.dependencies.map { |dependency| Name.new(dependency).node_name }
|
29
22
|
end
|
30
23
|
|
31
24
|
ROOT_COLOR = 'black'
|
@@ -33,24 +26,54 @@ module Graphwerk
|
|
33
26
|
|
34
27
|
sig { returns(String) }
|
35
28
|
def color
|
36
|
-
return ROOT_COLOR if root?
|
29
|
+
return ROOT_COLOR if package_name.root?
|
37
30
|
|
38
31
|
COMPONENT_COLOR
|
39
32
|
end
|
40
33
|
|
41
34
|
private
|
42
35
|
|
43
|
-
|
36
|
+
sig { returns(Name) }
|
37
|
+
def package_name
|
38
|
+
@package_name = T.let(@package_name, T.nilable(Name))
|
39
|
+
@package_name ||= Name.new(@package.name)
|
40
|
+
end
|
41
|
+
|
42
|
+
class Name
|
43
|
+
extend T::Sig
|
44
|
+
|
45
|
+
sig { params(package_name: String).void }
|
46
|
+
def initialize(package_name)
|
47
|
+
@package_name = package_name
|
48
|
+
end
|
49
|
+
|
50
|
+
sig { returns(String) }
|
51
|
+
def node_name
|
52
|
+
return without_root_package unless root?
|
53
|
+
|
54
|
+
Constants::ROOT_PACKAGE_NAME
|
55
|
+
end
|
56
|
+
|
57
|
+
ROOT_PACKAGE = '.'
|
58
|
+
|
59
|
+
sig { returns(T::Boolean) }
|
60
|
+
def root?
|
61
|
+
@package_name == ROOT_PACKAGE
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
sig { returns(String) }
|
67
|
+
def without_root_package
|
68
|
+
T.must(@package_name.split('/', 2).last)
|
69
|
+
end
|
44
70
|
|
45
|
-
|
46
|
-
def root?
|
47
|
-
@package.name == ROOT_PACKAGE
|
71
|
+
private_constant :ROOT_PACKAGE
|
48
72
|
end
|
49
73
|
|
50
|
-
private_constant :
|
51
|
-
:ROOT_COLOR,
|
74
|
+
private_constant :ROOT_COLOR,
|
52
75
|
:COMPONENT_COLOR,
|
53
|
-
:
|
76
|
+
:Name
|
54
77
|
end
|
55
78
|
end
|
56
79
|
end
|
data/lib/graphwerk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Giles
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|