pears 0.3.0 → 0.3.1

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: d7fc395542fa7edb5343dfc3a609289406dca92f8286b4db8c5dab540a514872
4
- data.tar.gz: fcd9e6d1caef736a54bbb4debb3fd2a3d805d13d26e7e02f2a81df0ef6742a3e
3
+ metadata.gz: 10cdea0d2eb59b303dab2dac91edbe3a3f37d6bb833fcbccaf7176ab28cc6813
4
+ data.tar.gz: aef9803cf0c1c022fdb21615c0d76c228c3eabbaf160bd5742d6fee244315301
5
5
  SHA512:
6
- metadata.gz: 54cb6031fe170893891123588cd2bb1b2f9e4fd350a5bc9e54b081af3609c8fc80b092756dd9025ef1f497de750bb2c760e5d3c9fddcf7817da0f4898c21056b
7
- data.tar.gz: 6ea523856f8af120dd3569c735603d5735448e6ac28a27db1f7af99236d1ca6104d6ece4142d3807a89c306533646da62877c3bd0449887909e4928f07e914e9
6
+ metadata.gz: 12365453b2bbdb8fc612180dd3d7723811ff3068c8c78d46c2b957824ce44cc477438d76d5a2086d7c252772a2d3ea11101fbef44e0df56e70222c0e3e3adb2f
7
+ data.tar.gz: aefbc749ea3806cec18b20c948cf93253ac9d87c1de579c06a2ea757bbd8ddd8e1b0d483222e5dfe7e78160c264b735cb05387606c2687d9ddedab280fa9308c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pears (0.2.0)
4
+ pears (0.3.1)
5
5
  activesupport
6
6
  dry-configurable (>= 0.13.0)
7
7
  redis
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (7.0.3)
12
+ activesupport (7.0.3.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
@@ -20,9 +20,9 @@ GEM
20
20
  dry-configurable (0.15.0)
21
21
  concurrent-ruby (~> 1.0)
22
22
  dry-core (~> 0.6)
23
- dry-core (0.7.1)
23
+ dry-core (0.8.0)
24
24
  concurrent-ruby (~> 1.0)
25
- i18n (1.10.0)
25
+ i18n (1.12.0)
26
26
  concurrent-ruby (~> 1.0)
27
27
  minitest (5.16.2)
28
28
  rake (13.0.6)
@@ -42,7 +42,7 @@ GEM
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
43
  rspec-support (~> 3.10.0)
44
44
  rspec-support (3.10.3)
45
- tzinfo (2.0.4)
45
+ tzinfo (2.0.5)
46
46
  concurrent-ruby (~> 1.0)
47
47
 
48
48
  PLATFORMS
@@ -5,6 +5,10 @@ module Pears
5
5
  Pears.subjects.each(&:purge)
6
6
  Pears.instance_variable_set('@subjects', [])
7
7
  end
8
+
9
+ def reboot
10
+ Pears.subjects.each(&:reboot)
11
+ end
8
12
  end
9
13
  end
10
14
  end
data/lib/pears/subject.rb CHANGED
@@ -8,9 +8,11 @@ module Pears
8
8
  include Enumerable
9
9
  attr_reader :name
10
10
 
11
- def initialize(name, *layers)
11
+ def initialize(name, *layers, loader: ->(builder){} )
12
12
  @name = name
13
13
  @layers = layers
14
+ @loader = loader
15
+ boot
14
16
  end
15
17
 
16
18
  def [](key)
@@ -48,8 +50,18 @@ module Pears
48
50
  project.each(&block)
49
51
  end
50
52
 
53
+ def reboot
54
+ purge
55
+ @layers = []
56
+ boot
57
+ end
58
+
51
59
  private
52
60
 
61
+ def boot
62
+ @loader.call(Provider::Builder.new(self))
63
+ end
64
+
53
65
  def layers
54
66
  @layers
55
67
  end
data/lib/pears/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pears
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/pears.rb CHANGED
@@ -16,15 +16,15 @@ module Pears
16
16
  end
17
17
 
18
18
  # This is the main way of locating a subject.
19
- def self.subject(name)
19
+ def self.subject(name, &block)
20
20
  if subjects.any? { |sub| sub.name == name }
21
21
  raise Pears::Error.new("subject name #{name} is already in use.")
22
22
  end
23
23
 
24
- Subject.new(name).tap do |subject|
25
- builder = Provider::Builder.new(subject)
26
- yield(builder)
27
- @subjects.push subject
28
- end
24
+ Subject.new(name, loader: block).tap { |sub| @subjects.push sub }
25
+ end
26
+
27
+ def self.[](name)
28
+ subjects.find { |subject| subject.name == name }
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pears
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Kemp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-07 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable