bootinq 1.4.2 → 1.5
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/Gemfile +8 -0
- data/lib/bootinq.rb +38 -9
- data/lib/bootinq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1e1d6c92b8790ff798d3ac3af73aa4d1ba51d65e5d30a710e71b109dff4a1d2
|
4
|
+
data.tar.gz: ff41e0be38f693a836592446d3a8600613497595228075a325bfa3cd06a36585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d003846a5991fef4e37aaf9ab72c03878eaaecb98b0b347b8ac537f4d583a880b578bda284ec1d1539396b3a822a0d72511cf349d54cb6638892052768a563
|
7
|
+
data.tar.gz: 28a35e3389f226c94126dc11adcecbdde73cb6b8b9b02876ffb987cddaec8f0d32274e3831d61ba163c64bde0eebe00c505bb0b24c7aa3032e445e840fb350dd
|
data/Gemfile
CHANGED
@@ -32,6 +32,14 @@ group :shared_boot do
|
|
32
32
|
gem 'shared', path: 'spec/dummy/engines/shared'
|
33
33
|
end
|
34
34
|
|
35
|
+
group :api_part_boot do
|
36
|
+
gem 'api_part', path: 'spec/dummy/engines/api_part'
|
37
|
+
end
|
38
|
+
|
35
39
|
group :api_boot do
|
36
40
|
gem 'api', path: 'spec/dummy/engines/api'
|
41
|
+
end
|
42
|
+
|
43
|
+
group :api2_boot do
|
44
|
+
gem 'api2', path: 'spec/dummy/engines/api2'
|
37
45
|
end
|
data/lib/bootinq.rb
CHANGED
@@ -37,7 +37,7 @@ require "bootinq/switch"
|
|
37
37
|
# == Example <tt>config/bootinq.yml</tt>:
|
38
38
|
#
|
39
39
|
# env_key: BOOTINQ
|
40
|
-
# default:
|
40
|
+
# default: a
|
41
41
|
#
|
42
42
|
# parts:
|
43
43
|
# s: :shared
|
@@ -45,6 +45,11 @@ require "bootinq/switch"
|
|
45
45
|
# mount:
|
46
46
|
# a: :api
|
47
47
|
# f: :engine
|
48
|
+
#
|
49
|
+
# deps:
|
50
|
+
# shared:
|
51
|
+
# in: af
|
52
|
+
#
|
48
53
|
class Bootinq
|
49
54
|
include Singleton
|
50
55
|
|
@@ -52,9 +57,22 @@ class Bootinq
|
|
52
57
|
"env_key" => 'BOOTINQ',
|
53
58
|
"default" => '',
|
54
59
|
"parts" => {},
|
55
|
-
"mount" => {}
|
60
|
+
"mount" => {},
|
61
|
+
"deps" => {}
|
56
62
|
}.freeze
|
57
63
|
|
64
|
+
FilterNegValue = -> (value, config) do
|
65
|
+
if value.start_with?(?-, ?^)
|
66
|
+
value = value.tr('\\-', '\\^')
|
67
|
+
flags = (config['parts'].keys + config['mount'].keys).join
|
68
|
+
[true, flags.delete(flags.delete(value))]
|
69
|
+
else
|
70
|
+
[false, value.dup]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private_constant :FilterNegValue
|
75
|
+
|
58
76
|
class << self
|
59
77
|
protected def delegated(sym) # :no-doc:
|
60
78
|
location = caller_locations(1, 1).first
|
@@ -110,13 +128,16 @@ class Bootinq
|
|
110
128
|
config = YAML.safe_load(File.read(config_path), [Symbol])
|
111
129
|
config.merge!(DEFAULT) { |_, l, r| l.nil? ? r : l }
|
112
130
|
|
113
|
-
@
|
114
|
-
@_neg
|
131
|
+
@_orig_value = ENV.fetch(config['env_key']) { config['default'] }
|
132
|
+
@_neg, @_value = FilterNegValue[@_orig_value, config]
|
133
|
+
|
134
|
+
@_deps = config['deps']
|
135
|
+
|
115
136
|
@flags = []
|
116
137
|
@components = []
|
117
138
|
|
118
|
-
config['parts'].each { |flag, name| enable_component(name, flag: flag) }
|
119
|
-
config['mount'].each { |flag, name| enable_component(name, flag: flag, as: Mountable) }
|
139
|
+
config['parts'].each { |flag, name| enable_component(name, flag: flag.to_s) }
|
140
|
+
config['mount'].each { |flag, name| enable_component(name, flag: flag.to_s, as: Mountable) }
|
120
141
|
end
|
121
142
|
|
122
143
|
delegated def ready? # :no-doc:
|
@@ -142,7 +163,7 @@ class Bootinq
|
|
142
163
|
# Bootinq.enable_component(name, flag: [, as: Component])
|
143
164
|
#
|
144
165
|
delegated def enable_component(name, flag:, as: Component)
|
145
|
-
if
|
166
|
+
if is_dependency?(name) || @_value.include?(flag)
|
146
167
|
@flags << flag
|
147
168
|
@components << as.new(name)
|
148
169
|
end
|
@@ -257,7 +278,7 @@ class Bootinq
|
|
257
278
|
end
|
258
279
|
|
259
280
|
# :call-seq:
|
260
|
-
#
|
281
|
+
# Bootinq.switch(*parts) { block } -> nil
|
261
282
|
#
|
262
283
|
# Collector method.
|
263
284
|
#
|
@@ -272,10 +293,18 @@ class Bootinq
|
|
272
293
|
nil
|
273
294
|
end
|
274
295
|
|
296
|
+
# :call-seq:
|
297
|
+
# is_dependency?(part_name) -> true or false
|
298
|
+
#
|
299
|
+
# Checks if the named component is a dependency of the enabled one.
|
300
|
+
def is_dependency?(name)
|
301
|
+
@_deps.key?(name) && @_value.count(@_deps[name]['in'].to_s) > 0
|
302
|
+
end
|
303
|
+
|
275
304
|
# Freezes every instance variables and the instance itself.
|
276
305
|
def freeze
|
277
306
|
@_value.freeze
|
278
|
-
@_neg
|
307
|
+
@_neg
|
279
308
|
@flags.freeze
|
280
309
|
@components.freeze
|
281
310
|
super
|
data/lib/bootinq/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootinq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|