packs 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/packs/private/configuration.rb +7 -6
- data/lib/packs/rspec/fixture_helper.rb +33 -0
- data/lib/packs/rspec/support.rb +21 -0
- data/lib/packs.rb +6 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59f7fd3aee7635eabbe2a66c748b1083ced17b48c020fd628825ebb47239e7d9
|
4
|
+
data.tar.gz: e6d8964d6286a7ba822c15d81cc48f18017997477349ba7b13a3628a634b93e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a566117be564c25d46e673ea53c8d8d4d6fe04948d99d919236848314e5c8bc436b7287bb1cd7ba409bcf12b910d5befb842b0c608dd6d072132c59cd0840bc6
|
7
|
+
data.tar.gz: 043c964fa23f0603c8cccbc224e4129f00d86e42a40f3746b46fc550cdfd8a0f61f5c372306ea0548b5638d158629649aa3815cf5bd3c3fe1071ad211d3eadb4
|
@@ -4,20 +4,21 @@ module Packs
|
|
4
4
|
module Private
|
5
5
|
class Configuration < T::Struct
|
6
6
|
extend T::Sig
|
7
|
+
CONFIGURATION_PATHNAME = T.let(Pathname.new('packs.yml'), Pathname)
|
8
|
+
|
7
9
|
DEFAULT_PACK_PATHS = T.let([
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
'packs/*',
|
11
|
+
'packs/*/*'
|
12
|
+
], T::Array[String])
|
11
13
|
|
12
14
|
prop :pack_paths, T::Array[String]
|
13
15
|
|
14
16
|
sig { returns(Configuration) }
|
15
17
|
def self.fetch
|
16
|
-
|
17
|
-
config_hash = configuration_path.exist? ? YAML.load_file('packs.yml') : {}
|
18
|
+
config_hash = CONFIGURATION_PATHNAME.exist? ? YAML.load_file(CONFIGURATION_PATHNAME) : {}
|
18
19
|
|
19
20
|
new(
|
20
|
-
pack_paths: pack_paths(config_hash)
|
21
|
+
pack_paths: pack_paths(config_hash)
|
21
22
|
)
|
22
23
|
end
|
23
24
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module FixtureHelper
|
5
|
+
extend T::Sig
|
6
|
+
|
7
|
+
sig { params(path: String, content: String).returns(String) }
|
8
|
+
def write_file(path, content = '')
|
9
|
+
pathname = Pathname.pwd.join(path)
|
10
|
+
FileUtils.mkdir_p(pathname.dirname)
|
11
|
+
pathname.write(content)
|
12
|
+
path
|
13
|
+
end
|
14
|
+
|
15
|
+
sig do
|
16
|
+
params(
|
17
|
+
pack_name: String,
|
18
|
+
config: T::Hash[T.untyped, T.untyped]
|
19
|
+
).void
|
20
|
+
end
|
21
|
+
def write_pack(
|
22
|
+
pack_name,
|
23
|
+
config = {}
|
24
|
+
)
|
25
|
+
path = Pathname.pwd.join(pack_name).join('package.yml')
|
26
|
+
write_file(path.to_s, YAML.dump(config))
|
27
|
+
end
|
28
|
+
|
29
|
+
sig { params(path: String).void }
|
30
|
+
def delete_app_file(path)
|
31
|
+
File.delete(path)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'fixture_helper'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.include FixtureHelper
|
5
|
+
|
6
|
+
config.before do
|
7
|
+
# We bust_cache always because each test may write its own packs
|
8
|
+
Packs.bust_cache!
|
9
|
+
end
|
10
|
+
|
11
|
+
# Eventually, we could make this opt-in via metadata so someone can use this support without affecting all their tests.
|
12
|
+
config.around do |example|
|
13
|
+
prefix = [File.basename($0), Process.pid].join('-') # rubocop:disable Style/SpecialGlobalVars
|
14
|
+
tmpdir = Dir.mktmpdir(prefix)
|
15
|
+
Dir.chdir(tmpdir) do
|
16
|
+
example.run
|
17
|
+
end
|
18
|
+
ensure
|
19
|
+
FileUtils.rm_rf(tmpdir)
|
20
|
+
end
|
21
|
+
end
|
data/lib/packs.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# typed: strict
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
+
require 'pathname'
|
4
5
|
require 'sorbet-runtime'
|
5
6
|
require 'packs/pack'
|
6
7
|
require 'packs/private'
|
7
8
|
|
8
9
|
module Packs
|
9
10
|
PACKAGE_FILE = T.let('package.yml'.freeze, String)
|
10
|
-
ROOTS = T.let(%w[packs components], T::Array[String])
|
11
11
|
|
12
12
|
class << self
|
13
13
|
extend T::Sig
|
@@ -45,6 +45,11 @@ module Packs
|
|
45
45
|
|
46
46
|
sig { params(blk: T.proc.params(arg0: Private::Configuration).void).void }
|
47
47
|
def configure(&blk)
|
48
|
+
# If packs.yml is being used, then ignore direct configuration.
|
49
|
+
# This is only a stop-gap to permit Stimpack users to more easily migrate
|
50
|
+
# to packs.yml
|
51
|
+
return if Private::Configuration::CONFIGURATION_PATHNAME.exist?
|
52
|
+
|
48
53
|
yield(config)
|
49
54
|
end
|
50
55
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
@@ -121,6 +121,8 @@ files:
|
|
121
121
|
- lib/packs/pack.rb
|
122
122
|
- lib/packs/private.rb
|
123
123
|
- lib/packs/private/configuration.rb
|
124
|
+
- lib/packs/rspec/fixture_helper.rb
|
125
|
+
- lib/packs/rspec/support.rb
|
124
126
|
homepage: https://github.com/rubyatscale/packs
|
125
127
|
licenses:
|
126
128
|
- MIT
|