bootinq 0.5.0 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7902442d51cbd75049e152e1e7c4097c7f9d8d1f
4
- data.tar.gz: 66efaa0d93126ee982e8a6fdad02f3fbe54de614
3
+ metadata.gz: 729bf1c9b83d3e11258f451f220542d46836ffc9
4
+ data.tar.gz: fc860ed30c15acc2046e2e33074d4097004aa4fc
5
5
  SHA512:
6
- metadata.gz: e68317bb8356171fbe0aac37eb41e64c64d7133791bf5d4dc92bacc394d2ea58d157af1f9d71d3e2c1b431ab0f43a66ec30b3eba6cf4c3e3ecb05877b1f16a0e
7
- data.tar.gz: 930826fe693f9ad2bea46b8e6ca7a795dc4afc417476e925f5597814748a5cce2bae6056776682d0447ee8a7030afa194787473c9c98ebd0643778c13d03a349
6
+ metadata.gz: f2aa46cef37e5b173a9efb010bbc3fcc616f324ddb8ed52938e8303ab400ff707baf6bddfa3135b918c7adcf791463c59021a257efa0589b8888435877d0c2ae
7
+ data.tar.gz: b1f55595d4f7611014c547831d1b34b5dae00ba479802099de799f732b2665afefb94ecb9ae7377b6b355a427c568957eeffc9783e4cf26dca0dcb8d6747b3c3
@@ -1,6 +1,6 @@
1
1
  class Bootinq
2
2
  class Component
3
- attr_reader :intern, :id2name
3
+ attr_reader :intern, :id2name, :group
4
4
 
5
5
  alias :to_sym :intern
6
6
  alias :to_s :id2name
@@ -10,6 +10,7 @@ class Bootinq
10
10
  def initialize(intern)
11
11
  @intern = intern.to_sym
12
12
  @id2name = intern.to_s.freeze
13
+ @group = :"#@id2name\_boot"
13
14
  freeze
14
15
  end
15
16
 
@@ -17,10 +18,6 @@ class Bootinq
17
18
  false
18
19
  end
19
20
 
20
- def group
21
- :"#@id2name\_boot"
22
- end
23
-
24
21
  def == other
25
22
  case other
26
23
  when String then other == @id2name
@@ -34,7 +31,6 @@ class Bootinq
34
31
  end
35
32
 
36
33
  def engine
37
- nil
38
34
  end
39
35
 
40
36
  def module_name
@@ -1,3 +1,3 @@
1
1
  class Bootinq
2
- VERSION = "0.5.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/bootinq.rb CHANGED
@@ -27,7 +27,6 @@ class Bootinq
27
27
  extend SingleForwardable
28
28
  include Singleton
29
29
 
30
- NEG_OPS = %w(- ^).freeze
31
30
  DEFAULT = {
32
31
  "env_key" => 'BOOTINQ',
33
32
  "default" => '',
@@ -38,10 +37,10 @@ class Bootinq
38
37
  # The helper method to bootstrap the Bootinq.
39
38
  # Sets the BOOTINQ_PATH enviroment variable, yields optional block in
40
39
  # the own instance's binding and, finally, requires selected bundler groups.
41
- def self.require(*groups, logger: nil, &block) # :yields:
40
+ def self.require(*groups, verbose: false, &block) # :yields:
42
41
  ENV['BOOTINQ_PATH'] ||= File.expand_path('../bootinq.yml', caller_locations(1..1)[0].path)
43
42
 
44
- logger.debug { "Bootinq: loading components #{instance.components.join(', ')}" } if logger.respond_to?(:debug)
43
+ puts "Bootinq: loading components #{instance.components.join(', ')}" if verbose
45
44
 
46
45
  instance.instance_exec(&block) if block_given?
47
46
 
@@ -60,7 +59,7 @@ class Bootinq
60
59
  merge!(DEFAULT) { |_,l,r| l.nil? ? r : l }
61
60
 
62
61
  @_value = ENV.fetch(config['env_key']) { config['default'] }
63
- @_neg = @_value.start_with?(*NEG_OPS)
62
+ @_neg = @_value.start_with?("-", "^")
64
63
  @flags = []
65
64
  @components = []
66
65
 
@@ -81,7 +80,7 @@ class Bootinq
81
80
  alias :[] :component
82
81
 
83
82
  # Enums each mountable component
84
- def each_mountable
83
+ def each_mountable # :yields:
85
84
  return to_enum(__method__) unless block_given?
86
85
  components.each { |part| yield(part) if part.mountable? }
87
86
  end
@@ -109,15 +108,17 @@ class Bootinq
109
108
  # Bootinq.on all: %i(frontend backend) do
110
109
  # # do something when frontend and backend are enabled
111
110
  # end
112
- def on(name) # :yields:
113
- if name.is_a?(Hash)
114
- %i(any all).each do |m|
115
- list = name[m]
116
- next unless list.is_a?(Enumerable)
117
- yield if list.public_send(:"#{m}?") { |part| enabled?(part) }
118
- end
119
- else
111
+ def on(name = nil, any: nil, all: nil) # :yields:
112
+ if (any && all) || (name && (any || all))
113
+ raise ArgumentError, "expected single argument or one of keywords: `all' or `any'"
114
+ elsif name
120
115
  yield if enabled?(name)
116
+ elsif any
117
+ yield if any.any? { |part| enabled?(part) }
118
+ elsif all
119
+ yield if all.all? { |part| enabled?(part) }
120
+ else
121
+ raise ArgumentError, "wrong arguments (given 0, expected 1)"
121
122
  end
122
123
  end
123
124
 
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: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler