packs-specification 0.0.9 → 0.0.11
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 +4 -4
- data/README.md +20 -19
- data/lib/packs/pack.rb +38 -9
- data/lib/packs/rspec/support.rb +13 -5
- metadata +26 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 122afd26ffb01ea123411f9efecf42dfd3773ceb65f77bd961788284ad3b16db
|
|
4
|
+
data.tar.gz: d48b1a2e41405ca2c8d5d0abd99e2f75e171ea4e27cbf498a40a8b297c45d2d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54dd61ad4422dd16b24143d3c82e4f18e4062e61eb0d95311aad3fb14cb34125a978dad366907cc937c612bbd3aa98ee3ab4d4bd2d57805c83995b416b107ada
|
|
7
|
+
data.tar.gz: edd3354022070ee6bf9a8c54050a2e1cd76ded04f434fc34bb9bb6af176dd90ca07eb47a988db9e714732777156fdfdef658b0c6e1e6531366ec003644983f9e
|
data/README.md
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
# packs-specification
|
|
2
|
+
This is a low-dependency gem that allows your production environment to query simple information about [`packs`](https://github.com/rubyatscale/packs).
|
|
2
3
|
|
|
3
|
-
Welcome to `packs-specification`! `packs` are a simple ruby specification for an extensible packaging system to help modularize Ruby applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Usage
|
|
6
|
+
```ruby
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
By default, this library will look for `packs` in the folder `packs/*/package.yml` (as well as nested packs at `packs/*/*/package.yml`). To change where `packs` are located, create a `packs.yml` file:
|
|
9
|
-
```
|
|
10
|
-
pack_paths:
|
|
11
|
-
- "{packs,utilities,deprecated}/*" # packs with multiple roots!
|
|
12
|
-
- "{packs,utilities,deprecated}/*/*" # nested packs!
|
|
13
|
-
- gems/* # gems can be packs too!
|
|
14
|
-
```
|
|
8
|
+
require 'packs-specification'
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- [`code_ownership`](https://github.com/rubyatscale/code_ownership) gives your application the capability to determine the owner of a pack
|
|
21
|
-
- [`use_packs`](https://github.com/rubyatscale/use_packs) gives a CLI, `bin/packs`, that makes it easy to create new packs, move files between packs, and more.
|
|
22
|
-
- [`pack_stats`](https://github.com/rubyatscale/pack_stats) makes it easy to send metrics about pack adoption and modularization to your favorite metrics provider, such as DataDog (which has built-in support).
|
|
10
|
+
# Getting all packs
|
|
11
|
+
# Example use: adding pack paths to a list of fixture paths
|
|
12
|
+
# Returns a T::Array[Packs::Pack]
|
|
13
|
+
Packs.all
|
|
23
14
|
|
|
24
|
-
#
|
|
25
|
-
|
|
15
|
+
# Getting the pack for a specific file
|
|
16
|
+
# Example use: Associating a file with an owner via a pack owner
|
|
17
|
+
# Returns a T.nilable(Packs::Pack)
|
|
18
|
+
Packs.for_file('/path/to/file.rb')
|
|
19
|
+
Packs.for_file(Pathname.new('/path/to/file.rb')) # also works
|
|
20
|
+
|
|
21
|
+
# Getting a pack with a specific name
|
|
22
|
+
# Example use: Special casing certain behavior for a specific pack
|
|
23
|
+
# Example use: Development tools that operate on user inputted pack names
|
|
24
|
+
# Returns a T.nilable(Packs::Pack)
|
|
25
|
+
Packs.find('packs/my_pack')
|
|
26
|
+
```
|
data/lib/packs/pack.rb
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
|
|
3
3
|
module Packs
|
|
4
|
-
class Pack
|
|
4
|
+
class Pack
|
|
5
5
|
extend T::Sig
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
sig { returns(String) }
|
|
8
|
+
attr_reader :name
|
|
9
|
+
|
|
10
|
+
sig { returns(Pathname) }
|
|
11
|
+
attr_reader :path
|
|
12
|
+
|
|
13
|
+
sig { returns(Pathname) }
|
|
14
|
+
attr_reader :relative_path
|
|
15
|
+
|
|
16
|
+
sig { params(name: String, path: Pathname, relative_path: Pathname).void }
|
|
17
|
+
def initialize(name:, path:, relative_path:)
|
|
18
|
+
@name = name
|
|
19
|
+
@path = path
|
|
20
|
+
@relative_path = relative_path
|
|
21
|
+
@raw_hash = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
|
|
22
|
+
@is_gem = T.let(nil, T.nilable(T::Boolean))
|
|
23
|
+
end
|
|
11
24
|
|
|
12
25
|
sig { params(package_yml_absolute_path: Pathname).returns(Pack) }
|
|
13
26
|
def self.from(package_yml_absolute_path)
|
|
14
|
-
package_loaded_yml = YAML.load_file(package_yml_absolute_path)
|
|
15
27
|
path = package_yml_absolute_path.dirname
|
|
16
28
|
relative_path = path.relative_path_from(Specification.root)
|
|
17
29
|
package_name = relative_path.cleanpath.to_s
|
|
@@ -19,11 +31,15 @@ module Packs
|
|
|
19
31
|
Pack.new(
|
|
20
32
|
name: package_name,
|
|
21
33
|
path: path,
|
|
22
|
-
relative_path: relative_path
|
|
23
|
-
raw_hash: package_loaded_yml || {}
|
|
34
|
+
relative_path: relative_path
|
|
24
35
|
)
|
|
25
36
|
end
|
|
26
37
|
|
|
38
|
+
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
|
39
|
+
def raw_hash
|
|
40
|
+
@raw_hash ||= YAML.load_file(yml(relative: false)) || {}
|
|
41
|
+
end
|
|
42
|
+
|
|
27
43
|
sig { params(relative: T::Boolean).returns(Pathname) }
|
|
28
44
|
def yml(relative: true)
|
|
29
45
|
path_to_use = relative ? relative_path : path
|
|
@@ -37,12 +53,25 @@ module Packs
|
|
|
37
53
|
|
|
38
54
|
sig { returns(T::Boolean) }
|
|
39
55
|
def is_gem? # rubocop:disable Naming/PredicateName
|
|
40
|
-
@is_gem ||=
|
|
56
|
+
@is_gem ||= relative_path.glob('*.gemspec').any?
|
|
41
57
|
end
|
|
42
58
|
|
|
43
59
|
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
|
44
60
|
def metadata
|
|
45
61
|
raw_hash['metadata'] || {}
|
|
46
62
|
end
|
|
63
|
+
|
|
64
|
+
sig { returns(T::Array[Symbol]) }
|
|
65
|
+
private def instance_variables_to_inspect = [:@name]
|
|
66
|
+
|
|
67
|
+
if RUBY_VERSION < '4'
|
|
68
|
+
sig { returns(String) }
|
|
69
|
+
def inspect
|
|
70
|
+
ivars = instance_variables_to_inspect.map do |ivar|
|
|
71
|
+
"#{ivar}=#{instance_variable_get(ivar).inspect}"
|
|
72
|
+
end.join(', ')
|
|
73
|
+
"#<#{self.class.name}:0x#{object_id.to_s(16)} #{ivars}>"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
47
76
|
end
|
|
48
77
|
end
|
data/lib/packs/rspec/support.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'tmpdir'
|
|
1
3
|
require_relative 'fixture_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.configure do |config|
|
|
@@ -10,12 +12,18 @@ RSpec.configure do |config|
|
|
|
10
12
|
|
|
11
13
|
# Eventually, we could make this opt-in via metadata so someone can use this support without affecting all their tests.
|
|
12
14
|
config.around do |example|
|
|
13
|
-
|
|
14
|
-
tmpdir = Dir.mktmpdir(prefix)
|
|
15
|
-
Dir.chdir(tmpdir) do
|
|
15
|
+
if example.metadata[:skip_chdir_to_tmpdir]
|
|
16
16
|
example.run
|
|
17
|
+
else
|
|
18
|
+
begin
|
|
19
|
+
prefix = [File.basename($0), Process.pid].join('-') # rubocop:disable Style/SpecialGlobalVars
|
|
20
|
+
tmpdir = Dir.mktmpdir(prefix)
|
|
21
|
+
Dir.chdir(tmpdir) do
|
|
22
|
+
example.run
|
|
23
|
+
end
|
|
24
|
+
ensure
|
|
25
|
+
FileUtils.rm_rf(tmpdir)
|
|
26
|
+
end
|
|
17
27
|
end
|
|
18
|
-
ensure
|
|
19
|
-
FileUtils.rm_rf(tmpdir)
|
|
20
28
|
end
|
|
21
29
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: packs-specification
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gusto Engineers
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: sorbet-runtime
|
|
@@ -28,16 +27,30 @@ dependencies:
|
|
|
28
27
|
name: bundler
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
32
|
+
version: '0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: debug
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
41
54
|
- !ruby/object:Gem::Dependency
|
|
42
55
|
name: rake
|
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -56,16 +69,16 @@ dependencies:
|
|
|
56
69
|
name: rspec
|
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
|
58
71
|
requirements:
|
|
59
|
-
- - "
|
|
72
|
+
- - ">="
|
|
60
73
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
74
|
+
version: '0'
|
|
62
75
|
type: :development
|
|
63
76
|
prerelease: false
|
|
64
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
78
|
requirements:
|
|
66
|
-
- - "
|
|
79
|
+
- - ">="
|
|
67
80
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
81
|
+
version: '0'
|
|
69
82
|
- !ruby/object:Gem::Dependency
|
|
70
83
|
name: rubocop
|
|
71
84
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -130,7 +143,6 @@ metadata:
|
|
|
130
143
|
source_code_uri: https://github.com/rubyatscale/packs-specification
|
|
131
144
|
changelog_uri: https://github.com/rubyatscale/packs-specification/releases
|
|
132
145
|
allowed_push_host: https://rubygems.org
|
|
133
|
-
post_install_message:
|
|
134
146
|
rdoc_options: []
|
|
135
147
|
require_paths:
|
|
136
148
|
- lib
|
|
@@ -138,15 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
138
150
|
requirements:
|
|
139
151
|
- - ">="
|
|
140
152
|
- !ruby/object:Gem::Version
|
|
141
|
-
version: '
|
|
153
|
+
version: '3.1'
|
|
142
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
155
|
requirements:
|
|
144
156
|
- - ">="
|
|
145
157
|
- !ruby/object:Gem::Version
|
|
146
158
|
version: '0'
|
|
147
159
|
requirements: []
|
|
148
|
-
rubygems_version: 3.
|
|
149
|
-
signing_key:
|
|
160
|
+
rubygems_version: 3.6.9
|
|
150
161
|
specification_version: 4
|
|
151
162
|
summary: The specification for packs in the `rubyatscale` ecosystem.
|
|
152
163
|
test_files: []
|