reactive-ruby 0.7.26 → 0.7.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reactive-ruby/rendering_context.rb +28 -22
- data/lib/reactive-ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 579a244953ecf04793186edfc376b776ee208bfa
|
4
|
+
data.tar.gz: cbd731345dd42377ab1d8890f5ff13eab3dacf08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b7aef0925c62a1e75cf8a6d7da93ab633ccbe0af4a6940b8d80af13213324b18323a3c9203c147c706e0742acfbf1dca13189a9ca5381e8b72738e494159168
|
7
|
+
data.tar.gz: d8df70a1a64040aae4e2a621353276d5df6da37f51928e286c8d598596a36e45aca958960d7821582eea0085e0619c486c99bc49abfeb4585f472299817cf4bc
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module React
|
2
|
-
|
2
|
+
|
3
3
|
class RenderingContext
|
4
|
-
|
4
|
+
|
5
5
|
class << self
|
6
6
|
attr_accessor :waiting_on_resources
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def self.render(name, *args, &block)
|
10
10
|
remove_nodes_from_args(args)
|
11
11
|
@buffer = [] unless @buffer
|
@@ -18,17 +18,17 @@ module React
|
|
18
18
|
# i.e. render_child/render_children that takes Element/Array[Element] and does the push into the buffer
|
19
19
|
if !name and ( # !name means called from outer render so we check that it has rendered correctly
|
20
20
|
(@buffer.count > 1) or # should only render one element
|
21
|
-
(@buffer.count == 1 and @buffer.last != result) or # it should return that element
|
21
|
+
(@buffer.count == 1 and @buffer.last != result) or # it should return that element
|
22
22
|
(@buffer.count == 0 and !(result.is_a? String or (result.respond_to? :acts_as_string? and result.acts_as_string?) or result.is_a? Element)) #for convience we will also convert the return value to a span if its a string
|
23
23
|
)
|
24
24
|
raise "a components render method must generate and return exactly 1 element or a string"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
@buffer << result.to_s if result.is_a? String or (result.respond_to? :acts_as_string? and result.acts_as_string?) # For convience we push the last return value on if its a string
|
28
28
|
@buffer << result if result.is_a? Element and @buffer.count == 0
|
29
29
|
if name
|
30
30
|
buffer = @buffer.dup
|
31
|
-
React.create_element(name, *args) { buffer }.tap do |element|
|
31
|
+
React.create_element(name, *args) { buffer }.tap do |element|
|
32
32
|
element.waiting_on_resources = saved_waiting_on_resources || !!buffer.detect { |e| e.waiting_on_resources if e.respond_to? :waiting_on_resources }
|
33
33
|
end
|
34
34
|
elsif @buffer.last.is_a? React::Element
|
@@ -39,16 +39,16 @@ module React
|
|
39
39
|
end
|
40
40
|
elsif name.is_a? React::Element
|
41
41
|
element = name
|
42
|
-
# I BELIEVE WAITING ON RESOURCES SHOULD ALREADY BE SET
|
42
|
+
# I BELIEVE WAITING ON RESOURCES SHOULD ALREADY BE SET
|
43
43
|
else
|
44
44
|
element = React.create_element(name, *args)
|
45
45
|
element.waiting_on_resources = waiting_on_resources
|
46
46
|
end
|
47
|
-
@buffer << element
|
47
|
+
@buffer << element
|
48
48
|
self.waiting_on_resources = nil
|
49
49
|
element
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def self.build(&block)
|
53
53
|
current = @buffer
|
54
54
|
@buffer = []
|
@@ -59,43 +59,49 @@ module React
|
|
59
59
|
# @buffer = current
|
60
60
|
# return_val
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def self.as_node(element)
|
64
64
|
@buffer.delete(element)
|
65
65
|
element
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
class << self; alias_method :delete, :as_node; end
|
69
|
-
|
69
|
+
|
70
70
|
def self.replace(e1, e2)
|
71
|
-
@buffer[@buffer.index(e1)] = e2
|
71
|
+
@buffer[@buffer.index(e1)] = e2
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def self.remove_nodes_from_args(args)
|
75
75
|
args[0].each do |key, value|
|
76
76
|
value.as_node if value.is_a? Element rescue nil
|
77
77
|
end if args[0] and args[0].is_a? Hash
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
class ::Object
|
83
|
-
|
83
|
+
|
84
84
|
alias_method :old_method_missing, :method_missing
|
85
|
-
|
85
|
+
|
86
86
|
["span", "para", "td", "th", "while_loading"].each do |tag|
|
87
87
|
define_method(tag) do | *args, &block |
|
88
88
|
args.unshift(tag)
|
89
|
-
return self.method_missing(*args, &block) if self.is_a? React::Component
|
89
|
+
return self.method_missing(*args, &block) if self.is_a? React::Component
|
90
90
|
React::RenderingContext.render(*args) { self.to_s }
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
|
+
def para(*args, &block)
|
95
|
+
args.unshift("p")
|
96
|
+
return self.method_missing(*args, &block) if self.is_a? React::Component
|
97
|
+
React::RenderingContext.render(*args) { self.to_s }
|
98
|
+
end
|
99
|
+
|
94
100
|
def br
|
95
101
|
return self.method_missing(*["br"]) if self.is_a? React::Component
|
96
102
|
React::RenderingContext.render("span") { React::RenderingContext.render(self.to_s); React::RenderingContext.render("br") }
|
97
103
|
end
|
98
|
-
|
104
|
+
|
99
105
|
end
|
100
106
|
|
101
|
-
end
|
107
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactive-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|