bootinq 1.3.1 → 1.4.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bootinq.rb +40 -13
  3. data/lib/bootinq/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2132126092e2938ead320330a8866a61e496e47683b1a88c7ec3f8b15d3f1f2b
4
- data.tar.gz: 3eee6dabbc507a0d8234d2edc64461eddca66259b3df04c76799cbfffbbb94f8
3
+ metadata.gz: c08400508d67149e4ea7d4eeda4f33a25a5a9dd68f4ed40b79ac517f5d028ce5
4
+ data.tar.gz: c1af627b8eb2282a3fccec5c90f83d44382bdb9ffea7f81de4df95a13af747c0
5
5
  SHA512:
6
- metadata.gz: e2b45226f655ee94a841ec79f70934af6948427ba97e4a1269a4371693b9c3d50bbd9857db2b2b7a914532cc04a571176c41dbeb7f44bbd5979b4464562e5dbe
7
- data.tar.gz: cd87ee76d07175f774202a45c20875d5e1c9a18ab2e0f469e75b2d4a9039520fda537ba29d12f05f67e5e1704b8797a4296ba5c277e56da14a1982731ff7678f
6
+ metadata.gz: da561be83aff97f64a9b41084ae19a5dc0f9c4692a0e944c1c9bf2f41d16538d37fe4d35de515c01c63c5c795abccc7c54a8d6c4cb2d9964762b4d84d880c5c7
7
+ data.tar.gz: 87152bc5af6852f2b1347bab91b9a8c5f68e929266fecf214a5fe66f545a6ef3517603904ce344fdb177ae95c10d03e30ac507cabcb7aa1863718ec42c343f0f
@@ -67,28 +67,36 @@ class Bootinq
67
67
  # :call-seq:
68
68
  # Bootinq.require(*groups, verbose: false, &block)
69
69
  #
70
- # The helper method to bootstrap the Bootinq.
71
- # Sets the BOOTINQ_PATH enviroment variable if it is missing,
72
- # invokes the <tt>Bootinq.setup</tt> method with the given verbose key argument & block,
73
- # 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.
74
72
  def self.require(*groups, verbose: false, &block) # :yields: Bootinq.instance
75
- ENV['BOOTINQ_PATH'] ||= File.expand_path('../bootinq.yml', caller_locations(1..1)[0].path)
76
-
77
- setup(verbose: verbose, &block)
78
-
73
+ init(verbose: verbose, &block)
79
74
  Bundler.require(*instance.groups(*groups))
80
75
  end
81
76
 
82
77
  # :call-seq:
83
- # Bootinq.setup(verbose: false, &block) -> true or false
78
+ # Bootinq.setup(*groups, verbose: false, &block)
84
79
  #
85
- # 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.
86
92
  # Optionally yields block within the own instance's binding.
87
- 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(1..1)[0].path)
95
+
88
96
  instance
97
+ instance.instance_variable_set(:@_on_ready, block.to_proc) if block_given?
89
98
  puts "Bootinq: loading components #{instance.components.join(', ')}" if verbose
90
- instance.instance_exec(&block) if block_given?
91
- instance
99
+ instance.ready!
92
100
  end
93
101
 
94
102
  attr_reader :flags
@@ -111,6 +119,25 @@ class Bootinq
111
119
  config['mount'].each { |flag, name| enable_component(name, flag: flag, as: Mountable) }
112
120
  end
113
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
+ self
139
+ end
140
+
114
141
  # :call-seq:
115
142
  # Bootinq.enable_component(name, flag: [, as: Component])
116
143
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Bootinq
4
- VERSION = "1.3.1"
4
+ VERSION = "1.4.0"
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.3.1
4
+ version: 1.4.0
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-27 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