packs 0.0.2 → 0.0.3

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: 4f911f00f2059f8b472edbfbe099fe0ee0586bb8426c8593d002fb7a0f4e9924
4
+ data.tar.gz: fc62651af9566195f83822938122f418ed7dd5cab115a3a27ee91fb4416724f9
5
5
  SHA512:
6
- metadata.gz: 29a0c8a277e0ae42061219e86ab7371dcd014e3649e3728db0d166f98c30ad430ad04a9d8cec82d862e34e075a12dbaf4ae4b96e4f77e97addfc01881762cf8f
7
- data.tar.gz: c9dccdac635c403f4a0ec2f305bf9947b7ca2b96ef943ae2088888e3b2a553743f19baae48b0451c574b69abda8de2c71275de6ce6637767640a0e6f431479a2
6
+ metadata.gz: 4a39af86905f7d639e98938eb83fd45d898a60991cae834d48365da60785dd1dc75b935eced72fa02da1f766382c5cbf817e4337047fbc7b5df66a1ca4853326
7
+ data.tar.gz: d66b67aa6a4b35bccf554390aa5dc23d9ac109dfba0fffe0100ac7d35152afbc6974034c3bbde61d6bcf3278e2a05f28266ea1f3d44614659629beb381704983
@@ -0,0 +1,35 @@
1
+ # typed: strict
2
+
3
+ module Packs
4
+ module Private
5
+ class Configuration < T::Struct
6
+ extend T::Sig
7
+ DEFAULT_PACK_PATHS = T.let([
8
+ 'packs/*',
9
+ 'packs/*/*',
10
+ ], T::Array[String])
11
+
12
+ prop :pack_paths, T::Array[String]
13
+
14
+ sig { returns(Configuration) }
15
+ def self.fetch
16
+ configuration_path = Pathname.new('packs.yml')
17
+ config_hash = configuration_path.exist? ? YAML.load_file('packs.yml') : {}
18
+
19
+ new(
20
+ pack_paths: pack_paths(config_hash),
21
+ )
22
+ end
23
+
24
+ sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[String]) }
25
+ def self.pack_paths(config_hash)
26
+ specified_pack_paths = config_hash['pack_paths']
27
+ if specified_pack_paths.nil?
28
+ DEFAULT_PACK_PATHS.dup
29
+ else
30
+ Array(specified_pack_paths)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ 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,7 +3,6 @@
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
@@ -38,6 +37,17 @@ module Packs
38
37
  @for_file = nil
39
38
  end
40
39
 
40
+ sig { returns(Private::Configuration) }
41
+ def config
42
+ @config = T.let(@config, T.nilable(Private::Configuration))
43
+ @config ||= Private::Configuration.fetch
44
+ end
45
+
46
+ sig { params(blk: T.proc.params(arg0: Private::Configuration).void).void }
47
+ def configure(&blk)
48
+ yield(config)
49
+ end
50
+
41
51
  private
42
52
 
43
53
  sig { returns(T::Hash[String, Pack]) }
@@ -56,12 +66,9 @@ module Packs
56
66
 
57
67
  sig { returns(T::Array[Pathname]) }
58
68
  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
- ]
69
+ absolute_root = Private.root
70
+ config.pack_paths.flat_map do |pack_path|
71
+ Pathname.glob(absolute_root.join(pack_path).join(PACKAGE_FILE))
65
72
  end
66
73
  end
67
74
  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.3
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