packs 0.0.40 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3317999d00b6c772ba2272a52813b945647c0699abd927f2ab95373e69f5204a
4
- data.tar.gz: c7c35f6160a0d9288551ba87c73daba9d186490c26cbba0726b875e0a833d14b
3
+ metadata.gz: 6ffe5dc9bf38dcea0c7eb2bf1091c5ea162d04a2a8551f2a4198d3b60acfe878
4
+ data.tar.gz: 2c74caaac69bcc7ad850c940f25254995333d4dcb144d779b6302872a1365cb1
5
5
  SHA512:
6
- metadata.gz: aa0c6ccb60434cc1e732d91ac114c2b16cde61d0d114112aa66dea8c67c79afa42fe881bf6d213621208b7897545e98bf585fe4edd496ee6a6fc2c34e692fe65
7
- data.tar.gz: f96feabe77b1b8a648404270101f9d767f81a3daa3800f067f4e02c273dbfb19df484c4a6c8f3114bbc06e79ed7ebfe779b48775adb706146b236c94f18869d4
6
+ metadata.gz: 6ba2df6056b91420e64b222c8a23e233634612bc0e1be4b249775892ce5be947523b1c9bd1665eadc5a9e7658e976be228912ec07ca55d64aa318eeb9fc39eab
7
+ data.tar.gz: 84235f58a2c5e5ddb106761bd4a2a312a6d3118af539f5f1ab9e09bc194f78dcc5f614b914450e6e6254c8f2b1e8989a265654a32b07b6e199ff25ce8f0a7559
@@ -9,34 +9,38 @@ module Packs
9
9
  const :destination_pathname, Pathname
10
10
  const :destination_pack, ParsePackwerk::Package
11
11
 
12
- sig { returns(ParsePackwerk::Package) }
12
+ sig { returns(T.nilable(Packs::Pack)) }
13
13
  def origin_pack
14
- ParsePackwerk.package_from_path(origin_pathname)
14
+ self.class.get_origin_pack(origin_pathname)
15
+ end
16
+
17
+ sig { params(origin_pathname: Pathname).returns(T.nilable(Packs::Pack)) }
18
+ def self.get_origin_pack(origin_pathname)
19
+ Packs.for_file(origin_pathname)
15
20
  end
16
21
 
17
22
  sig { params(origin_pathname: Pathname, new_package_root: Pathname).returns(Pathname) }
18
23
  def self.destination_pathname_for_package_move(origin_pathname, new_package_root)
19
- origin_pack = ParsePackwerk.package_from_path(origin_pathname)
20
-
21
- if origin_pack.name == ParsePackwerk::ROOT_PACKAGE_NAME
22
- new_package_root.join(origin_pathname).cleanpath
23
- else
24
+ origin_pack = get_origin_pack(origin_pathname)
25
+ if origin_pack
24
26
  Pathname.new(origin_pathname.to_s.gsub(origin_pack.name, new_package_root.to_s)).cleanpath
27
+ else
28
+ new_package_root.join(origin_pathname).cleanpath
25
29
  end
26
30
  end
27
31
 
28
32
  sig { params(origin_pathname: Pathname).returns(Pathname) }
29
33
  def self.destination_pathname_for_new_public_api(origin_pathname)
30
- origin_pack = ParsePackwerk.package_from_path(origin_pathname)
31
- if origin_pack.name == ParsePackwerk::ROOT_PACKAGE_NAME
32
- filepath_without_pack_name = origin_pathname.to_s
33
- else
34
+ origin_pack = get_origin_pack(origin_pathname)
35
+ if origin_pack
34
36
  filepath_without_pack_name = origin_pathname.to_s.gsub("#{origin_pack.name}/", '')
37
+ else
38
+ filepath_without_pack_name = origin_pathname.to_s
35
39
  end
36
40
 
37
41
  # We join the pack name with the rest of the path...
38
42
  path_parts = filepath_without_pack_name.split('/')
39
- Pathname.new(origin_pack.name).join(
43
+ Pathname.new(origin_pack&.name || ParsePackwerk::ROOT_PACKAGE_NAME).join(
40
44
  # ... keeping the "app" or "spec"
41
45
  T.must(path_parts[0]),
42
46
  # ... substituting "controllers," "services," etc. with "public"
@@ -15,7 +15,7 @@ module Packs
15
15
  def after_move_files!(file_move_operations)
16
16
  return if file_move_operations.empty?
17
17
 
18
- origin_pack = T.must(file_move_operations.first).origin_pack.name
18
+ origin_pack = T.must(file_move_operations.first).origin_pack&.name || ParsePackwerk::ROOT_PACKAGE_NAME
19
19
  destination_pack = T.must(file_move_operations.first).destination_pack.name
20
20
 
21
21
  if self.class.ripgrep_enabled?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.40
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal