bootinq 1.4.2 → 1.5

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: 4bbde8bd5a9047488c41a60788b57c99ffba1de61217a0e5ac6613a856e5fc66
4
- data.tar.gz: 6932d67aa5b2f484726331b5f1483352bc1f6bd535ea187dabe13d7e909630ae
3
+ metadata.gz: f1e1d6c92b8790ff798d3ac3af73aa4d1ba51d65e5d30a710e71b109dff4a1d2
4
+ data.tar.gz: ff41e0be38f693a836592446d3a8600613497595228075a325bfa3cd06a36585
5
5
  SHA512:
6
- metadata.gz: 48c42edfe5b1a4475ad65b5cec66e6a5a124073b6aea9b6fceeea94cc76ce3ddac1786c30f4c0290cbe677e40a677e4ce4350e080867d3a8032fd36a0552d12e
7
- data.tar.gz: 95db837f38266267c0fe733edcd91ad51694ff8c5a90c849e1f28335637a385cda2de1ea1c285e5a6e8f8bb5f00be2e121b5ef27bbfe9213a3ecf17e97454c22
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
@@ -37,7 +37,7 @@ require "bootinq/switch"
37
37
  # == Example <tt>config/bootinq.yml</tt>:
38
38
  #
39
39
  # env_key: BOOTINQ
40
- # default: "-f"
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
- @_value = ENV.fetch(config['env_key']) { config['default'] }
114
- @_neg = @_value.start_with?(?-, ?^)
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 @_neg ^ @_value.include?(flag)
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
- # Bottinq.switch(*parts) { block } -> nil
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.freeze
307
+ @_neg
279
308
  @flags.freeze
280
309
  @components.freeze
281
310
  super
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Bootinq
4
- VERSION = "1.4.2"
4
+ VERSION = "1.5"
5
5
  end
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.2
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-06-30 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler