props_template 1.1.0 → 1.1.1
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/props_template/base.rb +9 -0
- data/lib/props_template/extension_manager.rb +5 -13
- data/lib/props_template/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: 9a54115d5cb581b3b4a3c487ca6bdad66a2f533a56f1171d65c9f1759ca9f2ec
|
|
4
|
+
data.tar.gz: d7672f8b3324ec7ae2b63e790b2c0f38e73f3b5534ad18a5e8a1704bd14c98b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d07608d99ad469d3dfe6c4f264b7addb844b7a35f6a5ce2c13469bd1bd1dfa14d41c6800f62933a122d86d3ecf65a08aba95a4746d3fc329b5daf1305ec288af
|
|
7
|
+
data.tar.gz: b76b141b1938ebc83b40c2208c0d77274472c02615a17a0a6771147b38ac7639923b092b066333708087f2074b920e06d99e824b4b36fc9a8e4d517afb7d3f3a
|
data/lib/props_template/base.rb
CHANGED
|
@@ -168,6 +168,15 @@ module Props
|
|
|
168
168
|
@child_index = child_index
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
+
def capture_json
|
|
172
|
+
parent_stream = @stream
|
|
173
|
+
@stream = Oj::StringWriter.new(mode: :rails)
|
|
174
|
+
yield
|
|
175
|
+
@stream.raw_json.strip
|
|
176
|
+
ensure
|
|
177
|
+
@stream = parent_stream
|
|
178
|
+
end
|
|
179
|
+
|
|
171
180
|
def result!
|
|
172
181
|
if @scope.nil?
|
|
173
182
|
@stream.push_object
|
|
@@ -70,22 +70,16 @@ module Props
|
|
|
70
70
|
|
|
71
71
|
def handle_cache(options, item)
|
|
72
72
|
if options[:cache]
|
|
73
|
-
recently_cached = false
|
|
74
|
-
|
|
75
73
|
key, rest = Cache
|
|
76
74
|
.normalize_options(options[:cache], item)
|
|
75
|
+
|
|
76
|
+
# A miss renders into a writer of its own, so its JSON is added to
|
|
77
|
+
# the output below like a hit's.
|
|
77
78
|
state = @cache.cache(key, rest) do
|
|
78
|
-
recently_cached = true
|
|
79
79
|
result = nil
|
|
80
|
-
start = base.stream.to_s.length
|
|
81
80
|
base.scoped_state { |stream, deferred_paths, fragment_paths|
|
|
82
|
-
yield
|
|
81
|
+
raw = base.capture_json { yield }
|
|
83
82
|
meta = Oj.dump([deferred_paths, fragment_paths]).strip
|
|
84
|
-
json_in_progress = base.stream.to_s
|
|
85
|
-
if json_in_progress[start] == ","
|
|
86
|
-
start += 1
|
|
87
|
-
end
|
|
88
|
-
raw = base.stream.to_s[start..].strip
|
|
89
83
|
result = "#{meta}\n#{raw}"
|
|
90
84
|
}
|
|
91
85
|
result
|
|
@@ -96,9 +90,7 @@ module Props
|
|
|
96
90
|
deferred.push(*next_deferred)
|
|
97
91
|
fragments.push(*next_fragments)
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
base.stream.push_json(raw_json)
|
|
101
|
-
end
|
|
93
|
+
base.stream.push_json(raw_json)
|
|
102
94
|
else
|
|
103
95
|
yield
|
|
104
96
|
end
|