dirload 0.7.2 → 0.7.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/adapters/rbx_adapter.rb +12 -6
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec0a5fb0f9791f9c86bd426942bd8b97fd37c4dde99ddea3a2988bf7700cdbf4
|
|
4
|
+
data.tar.gz: d7dd2153288bbab8c9eba9212830f0c6d8035e654089526747871e52628a0636
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd29235c6e86da989b986489d31187af619c45b5bb93b6b19d2c1c2a46ba246cdbf57cba83fd7afa92ba80ed0e10ad83c247ded9383c5f72819dd89dcf1c3768
|
|
7
|
+
data.tar.gz: f754e46247f236b8571bf286590776d53cc244aa4d38ee8d08c0cf0790b64caffc541147d57bbdffda5ee77e3b1b30606bca4c1ffeba31662d11e302304bd108
|
data/lib/adapters/rbx_adapter.rb
CHANGED
|
@@ -22,13 +22,14 @@ module Dirload
|
|
|
22
22
|
|
|
23
23
|
def evaluate(file_path:)
|
|
24
24
|
# 1. "File Load" phase.
|
|
25
|
-
#
|
|
26
|
-
file_proxy = Lowkey.load(file_path)
|
|
27
|
-
|
|
25
|
+
# Wraps a copy of the file's lines so the file proxy mapload cached stays as the file is.
|
|
26
|
+
file_proxy = Lowkey[file_path] || Lowkey.load(file_path)
|
|
27
|
+
lines = file_proxy.lines.dup
|
|
28
|
+
templates = wrap_render_methods(file_proxy:, lines:)
|
|
28
29
|
|
|
29
30
|
# 2. "Class Load" phase.
|
|
30
31
|
# Not a security risk because "eval" is equivalent to "load" or "require_relative" in this context.
|
|
31
|
-
eval(
|
|
32
|
+
eval(lines.join, top_level_binding, file_proxy.file_path, 0) # rubocop:disable Security/Eval
|
|
32
33
|
|
|
33
34
|
# 3. "Runtime" phase (before low nodes are rendered).
|
|
34
35
|
# Templates only exist when there's a template engine and the template contains template syntax.
|
|
@@ -50,7 +51,7 @@ module Dirload
|
|
|
50
51
|
klass.respond_to?(:render) && klass.respond_to?(:template) && klass.respond_to?(:build_template)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
def wrap_render_methods(file_proxy:)
|
|
54
|
+
def wrap_render_methods(file_proxy:, lines:)
|
|
54
55
|
# GOAL: Templates could be organised by method and template rendering engine.
|
|
55
56
|
templates = {}
|
|
56
57
|
|
|
@@ -66,10 +67,15 @@ module Dirload
|
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
# Intended to target HTML or Antlers tags. Use HEREDOC "<<~" in a plain Ruby (".rb") file, not RBX.
|
|
69
|
-
|
|
70
|
+
wrap_lines(lines:, body: render_method.body) if render_method_body.strip.start_with?('<')
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
templates
|
|
73
74
|
end
|
|
75
|
+
|
|
76
|
+
def wrap_lines(lines:, body:)
|
|
77
|
+
lines[body.start_index] = lines[body.start_index].sub(/\A(\s*)/, '\\1%q{')
|
|
78
|
+
lines[body.end_index] += '}'
|
|
79
|
+
end
|
|
74
80
|
end
|
|
75
81
|
end
|
data/lib/version.rb
CHANGED