bootinq 1.2.0 → 1.4.2

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: 266e204b1e16ba81aaaf17e2ab6b638f2c33b1717a9c728e65332b6b2274e98d
4
- data.tar.gz: 0f8210ddf0aae40d21ccc68b3964df30b7102ea35cb76c04779e3a2f48d0f9dd
3
+ metadata.gz: 4bbde8bd5a9047488c41a60788b57c99ffba1de61217a0e5ac6613a856e5fc66
4
+ data.tar.gz: 6932d67aa5b2f484726331b5f1483352bc1f6bd535ea187dabe13d7e909630ae
5
5
  SHA512:
6
- metadata.gz: d8d3172c9a7a38e335585b0b1a35dc7bdaccbb993076095cd414a317f891d0506e6b0995b5e7eb4cdea9f885553658cd175219273a788db797994d63eca59a44
7
- data.tar.gz: 182655c54c91a0a4cac2d7c17e5750e59e8941309a9ce492faddc1204f30e72a90c847f5e48e23ffb549cc9dc60ad4ed0c0b064eb92348960a6b85286380321b
6
+ metadata.gz: 48c42edfe5b1a4475ad65b5cec66e6a5a124073b6aea9b6fceeea94cc76ce3ddac1786c30f4c0290cbe677e40a677e4ce4350e080867d3a8032fd36a0552d12e
7
+ data.tar.gz: 95db837f38266267c0fe733edcd91ad51694ff8c5a90c849e1f28335637a385cda2de1ea1c285e5a6e8f8bb5f00be2e121b5ef27bbfe9213a3ecf17e97454c22
@@ -4,6 +4,7 @@ require "yaml"
4
4
  require "singleton"
5
5
  require "forwardable"
6
6
  require "bootinq/component"
7
+ require "bootinq/switch"
7
8
 
8
9
  # = Bootinq
9
10
  #
@@ -66,28 +67,36 @@ class Bootinq
66
67
  # :call-seq:
67
68
  # Bootinq.require(*groups, verbose: false, &block)
68
69
  #
69
- # The helper method to bootstrap the Bootinq.
70
- # Sets the BOOTINQ_PATH enviroment variable if it is missing,
71
- # invokes the <tt>Bootinq.setup</tt> method with the given verbose key argument & block,
72
- # and, finally, gets Bundler to require the given groups.
70
+ # Invokes the <tt>Bootinq.init</tt> method with the given verbose key argument & block,
71
+ # and, finally, makes Bundler to require the given groups.
73
72
  def self.require(*groups, verbose: false, &block) # :yields: Bootinq.instance
74
- ENV['BOOTINQ_PATH'] ||= File.expand_path('../bootinq.yml', caller_locations(1..1)[0].path)
75
-
76
- setup(verbose: verbose, &block)
77
-
73
+ init(verbose: verbose, &block)
78
74
  Bundler.require(*instance.groups(*groups))
79
75
  end
80
76
 
81
77
  # :call-seq:
82
- # Bootinq.setup(verbose: false, &block) -> true or false
78
+ # Bootinq.setup(*groups, verbose: false, &block)
83
79
  #
84
- # Initializes itself. To track inquired components use <tt>verbose: true</tt> key argument.
80
+ # Invokes the <tt>Bootinq.init</tt> method with the given verbose key argument & block,
81
+ # and, finally, makes Bundler to setup the given groups.
82
+ def self.setup(*groups, verbose: false, &block) # :yields: Bootinq.instance
83
+ init(verbose: verbose, &block)
84
+ Bundler.setup(*instance.groups(*groups))
85
+ end
86
+
87
+ # :call-seq:
88
+ # Bootinq.init(verbose: false, &block) -> true or false
89
+ #
90
+ # Initializes itself. Sets the BOOTINQ_PATH enviroment variable if it is missing.
91
+ # To track inquired components use <tt>verbose: true</tt> key argument.
85
92
  # Optionally yields block within the own instance's binding.
86
- def self.setup(verbose: false, &block) # :yields: Bootinq.instance
93
+ def self.init(verbose: false, &block) # :yields: Bootinq.instance
94
+ ENV['BOOTINQ_PATH'] ||= File.expand_path('../bootinq.yml', caller_locations(2, 1)[0].path)
95
+
87
96
  instance
97
+ instance.instance_variable_set(:@_on_ready, block.to_proc) if block_given?
88
98
  puts "Bootinq: loading components #{instance.components.join(', ')}" if verbose
89
- instance.instance_exec(&block) if block_given?
90
- instance
99
+ instance.ready!
91
100
  end
92
101
 
93
102
  attr_reader :flags
@@ -110,6 +119,25 @@ class Bootinq
110
119
  config['mount'].each { |flag, name| enable_component(name, flag: flag, as: Mountable) }
111
120
  end
112
121
 
122
+ delegated def ready? # :no-doc:
123
+ !!@ready
124
+ end
125
+
126
+ # :call-seq:
127
+ # Bootinq.ready! -> nil or self
128
+ #
129
+ # At the first call marks Bootinq as ready and returns the instance,
130
+ # otherwise returns nil.
131
+ delegated def ready!
132
+ return if ready?
133
+ @ready = true
134
+ if defined?(@_on_ready)
135
+ instance_exec(&@_on_ready)
136
+ remove_instance_variable :@_on_ready
137
+ end
138
+ freeze
139
+ end
140
+
113
141
  # :call-seq:
114
142
  # Bootinq.enable_component(name, flag: [, as: Component])
115
143
  #
@@ -228,6 +256,22 @@ class Bootinq
228
256
  is_matched
229
257
  end
230
258
 
259
+ # :call-seq:
260
+ # Bottinq.switch(*parts) { block } -> nil
261
+ #
262
+ # Collector method.
263
+ #
264
+ # Example:
265
+ #
266
+ # Bootinq.switch do |part|
267
+ # part.frontend { … }
268
+ # part.backend { … }
269
+ # end
270
+ delegated def switch # :yields: Bootinq::Switch.new
271
+ yield(Switch.new)
272
+ nil
273
+ end
274
+
231
275
  # Freezes every instance variables and the instance itself.
232
276
  def freeze
233
277
  @_value.freeze
@@ -236,10 +280,4 @@ class Bootinq
236
280
  @components.freeze
237
281
  super
238
282
  end
239
-
240
- def self.new
241
- super.freeze
242
- end
243
-
244
- private_class_method :new
245
283
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Bootinq
4
+ class Switch < ::BasicObject # :no-doc:
5
+ undef_method :==
6
+ undef_method :equal?
7
+
8
+ def raise(*args) # :no-doc:
9
+ ::Object.send(:raise, *args)
10
+ end
11
+
12
+ def method_missing(name, *)
13
+ if ::Bootinq.enabled?(name)
14
+ yield()
15
+ else
16
+ nil
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Bootinq
4
- VERSION = "1.2.0"
4
+ VERSION = "1.4.2"
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.2.0
4
+ version: 1.4.2
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-24 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,6 +58,7 @@ files:
58
58
  - lib/bootinq.rb
59
59
  - lib/bootinq.yml
60
60
  - lib/bootinq/component.rb
61
+ - lib/bootinq/switch.rb
61
62
  - lib/bootinq/version.rb
62
63
  homepage: https://github.com/estum/bootinq
63
64
  licenses:
@@ -78,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
79
  - !ruby/object:Gem::Version
79
80
  version: '0'
80
81
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.7.6
82
+ rubygems_version: 3.0.3
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Rails Boot Inquirer