truck 0.8.2 → 0.8.3

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
  SHA1:
3
- metadata.gz: 078fde6292a95915f76eeba0efec27a4398bb055
4
- data.tar.gz: 205bd43d1d5391460de0c7b2f32499ee3c56e3e6
3
+ metadata.gz: 5a2fcfe39879e13f8c344cafb95db949dc89d74b
4
+ data.tar.gz: caed4964dd127828e91ff3801f2993f38376d1e9
5
5
  SHA512:
6
- metadata.gz: ed4264626b8e609d7af67313d6ac08ebaa8ec58ea952e6414b43f06cb25e4eb4cfe99663547e0d8c676121cce41bd46c2451ad1d6a7a6a190dd3a459e9a2c9ca
7
- data.tar.gz: a3dea32078bb7500694c4c5c21089851cfe7d07518d6c5ac78185c804f0c64c6b7f8957539f09bf4f8fc18029d836eb7481476e4c04eca1152403da9f679960c
6
+ metadata.gz: 787d4dc1ae99279a73e81461ce69f692d904239b113e6ec67e0e7d323ce513201ffd907086ef9156f6f6d2aff0202e2f79424c870134394328c656fac80a0f7f
7
+ data.tar.gz: 51eb6e680f7b7fade4e1a9417c618575d67b07677330eecc7b1255531aa2a14dae010fa5c54931b7021d4af6a28647a69b465fc1b38c02b2fcd8ea37a6b8a0ed
@@ -15,16 +15,17 @@ module Truck
15
15
  end
16
16
 
17
17
  def boot!
18
- contexts.each_value(&:boot!)
18
+ contexts.each_value &:boot!
19
19
  end
20
20
 
21
21
  def reset!
22
- each_booted_context &:reset!
22
+ shutdown!
23
+ boot!
23
24
  end
24
25
  alias_method :reload!, :reset!
25
26
 
26
27
  def shutdown!
27
- each_booted_context &:shutdown!
28
+ each_booted_context.to_a.reverse.each &:shutdown!
28
29
  end
29
30
 
30
31
  Error = Class.new StandardError
@@ -1,12 +1,11 @@
1
1
  module Truck
2
2
  class Context
3
- attr :autoload_paths, :mod, :name, :root
3
+ attr :autoload_paths, :name, :root
4
4
 
5
5
  def initialize(name, parent: nil, root:, autoload_paths: ['.'])
6
6
  @name = name
7
7
  @root = Pathname(root)
8
8
  @parent = parent
9
- @mod = build_mod
10
9
  @autoload_paths = expand_autoload_paths autoload_paths
11
10
  end
12
11
 
@@ -18,11 +17,16 @@ module Truck
18
17
  end
19
18
 
20
19
  def boot!
21
- parent.const_set name, mod
20
+ parent.const_set name, build_mod
21
+ end
22
+
23
+ def mod
24
+ return nil unless parent and parent.const_defined? name
25
+ parent.const_get name
22
26
  end
23
27
 
24
28
  def booted?
25
- parent.const_defined? name
29
+ mod ? true : false
26
30
  end
27
31
 
28
32
  def eager_load!
@@ -40,19 +44,12 @@ module Truck
40
44
  Truck.contexts.fetch(@parent.to_sym).mod
41
45
  end
42
46
 
43
- def reset!
44
- shutdown!
45
- @mod = build_mod
46
- boot!
47
- end
48
- alias_method :reload!, :reset!
49
-
50
47
  def resolve_const(expanded_const)
51
48
  build_const_resolver(expanded_const).resolve
52
49
  end
53
50
 
54
51
  def shutdown!
55
- parent.send(:remove_const, name)
52
+ parent.send :remove_const, name
56
53
  end
57
54
 
58
55
  private
@@ -1,3 +1,3 @@
1
1
  module Truck
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
@@ -63,13 +63,6 @@ class ContextTest < Minitest::Test
63
63
  assert Foo.const_defined?(:A)
64
64
  end
65
65
 
66
- def test_reload_drops_constant_references
67
- @context.eager_load!
68
- assert Foo.const_defined?(:A)
69
- @context.reload!
70
- refute Foo.const_defined?(:A)
71
- end
72
-
73
66
  def test_shutdown_removes_const
74
67
  assert @context.booted?
75
68
  @context.shutdown!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ntl