packs 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29e18f23de09397b4441c88789b231d1226bd68bea5d0fce16655d0367f93b9b
4
- data.tar.gz: bfd5b5aefd4de2aa8b126accd52c44a980ca1302a57c49d6faf37a969ca2d1f5
3
+ metadata.gz: 7080a6fa5987fd5e6526b429e393cf5a8c0880f949dc5ebcd7a151479f1b3683
4
+ data.tar.gz: bd4c0fe1047832ba6ecd4277368f7b3effd5f1f97143155ff0f2b3f0d472816d
5
5
  SHA512:
6
- metadata.gz: 29a0c8a277e0ae42061219e86ab7371dcd014e3649e3728db0d166f98c30ad430ad04a9d8cec82d862e34e075a12dbaf4ae4b96e4f77e97addfc01881762cf8f
7
- data.tar.gz: c9dccdac635c403f4a0ec2f305bf9947b7ca2b96ef943ae2088888e3b2a553743f19baae48b0451c574b69abda8de2c71275de6ce6637767640a0e6f431479a2
6
+ metadata.gz: 6ee749052a37b250094beba396462274948e7a8964267eccbd76a256390a50af7ee3be33b1e1bf391ace03b2007175b51a35a4d99e6f3c407c354ff889ac2803
7
+ data.tar.gz: adeb079802b6711e84f6b9860d3d128aee2d805c801f09c26eeed9d8836e8216302c0d03abb7a2f201ee96556c0c717af294e270ea72cc4d67b68bb742286d2b
@@ -0,0 +1,36 @@
1
+ # typed: strict
2
+
3
+ module Packs
4
+ module Private
5
+ class Configuration < T::Struct
6
+ extend T::Sig
7
+ CONFIGURATION_PATHNAME = T.let(Pathname.new('packs.yml'), Pathname)
8
+
9
+ DEFAULT_PACK_PATHS = T.let([
10
+ 'packs/*',
11
+ 'packs/*/*'
12
+ ], T::Array[String])
13
+
14
+ prop :pack_paths, T::Array[String]
15
+
16
+ sig { returns(Configuration) }
17
+ def self.fetch
18
+ config_hash = CONFIGURATION_PATHNAME.exist? ? YAML.load_file(CONFIGURATION_PATHNAME) : {}
19
+
20
+ new(
21
+ pack_paths: pack_paths(config_hash)
22
+ )
23
+ end
24
+
25
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[String]) }
26
+ def self.pack_paths(config_hash)
27
+ specified_pack_paths = config_hash['pack_paths']
28
+ if specified_pack_paths.nil?
29
+ DEFAULT_PACK_PATHS.dup
30
+ else
31
+ Array(specified_pack_paths)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/packs/private.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # typed: strict
2
2
 
3
+ require 'packs/private/configuration'
4
+
3
5
  module Packs
4
6
  module Private
5
7
  extend T::Sig
data/lib/packs.rb CHANGED
@@ -3,12 +3,10 @@
3
3
  require 'yaml'
4
4
  require 'sorbet-runtime'
5
5
  require 'packs/pack'
6
- require 'packs/configuration'
7
6
  require 'packs/private'
8
7
 
9
8
  module Packs
10
9
  PACKAGE_FILE = T.let('package.yml'.freeze, String)
11
- ROOTS = T.let(%w[packs components], T::Array[String])
12
10
 
13
11
  class << self
14
12
  extend T::Sig
@@ -38,6 +36,22 @@ module Packs
38
36
  @for_file = nil
39
37
  end
40
38
 
39
+ sig { returns(Private::Configuration) }
40
+ def config
41
+ @config = T.let(@config, T.nilable(Private::Configuration))
42
+ @config ||= Private::Configuration.fetch
43
+ end
44
+
45
+ sig { params(blk: T.proc.params(arg0: Private::Configuration).void).void }
46
+ def configure(&blk)
47
+ # If packs.yml is being used, then ignore direct configuration.
48
+ # This is only a stop-gap to permit Stimpack users to more easily migrate
49
+ # to packs.yml
50
+ return if Private::Configuration::CONFIGURATION_PATHNAME.exist?
51
+
52
+ yield(config)
53
+ end
54
+
41
55
  private
42
56
 
43
57
  sig { returns(T::Hash[String, Pack]) }
@@ -56,12 +70,9 @@ module Packs
56
70
 
57
71
  sig { returns(T::Array[Pathname]) }
58
72
  def package_glob_patterns
59
- config.roots.flat_map do |root|
60
- absolute_root = Private.root.join(root)
61
- [
62
- *absolute_root.glob("*/#{PACKAGE_FILE}"),
63
- *absolute_root.glob("*/*/#{PACKAGE_FILE}")
64
- ]
73
+ absolute_root = Private.root
74
+ config.pack_paths.flat_map do |pack_path|
75
+ Pathname.glob(absolute_root.join(pack_path).join(PACKAGE_FILE))
65
76
  end
66
77
  end
67
78
  end
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.2
4
+ version: 0.0.4
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-12-21 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -118,9 +118,9 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - README.md
120
120
  - lib/packs.rb
121
- - lib/packs/configuration.rb
122
121
  - lib/packs/pack.rb
123
122
  - lib/packs/private.rb
123
+ - lib/packs/private/configuration.rb
124
124
  homepage: https://github.com/rubyatscale/packs
125
125
  licenses:
126
126
  - MIT
@@ -1,37 +0,0 @@
1
- # typed: strict
2
-
3
- module Packs
4
- class Configuration
5
- extend T::Sig
6
-
7
- sig { params(roots: T::Array[String]).void }
8
- attr_writer :roots
9
-
10
- sig { void }
11
- def initialize
12
- @roots = T.let(ROOTS, T::Array[String])
13
- end
14
-
15
- sig { returns(T::Array[Pathname]) }
16
- def roots
17
- @roots.map do |root|
18
- Pathname.new(root)
19
- end
20
- end
21
- end
22
-
23
- class << self
24
- extend T::Sig
25
-
26
- sig { returns(Configuration) }
27
- def config
28
- @config = T.let(@config, T.nilable(Configuration))
29
- @config ||= Configuration.new
30
- end
31
-
32
- sig { params(blk: T.proc.params(arg0: Configuration).void).void }
33
- def configure(&blk)
34
- yield(config)
35
- end
36
- end
37
- end