parse_packwerk 0.14.0 → 0.15.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 +5 -5
- data/lib/parse_packwerk/constants.rb +1 -1
- data/lib/parse_packwerk/package.rb +1 -1
- data/lib/parse_packwerk/{deprecated_references.rb → package_todo.rb} +10 -10
- data/lib/parse_packwerk.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307906041051ec00eb3cc2647b0e04be2ac81d03f4ee0ebce51450b42a6eca55
|
4
|
+
data.tar.gz: 886374546d1cbb7d8562850d541c7fd77c3089f935138ab399c3c5df632ab396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76eff55192a47f33bf95cf267ed7517d143bec88ef403a36fc88b896254ef7278bfc4cc5d7a279aaa39f82d028b6db2d8ac64ee6840080c6da7cc39f5d1ce81d
|
7
|
+
data.tar.gz: 97ae51ba0bb3694e382f367deecf65ecda486679412c80c970fae1560de8253f30fcbe4eb30502cd2438e75d3cf9224a4ac4637ea91e38a2b0d2afef2d5021fd
|
data/README.md
CHANGED
@@ -10,15 +10,15 @@ packages = ParsePackwerk.all
|
|
10
10
|
# Get a single package with a given ame
|
11
11
|
package = ParsePackwerk.find('packs/my_pack')
|
12
12
|
|
13
|
-
# Get a structured `
|
14
|
-
|
13
|
+
# Get a structured `package_todo.yml` object a single package
|
14
|
+
package_todo = ParsePackwerk::PackageTodo.for(package)
|
15
15
|
|
16
16
|
# Count violations of a particular type for a package
|
17
|
-
|
18
|
-
|
17
|
+
package_todo.violations.count(&:privacy?)
|
18
|
+
package_todo.violations.count(&:dependency?)
|
19
19
|
|
20
20
|
# Get the number of files a particular constant is violated in
|
21
|
-
|
21
|
+
package_todo.violations.select { |v| v.class_name == 'SomeConstant' }.sum { |v| v.files.count }
|
22
22
|
```
|
23
23
|
|
24
24
|
# Why does this gem exist?
|
@@ -4,7 +4,7 @@ module ParsePackwerk
|
|
4
4
|
ROOT_PACKAGE_NAME = T.let('.'.freeze, String)
|
5
5
|
PACKAGE_YML_NAME = T.let('package.yml'.freeze, String)
|
6
6
|
PACKWERK_YML_NAME = T.let('packwerk.yml'.freeze, String)
|
7
|
-
|
7
|
+
PACKAGE_TODO_YML_NAME = T.let('package_todo.yml'.freeze, String)
|
8
8
|
ENFORCE_DEPENDENCIES = T.let('enforce_dependencies'.freeze, String)
|
9
9
|
ENFORCE_PRIVACY = T.let('enforce_privacy'.freeze, String)
|
10
10
|
PUBLIC_PATH = T.let('public_path'.freeze, String)
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# typed: strict
|
2
2
|
|
3
3
|
module ParsePackwerk
|
4
|
-
class
|
4
|
+
class PackageTodo < T::Struct
|
5
5
|
extend T::Sig
|
6
6
|
|
7
7
|
const :pathname, Pathname
|
8
8
|
const :violations, T::Array[Violation]
|
9
9
|
|
10
|
-
sig { params(package: Package).returns(
|
10
|
+
sig { params(package: Package).returns(PackageTodo) }
|
11
11
|
def self.for(package)
|
12
|
-
|
13
|
-
|
12
|
+
package_todo_yml_pathname = package.directory.join(PACKAGE_TODO_YML_NAME)
|
13
|
+
PackageTodo.from(package_todo_yml_pathname)
|
14
14
|
end
|
15
15
|
|
16
|
-
sig { params(pathname: Pathname).returns(
|
16
|
+
sig { params(pathname: Pathname).returns(PackageTodo) }
|
17
17
|
def self.from(pathname)
|
18
18
|
if !pathname.exist?
|
19
19
|
new(
|
@@ -21,13 +21,13 @@ module ParsePackwerk
|
|
21
21
|
violations: []
|
22
22
|
)
|
23
23
|
else
|
24
|
-
|
24
|
+
package_todo_loaded_yml = YAML.load_file(pathname)
|
25
25
|
|
26
26
|
all_violations = []
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
symbol_usage =
|
27
|
+
package_todo_loaded_yml&.each_key do |to_package_name|
|
28
|
+
package_todo_per_package = package_todo_loaded_yml[to_package_name]
|
29
|
+
package_todo_per_package.each_key do |class_name|
|
30
|
+
symbol_usage = package_todo_per_package[class_name]
|
31
31
|
files = symbol_usage['files']
|
32
32
|
violations = symbol_usage['violations']
|
33
33
|
if violations.include? 'dependency'
|
data/lib/parse_packwerk.rb
CHANGED
@@ -5,7 +5,7 @@ require 'yaml'
|
|
5
5
|
require 'pathname'
|
6
6
|
require 'parse_packwerk/constants'
|
7
7
|
require 'parse_packwerk/violation'
|
8
|
-
require 'parse_packwerk/
|
8
|
+
require 'parse_packwerk/package_todo'
|
9
9
|
require 'parse_packwerk/package'
|
10
10
|
require 'parse_packwerk/configuration'
|
11
11
|
require 'parse_packwerk/package_set'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parse_packwerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -133,9 +133,9 @@ files:
|
|
133
133
|
- lib/parse_packwerk.rb
|
134
134
|
- lib/parse_packwerk/configuration.rb
|
135
135
|
- lib/parse_packwerk/constants.rb
|
136
|
-
- lib/parse_packwerk/deprecated_references.rb
|
137
136
|
- lib/parse_packwerk/package.rb
|
138
137
|
- lib/parse_packwerk/package_set.rb
|
138
|
+
- lib/parse_packwerk/package_todo.rb
|
139
139
|
- lib/parse_packwerk/violation.rb
|
140
140
|
- sorbet/config
|
141
141
|
- sorbet/rbi/gems/hashdiff@1.0.1.rbi
|