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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cabb9dbc691bdd59d655c9112d8ea4c55a69d7e
4
- data.tar.gz: a3fe4c7eedbfe32adc455040ba523c203dc7e772
3
+ metadata.gz: b4cfe73def23ff520e039aad9da34c207484733a
4
+ data.tar.gz: 6fd1b502c56739617144e5178eaf8238f752eddf
5
5
  SHA512:
6
- metadata.gz: f1c7200dd2026f609343ec8e07715e0ae47f6fe32746d1d59e1c2b9ea867bc39860e758f6de4bfe41bbb867603f3e2c126e05300f7fb6d0eef51175a8eda161e
7
- data.tar.gz: 3e793b8ad729af2404bf238c87a050ceae5fee9536ae0d547379b81a7b0ee9a98ca259cddc2fe2661f1c2df380db52f6a666b7bc1376834ae266d9b3a2c103e0
6
+ metadata.gz: 75bf09f809d80b7d4c9635a6b9141106f1f04d87165ab80b243fe4125d4ff04692968b9f6affc29f32465140cd07fbcb0b123b6adff6f230718211f0e48add11
7
+ data.tar.gz: 9b298e91f8b4574fc914c68e4d2c7a2ff7f41de29e54f90f6b6388147e8effc2e69aa799991990e1c0b8402889e05a23fcc2d3c971a37a9f7126c2a7a19f9d21
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "async_partial"
6
- spec.version = '0.2.0'.freeze
6
+ spec.version = '0.3.0'.freeze
7
7
  spec.authors = ["Akira Matsuda"]
8
8
  spec.email = ["ronnie@dio.jp"]
9
9
 
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
- buf << v.to_s
67
+ if AsyncPartial::AsyncResult === v
68
+ buf << v.value
69
+ else
70
+ buf << v.to_s
71
+ end
64
72
  else
65
- buf.safe_concat(v.to_s)
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
@@ -11,10 +11,6 @@ module Temple
11
11
  class ThreadedRailsOutputBuffer < RailsOutputBuffer
12
12
  set_options buffer_class: 'ActionView::OutputBuffer', buffer: 'output_buffer'
13
13
 
14
- def on_dynamic(code)
15
- concat(code)
16
- end
17
-
18
14
  def return_buffer
19
15
  "#{buffer}.to_s"
20
16
  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.2.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-05 00:00:00.000000000 Z
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