async_partial 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/async_partial.gemspec +1 -1
- data/lib/async_partial.rb +14 -2
- data/lib/async_partial/handlers/haml.rb +18 -0
- data/lib/async_partial/handlers/slim.rb +0 -4
- data/lib/async_partial/railtie.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4cfe73def23ff520e039aad9da34c207484733a
|
4
|
+
data.tar.gz: 6fd1b502c56739617144e5178eaf8238f752eddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75bf09f809d80b7d4c9635a6b9141106f1f04d87165ab80b243fe4125d4ff04692968b9f6affc29f32465140cd07fbcb0b123b6adff6f230718211f0e48add11
|
7
|
+
data.tar.gz: 9b298e91f8b4574fc914c68e4d2c7a2ff7f41de29e54f90f6b6388147e8effc2e69aa799991990e1c0b8402889e05a23fcc2d3c971a37a9f7126c2a7a19f9d21
|
data/async_partial.gemspec
CHANGED
data/lib/async_partial.rb
CHANGED
@@ -27,6 +27,10 @@ module AsyncPartial
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def to_s
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def value
|
30
34
|
val = @thread.value
|
31
35
|
@thread.kill
|
32
36
|
val
|
@@ -60,9 +64,17 @@ module AsyncPartial
|
|
60
64
|
def to_s
|
61
65
|
result = @values.each_with_object(ActiveSupport::SafeBuffer.new) do |(v, meth), buf|
|
62
66
|
if meth == :<<
|
63
|
-
|
67
|
+
if AsyncPartial::AsyncResult === v
|
68
|
+
buf << v.value
|
69
|
+
else
|
70
|
+
buf << v.to_s
|
71
|
+
end
|
64
72
|
else
|
65
|
-
|
73
|
+
if AsyncPartial::AsyncResult === v
|
74
|
+
buf.safe_concat(v.value)
|
75
|
+
else
|
76
|
+
buf.safe_concat(v.to_s)
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
68
80
|
result.to_s
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AsyncPartial
|
4
|
+
class HamlArrayBuffer < Array
|
5
|
+
def html_safe
|
6
|
+
map {|v| AsyncPartial::AsyncResult === v ? v.value : v}.join.html_safe
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module HamlArrayBufferizer
|
11
|
+
def initialize(*)
|
12
|
+
super;
|
13
|
+
@buffer = AsyncPartial::HamlArrayBuffer.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Haml::Buffer.prepend HamlArrayBufferizer
|
18
|
+
end
|
@@ -15,6 +15,11 @@ module AsyncPartial
|
|
15
15
|
rescue LoadError
|
16
16
|
end
|
17
17
|
|
18
|
+
if Gem.loaded_specs.detect {|g| g[0] == 'haml'}
|
19
|
+
require 'haml/buffer'
|
20
|
+
require_relative 'handlers/haml'
|
21
|
+
end
|
22
|
+
|
18
23
|
if Gem.loaded_specs.detect {|g| g[0] == 'slim'}
|
19
24
|
require 'temple/generators/rails_output_buffer'
|
20
25
|
require_relative 'handlers/slim'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async_partial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- bin/setup
|
85
85
|
- lib/async_partial.rb
|
86
86
|
- lib/async_partial/handlers/erubi.rb
|
87
|
+
- lib/async_partial/handlers/haml.rb
|
87
88
|
- lib/async_partial/handlers/slim.rb
|
88
89
|
- lib/async_partial/railtie.rb
|
89
90
|
homepage: https://github.com/amatsuda/async_partial
|