truck 0.8.2 → 0.8.3
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 +4 -4
- data/lib/truck.rb +4 -3
- data/lib/truck/context.rb +9 -12
- data/lib/truck/version.rb +1 -1
- data/test/unit/context_test.rb +0 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a2fcfe39879e13f8c344cafb95db949dc89d74b
|
|
4
|
+
data.tar.gz: caed4964dd127828e91ff3801f2993f38376d1e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 787d4dc1ae99279a73e81461ce69f692d904239b113e6ec67e0e7d323ce513201ffd907086ef9156f6f6d2aff0202e2f79424c870134394328c656fac80a0f7f
|
|
7
|
+
data.tar.gz: 51eb6e680f7b7fade4e1a9417c618575d67b07677330eecc7b1255531aa2a14dae010fa5c54931b7021d4af6a28647a69b465fc1b38c02b2fcd8ea37a6b8a0ed
|
data/lib/truck.rb
CHANGED
|
@@ -15,16 +15,17 @@ module Truck
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def boot!
|
|
18
|
-
contexts.each_value
|
|
18
|
+
contexts.each_value &:boot!
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def reset!
|
|
22
|
-
|
|
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
|
data/lib/truck/context.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
module Truck
|
|
2
2
|
class Context
|
|
3
|
-
attr :autoload_paths, :
|
|
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,
|
|
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
|
-
|
|
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
|
|
52
|
+
parent.send :remove_const, name
|
|
56
53
|
end
|
|
57
54
|
|
|
58
55
|
private
|
data/lib/truck/version.rb
CHANGED
data/test/unit/context_test.rb
CHANGED
|
@@ -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!
|