template_streaming 0.0.2 → 0.0.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.
- data/CHANGELOG +8 -0
- data/lib/template_streaming.rb +26 -7
- data/lib/template_streaming/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/lib/template_streaming.rb
CHANGED
@@ -6,11 +6,8 @@ module TemplateStreaming
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def render_with_template_streaming(*args, &block)
|
9
|
-
|
10
|
-
|
11
|
-
@render_stack_height += 1
|
12
|
-
begin
|
13
|
-
if @render_stack_height == 1
|
9
|
+
with_template_streaming_condition(*args) do |condition|
|
10
|
+
if condition
|
14
11
|
@performed_render = true
|
15
12
|
check_thin_support
|
16
13
|
@streaming_body = StreamingBody.new(progressive_rendering_threshold) do
|
@@ -25,8 +22,6 @@ module TemplateStreaming
|
|
25
22
|
else
|
26
23
|
render_without_template_streaming(*args, &block)
|
27
24
|
end
|
28
|
-
ensure
|
29
|
-
@render_stack_height -= 1
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
@@ -50,6 +45,30 @@ module TemplateStreaming
|
|
50
45
|
|
51
46
|
private # --------------------------------------------------------
|
52
47
|
|
48
|
+
#
|
49
|
+
# Yield true if we should intercept this render call, false
|
50
|
+
# otherwise.
|
51
|
+
#
|
52
|
+
def with_template_streaming_condition(*args)
|
53
|
+
@render_stack_height ||= 0
|
54
|
+
@render_stack_height += 1
|
55
|
+
begin
|
56
|
+
# Only install our StreamingBody in the toplevel #render call.
|
57
|
+
@render_stack_height == 1 or
|
58
|
+
return yield(false)
|
59
|
+
|
60
|
+
if (options = args.last).is_a?(Hash)
|
61
|
+
yield((UNSTREAMABLE_KEYS & options.keys).empty?)
|
62
|
+
else
|
63
|
+
yield(args.first != :update)
|
64
|
+
end
|
65
|
+
ensure
|
66
|
+
@render_stack_height -= 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
UNSTREAMABLE_KEYS = [:text, :xml, :json, :js, :update, :nothing]
|
71
|
+
|
53
72
|
#
|
54
73
|
# The number of bytes that must be received by the client before
|
55
74
|
# anything will be rendered.
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- George Ogata
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-23 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|