react.rb 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +12 -10
- data/README.md +6 -4
- data/Rakefile +12 -0
- data/config.ru +1 -0
- data/example/basic-jsx/Gemfile.lock +2 -2
- data/example/basic-jsx/example.jsx.rb +4 -7
- data/example/react-tutorial/Gemfile.lock +21 -11
- data/example/react-tutorial/config.ru +1 -1
- data/example/react-tutorial/example.rb +1 -1
- data/example/todos/Gemfile +1 -1
- data/example/todos/Gemfile.lock +4 -8
- data/example/todos/index.html.haml +1 -1
- data/lib/react/api.rb +2 -2
- data/lib/react/component.rb +0 -4
- data/lib/react/element.rb +63 -29
- data/lib/react/top_level.rb +4 -4
- data/lib/react/version.rb +1 -1
- data/react.rb.gemspec +7 -6
- data/spec/component_spec.rb +0 -17
- data/spec/element_spec.rb +76 -10
- data/spec/react_spec.rb +16 -18
- data/spec/reactjs/index.html.erb +1 -0
- data/spec/spec_helper.rb +4 -4
- data/spec/vendor/es5-shim.min.js +7 -0
- metadata +35 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2edd338c72d88b40b11c779a530108df20c2f20e
|
4
|
+
data.tar.gz: 7c5b542f62c33a02d5fb4de25e8b4af5519b0ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a3aa1ca6ab21e4f7699585d50fbb27f1f82cf67e8f7bf43d66a239c3b39da7f7a804abf7329f3cc0f96cfb6b71410bf7f39c8cf543f8f2d89b701c8ecfffc52
|
7
|
+
data.tar.gz: c3a4852db1d7d1b672d78f08bbc0843e22b66a7fece186cbb94311a9f2d6fda36058a60ecbc96239ebbf96c51d68764c609e51eb68851c28ebf1701e434463da
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## 0.2.0
|
2
|
+
|
3
|
+
* Deprecating `jsx` helper method in component instance
|
4
|
+
* Deprecating `React::Element.new`, use `React.create_element` instead
|
5
|
+
* `React::Element` is now toll-free bridge to [ReactElement](http://facebook.github.io/react/docs/glossary.html#react-elements)
|
6
|
+
* `React::Element#props` now return a `Hash` rather than a `Native`
|
7
|
+
* `React::Element#children` now handling empty child & single child correctly
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
react.rb (0.
|
5
|
-
opal (~> 0.6
|
6
|
-
opal-activesupport
|
7
|
-
sprockets-es6
|
8
|
-
therubyracer
|
4
|
+
react.rb (0.2.0)
|
5
|
+
opal (~> 0.6)
|
6
|
+
opal-activesupport (~> 0)
|
7
|
+
sprockets-es6 (~> 0)
|
8
|
+
therubyracer (~> 0)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -29,12 +29,13 @@ GEM
|
|
29
29
|
rack (1.6.0)
|
30
30
|
rack-protection (1.5.3)
|
31
31
|
rack
|
32
|
+
rake (10.4.2)
|
32
33
|
react-source (0.12.2)
|
33
34
|
ref (1.0.5)
|
34
|
-
sinatra (1.4.
|
35
|
+
sinatra (1.4.6)
|
35
36
|
rack (~> 1.4)
|
36
37
|
rack-protection (~> 1.4)
|
37
|
-
tilt (
|
38
|
+
tilt (>= 1.3, < 3)
|
38
39
|
source_map (3.0.1)
|
39
40
|
json
|
40
41
|
sprockets (3.0.0.beta.10)
|
@@ -45,14 +46,15 @@ GEM
|
|
45
46
|
therubyracer (0.12.1)
|
46
47
|
libv8 (~> 3.16.14.0)
|
47
48
|
ref
|
48
|
-
tilt (
|
49
|
+
tilt (2.0.1)
|
49
50
|
|
50
51
|
PLATFORMS
|
51
52
|
ruby
|
52
53
|
|
53
54
|
DEPENDENCIES
|
54
|
-
opal-jquery
|
55
|
+
opal-jquery (~> 0)
|
55
56
|
opal-rspec (~> 0.3.0.beta3)
|
57
|
+
rake (~> 10)
|
56
58
|
react-source (~> 0.12)
|
57
59
|
react.rb!
|
58
|
-
sinatra
|
60
|
+
sinatra (~> 1)
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# React.rb
|
2
2
|
|
3
|
+
[![Build Status](http://img.shields.io/travis/zetachang/react.rb/master.svg)](http://travis-ci.org/zetachang/react.rb)
|
3
4
|
[![Gem Version](https://badge.fury.io/rb/react.rb.svg)](http://badge.fury.io/rb/react.rb)
|
4
5
|
[![Code Climate](https://codeclimate.com/github/zetachang/react.rb/badges/gpa.svg)](https://codeclimate.com/github/zetachang/react.rb)
|
5
6
|
|
@@ -133,7 +134,7 @@ def render
|
|
133
134
|
end
|
134
135
|
```
|
135
136
|
|
136
|
-
|
137
|
+
### JSX Support
|
137
138
|
|
138
139
|
Not a fan of using element building DSL? Use file extension `.jsx.rb` to get JSX fragment compiled.
|
139
140
|
|
@@ -141,7 +142,7 @@ Not a fan of using element building DSL? Use file extension `.jsx.rb` to get JSX
|
|
141
142
|
# app.jsx.rb
|
142
143
|
class Fancy
|
143
144
|
def render
|
144
|
-
|
145
|
+
`<div>"this is fancy"</div>`
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
@@ -149,12 +150,13 @@ class App
|
|
149
150
|
include React::Component
|
150
151
|
|
151
152
|
def render
|
152
|
-
|
153
|
+
element = %x{
|
153
154
|
<div>
|
154
155
|
<h1>Outer</h1>
|
155
156
|
<Fancy>{ #{5.times.to_a.join(",")} }</Fancy>
|
156
157
|
</div>
|
157
|
-
}
|
158
|
+
}
|
159
|
+
element
|
158
160
|
end
|
159
161
|
end
|
160
162
|
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'opal/rspec/rake_task'
|
6
|
+
require "react/source"
|
7
|
+
|
8
|
+
Opal::RSpec::RakeTask.new(:default) do |s|
|
9
|
+
s.append_path File.dirname(::React::Source.bundled_path_for("react-with-addons"))
|
10
|
+
s.append_path 'spec/vendor'
|
11
|
+
s.index_path = 'spec/reactjs/index.html.erb'
|
12
|
+
end
|
data/config.ru
CHANGED
@@ -9,6 +9,7 @@ Opal.append_path File.expand_path('../spec', __FILE__)
|
|
9
9
|
run Opal::Server.new { |s|
|
10
10
|
s.main = 'opal/rspec/sprockets_runner'
|
11
11
|
s.append_path 'spec'
|
12
|
+
s.append_path 'spec/vendor'
|
12
13
|
s.append_path File.dirname(::React::Source.bundled_path_for("react-with-addons.js"))
|
13
14
|
s.debug = true
|
14
15
|
s.index_path = 'spec/reactjs/index.html.erb'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
react.rb (0.0
|
4
|
+
react.rb (0.1.0)
|
5
5
|
opal (~> 0.6.0)
|
6
6
|
opal-activesupport
|
7
7
|
sprockets-es6
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
babel-source (4.7.
|
13
|
+
babel-source (4.7.16)
|
14
14
|
babel-transpiler (0.6.0)
|
15
15
|
babel-source (>= 4.0, < 5)
|
16
16
|
execjs (~> 2.0)
|
@@ -8,9 +8,8 @@ class Clock
|
|
8
8
|
def render
|
9
9
|
message = "React has been successfully running for #{params[:elapsed].round} seconds."
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
}
|
11
|
+
|
12
|
+
`<p>{#{message}}</p>`
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
@@ -18,9 +17,7 @@ class ExampleApp
|
|
18
17
|
include React::Component
|
19
18
|
|
20
19
|
def render
|
21
|
-
|
22
|
-
<Clock elapsed={#{params[:elapsed]}} />
|
23
|
-
})
|
20
|
+
`<Clock elapsed={#{params[:elapsed]}} />`
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
@@ -29,7 +26,7 @@ React.expose_native_class(Clock, ExampleApp)
|
|
29
26
|
start = Time.now
|
30
27
|
|
31
28
|
$window.every(0.05) do
|
32
|
-
element =
|
29
|
+
element = `<ExampleApp elapsed={#{Time.now - start}}/>`
|
33
30
|
container = `document.getElementById('container')`
|
34
31
|
React.render element, container
|
35
32
|
end
|
@@ -1,16 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
react.rb (0.0
|
4
|
+
react.rb (0.1.0)
|
5
5
|
opal (~> 0.6.0)
|
6
6
|
opal-activesupport
|
7
|
+
sprockets-es6
|
8
|
+
therubyracer
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: https://rubygems.org/
|
10
12
|
specs:
|
11
|
-
|
13
|
+
babel-source (4.7.16)
|
14
|
+
babel-transpiler (0.6.0)
|
15
|
+
babel-source (>= 4.0, < 5)
|
16
|
+
execjs (~> 2.0)
|
17
|
+
execjs (2.4.0)
|
12
18
|
json (1.8.2)
|
13
|
-
|
19
|
+
libv8 (3.16.14.7)
|
14
20
|
opal (0.6.3)
|
15
21
|
source_map
|
16
22
|
sprockets
|
@@ -21,19 +27,23 @@ GEM
|
|
21
27
|
rack (1.6.0)
|
22
28
|
rack-protection (1.5.3)
|
23
29
|
rack
|
24
|
-
react-source (0.
|
25
|
-
|
30
|
+
react-source (0.13.1)
|
31
|
+
ref (1.0.5)
|
32
|
+
sinatra (1.4.6)
|
26
33
|
rack (~> 1.4)
|
27
34
|
rack-protection (~> 1.4)
|
28
|
-
tilt (
|
35
|
+
tilt (>= 1.3, < 3)
|
29
36
|
source_map (3.0.1)
|
30
37
|
json
|
31
|
-
sprockets (
|
32
|
-
hike (~> 1.2)
|
33
|
-
multi_json (~> 1.0)
|
38
|
+
sprockets (3.0.0.rc.1)
|
34
39
|
rack (~> 1.0)
|
35
|
-
|
36
|
-
|
40
|
+
sprockets-es6 (0.6.0)
|
41
|
+
babel-transpiler
|
42
|
+
sprockets (~> 3.0.0.beta)
|
43
|
+
therubyracer (0.12.1)
|
44
|
+
libv8 (~> 3.16.14.0)
|
45
|
+
ref
|
46
|
+
tilt (2.0.1)
|
37
47
|
|
38
48
|
PLATFORMS
|
39
49
|
ruby
|
@@ -42,7 +42,7 @@ get '/' do
|
|
42
42
|
<link rel="stylesheet" href="base.css" />
|
43
43
|
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
|
44
44
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
|
45
|
-
<script src="/assets/react-with-addons.
|
45
|
+
<script src="/assets/react-with-addons.js"></script>
|
46
46
|
<script src="/assets/example.js"></script>
|
47
47
|
</head>
|
48
48
|
<body>
|
@@ -100,5 +100,5 @@ end
|
|
100
100
|
|
101
101
|
|
102
102
|
Document.ready? do
|
103
|
-
React.render React.create_element(CommentBox, url: "comments.json", poll_interval: 2000),
|
103
|
+
React.render React.create_element(CommentBox, url: "comments.json", poll_interval: 2000), `document.getElementById('content')`
|
104
104
|
end
|
data/example/todos/Gemfile
CHANGED
@@ -6,6 +6,6 @@ gem 'opal-jquery', :github => 'opal/opal-jquery'
|
|
6
6
|
gem 'vienna', :github => 'opal/vienna', :ref => '593335cbd7fb99ce471fa720e9b9c849d99b8dda'
|
7
7
|
gem 'opal-haml', :github => 'opal/opal-haml'
|
8
8
|
gem 'opal-rspec', '0.3.0.beta2'
|
9
|
-
gem 'react.rb',
|
9
|
+
gem 'react.rb', '~> 0.0.2'
|
10
10
|
gem 'thin'
|
11
11
|
gem 'react-source'
|
data/example/todos/Gemfile.lock
CHANGED
@@ -32,13 +32,6 @@ GIT
|
|
32
32
|
opal-activesupport
|
33
33
|
opal-jquery
|
34
34
|
|
35
|
-
PATH
|
36
|
-
remote: ../..
|
37
|
-
specs:
|
38
|
-
react.rb (0.0.1)
|
39
|
-
opal (~> 0.6.0)
|
40
|
-
opal-activesupport
|
41
|
-
|
42
35
|
GEM
|
43
36
|
remote: https://rubygems.org/
|
44
37
|
specs:
|
@@ -56,6 +49,9 @@ GEM
|
|
56
49
|
rack (1.5.2)
|
57
50
|
rake (10.1.1)
|
58
51
|
react-source (0.12.2)
|
52
|
+
react.rb (0.0.2)
|
53
|
+
opal (~> 0.6.0)
|
54
|
+
opal-activesupport
|
59
55
|
source_map (3.0.1)
|
60
56
|
json
|
61
57
|
sprockets (2.12.3)
|
@@ -79,6 +75,6 @@ DEPENDENCIES
|
|
79
75
|
opal-rspec (= 0.3.0.beta2)
|
80
76
|
rake
|
81
77
|
react-source
|
82
|
-
react.rb
|
78
|
+
react.rb (~> 0.0.2)
|
83
79
|
thin
|
84
80
|
vienna!
|
@@ -4,7 +4,7 @@
|
|
4
4
|
%meta(charset="utf-8")
|
5
5
|
%meta(http-equiv="X-UA-Compatible" content="IE=edge,chrome=1")
|
6
6
|
%link(rel="stylesheet" href="/vendor/base.css")
|
7
|
-
= javascript_include_tag 'react-with-addons.
|
7
|
+
= javascript_include_tag 'react-with-addons.js'
|
8
8
|
= javascript_include_tag 'application'
|
9
9
|
|
10
10
|
%body
|
data/lib/react/api.rb
CHANGED
@@ -32,7 +32,7 @@ module React
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
return
|
35
|
+
return `React.createElement.apply(null, #{params})`
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.clear_component_class_cache
|
@@ -88,7 +88,7 @@ module React
|
|
88
88
|
},
|
89
89
|
render: function() {
|
90
90
|
var instance = this._getOpalInstance.apply(this);
|
91
|
-
return
|
91
|
+
return instance.$render();
|
92
92
|
}
|
93
93
|
})
|
94
94
|
}
|
data/lib/react/component.rb
CHANGED
data/lib/react/element.rb
CHANGED
@@ -1,63 +1,97 @@
|
|
1
1
|
require "./ext/string"
|
2
2
|
|
3
3
|
module React
|
4
|
-
class Element
|
5
|
-
|
6
|
-
|
7
|
-
alias_native :element_type, :type
|
8
|
-
alias_native :props, :props
|
9
|
-
|
10
|
-
def initialize(native_element)
|
11
|
-
@native = native_element
|
4
|
+
class Element < `(function(){var f = new Function();f.prototype = Object.getPrototypeOf(React.createElement(''));return f})()`
|
5
|
+
def self.new
|
6
|
+
raise "use React.create_element instead"
|
12
7
|
end
|
13
|
-
|
8
|
+
|
9
|
+
def element_type
|
10
|
+
`self.type`
|
11
|
+
end
|
12
|
+
|
13
|
+
def key
|
14
|
+
Native(`self.key`)
|
15
|
+
end
|
16
|
+
|
17
|
+
def props
|
18
|
+
Hash.new(`self.props`)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ref
|
22
|
+
Native(`self.ref`)
|
23
|
+
end
|
24
|
+
|
14
25
|
def on(event_name)
|
15
26
|
name = event_name.to_s.event_camelize
|
27
|
+
|
28
|
+
|
16
29
|
if React::Event::BUILT_IN_EVENTS.include?("on#{name}")
|
17
|
-
|
30
|
+
prop_key = "on#{name}"
|
31
|
+
callback = %x{
|
18
32
|
function(event){
|
19
33
|
#{yield React::Event.new(`event`)}
|
20
34
|
}
|
21
35
|
}
|
22
36
|
else
|
23
|
-
|
37
|
+
prop_key = "_on#{name}"
|
38
|
+
callback = %x{
|
24
39
|
function(){
|
25
40
|
#{yield *Array(`arguments`)}
|
26
41
|
}
|
27
42
|
}
|
28
43
|
end
|
44
|
+
|
45
|
+
`self.props[#{prop_key}] = #{callback}`
|
46
|
+
|
29
47
|
self
|
30
48
|
end
|
31
49
|
|
32
50
|
def children
|
33
|
-
nodes = self.props.children
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
51
|
+
nodes = `self.props.children`
|
52
|
+
|
53
|
+
if `React.Children.count(nodes)` == 0
|
54
|
+
`[]`
|
55
|
+
elsif `React.Children.count(nodes)` == 1
|
56
|
+
if `(typeof nodes === 'string') || (typeof nodes === 'number')`
|
57
|
+
[nodes]
|
58
|
+
else
|
59
|
+
`[React.Children.only(nodes)]`
|
39
60
|
end
|
61
|
+
else
|
62
|
+
# Not sure the overhead of doing this..
|
63
|
+
class << nodes
|
64
|
+
include Enumerable
|
65
|
+
|
66
|
+
def to_n
|
67
|
+
self
|
68
|
+
end
|
40
69
|
|
41
|
-
|
42
|
-
|
43
|
-
%x{
|
44
|
-
React.Children.forEach(#{self.to_n}, function(context){
|
45
|
-
#{block.call(React::Element.new(`context`))}
|
46
|
-
})
|
47
|
-
}
|
48
|
-
else
|
49
|
-
Enumerator.new(`React.Children.count(#{self.to_n})`) do |y|
|
70
|
+
def each(&block)
|
71
|
+
if block_given?
|
50
72
|
%x{
|
51
73
|
React.Children.forEach(#{self.to_n}, function(context){
|
52
|
-
#{
|
74
|
+
#{block.call(`context`)}
|
53
75
|
})
|
54
76
|
}
|
77
|
+
else
|
78
|
+
Enumerator.new(`React.Children.count(#{self.to_n})`) do |y|
|
79
|
+
%x{
|
80
|
+
React.Children.forEach(#{self.to_n}, function(context){
|
81
|
+
#{y << `context`}
|
82
|
+
})
|
83
|
+
}
|
84
|
+
end
|
55
85
|
end
|
56
86
|
end
|
57
87
|
end
|
88
|
+
|
89
|
+
nodes
|
58
90
|
end
|
59
|
-
|
60
|
-
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_n
|
94
|
+
self
|
61
95
|
end
|
62
96
|
end
|
63
97
|
end
|
data/lib/react/top_level.rb
CHANGED
@@ -27,21 +27,21 @@ module React
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.render(element, container)
|
30
|
-
component = Native(`React.render(#{element
|
30
|
+
component = Native(`React.render(#{element}, container, function(){#{yield if block_given?}})`)
|
31
31
|
component.class.include(React::Component::API)
|
32
32
|
component
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.is_valid_element(element)
|
36
|
-
|
36
|
+
`React.isValidElement(#{element})`
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.render_to_string(element)
|
40
|
-
`React.renderToString(#{element
|
40
|
+
`React.renderToString(#{element})`
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.render_to_static_markup(element)
|
44
|
-
`React.renderToStaticMarkup(#{element
|
44
|
+
`React.renderToStaticMarkup(#{element})`
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.unmount_component_at_node(node)
|
data/lib/react/version.rb
CHANGED
data/react.rb.gemspec
CHANGED
@@ -16,12 +16,13 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.require_paths = ['lib', 'vendor']
|
18
18
|
|
19
|
-
s.add_runtime_dependency 'opal', '~> 0.6
|
20
|
-
s.add_runtime_dependency 'opal-activesupport'
|
21
|
-
s.add_runtime_dependency 'sprockets-es6'
|
22
|
-
s.add_runtime_dependency 'therubyracer'
|
19
|
+
s.add_runtime_dependency 'opal', '~> 0.6'
|
20
|
+
s.add_runtime_dependency 'opal-activesupport', '~> 0'
|
21
|
+
s.add_runtime_dependency 'sprockets-es6', '~> 0'
|
22
|
+
s.add_runtime_dependency 'therubyracer', '~> 0'
|
23
23
|
s.add_development_dependency 'react-source', '~> 0.12'
|
24
24
|
s.add_development_dependency 'opal-rspec', '~> 0.3.0.beta3'
|
25
|
-
s.add_development_dependency 'sinatra'
|
26
|
-
s.add_development_dependency 'opal-jquery'
|
25
|
+
s.add_development_dependency 'sinatra', '~> 1'
|
26
|
+
s.add_development_dependency 'opal-jquery', '~> 0'
|
27
|
+
s.add_development_dependency 'rake', '~> 10'
|
27
28
|
end
|
data/spec/component_spec.rb
CHANGED
@@ -594,21 +594,4 @@ describe React::Component do
|
|
594
594
|
expect(component.mounted?).to eq(true)
|
595
595
|
end
|
596
596
|
end
|
597
|
-
|
598
|
-
describe "Helpers" do
|
599
|
-
describe "jsx" do
|
600
|
-
it "should wrap passed JS object to React::Element" do
|
601
|
-
stub_const 'Foo', Class.new
|
602
|
-
Foo.class_eval do
|
603
|
-
include React::Component
|
604
|
-
|
605
|
-
def foo
|
606
|
-
jsx(`React.createElement('div')`)
|
607
|
-
end
|
608
|
-
end
|
609
|
-
|
610
|
-
expect(Foo.new.foo).to be_kind_of(React::Element)
|
611
|
-
end
|
612
|
-
end
|
613
|
-
end
|
614
597
|
end
|
data/spec/element_spec.rb
CHANGED
@@ -1,18 +1,52 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe React::Element do
|
4
|
-
it "should
|
4
|
+
it "should be toll-free bridged to React.Element" do
|
5
5
|
element = React.create_element('div')
|
6
|
-
expect(element
|
6
|
+
expect(`React.isValidElement(#{element})`).to eq(true)
|
7
7
|
end
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
|
9
|
+
describe "#new" do
|
10
|
+
it "should raise error if invokded" do
|
11
|
+
expect { React::Element.new }.to raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#element_type" do
|
16
|
+
it "should bridge to `type` of native" do
|
17
|
+
element = React.create_element('div')
|
18
|
+
expect(element.element_type).to eq("div")
|
19
|
+
%x{
|
20
|
+
var m = React.createClass({
|
21
|
+
render:function(){ return React.createElement('div'); }
|
22
|
+
});
|
23
|
+
var ele = React.createElement(m);
|
15
24
|
}
|
25
|
+
expect(`ele`.element_type).to eq(`ele.type`)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#key" do
|
30
|
+
it "should bridge to `key` of native" do
|
31
|
+
element = React.create_element('div', key: "1")
|
32
|
+
expect(element.key).to eq(`#{element}.key`)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return nil if key is null" do
|
36
|
+
element = React.create_element('div')
|
37
|
+
expect(element.key).to be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#ref" do
|
42
|
+
it "should bridge to `ref` of native" do
|
43
|
+
element = React.create_element('div', ref: "foo")
|
44
|
+
expect(element.ref).to eq(`#{element}.ref`)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return nil if ref is null" do
|
48
|
+
element = React.create_element('div')
|
49
|
+
expect(element.ref).to be_nil
|
16
50
|
end
|
17
51
|
end
|
18
52
|
|
@@ -43,7 +77,7 @@ describe React::Element do
|
|
43
77
|
end
|
44
78
|
end
|
45
79
|
|
46
|
-
describe "Children" do
|
80
|
+
describe "Props.Children" do
|
47
81
|
it "should return a Enumerable" do
|
48
82
|
ele = React.create_element('div') { [React.create_element('a'), React.create_element('li')] }
|
49
83
|
nodes = ele.children.map {|ele| ele.element_type }
|
@@ -56,5 +90,37 @@ describe React::Element do
|
|
56
90
|
expect(nodes).to be_a(Enumerator)
|
57
91
|
expect(nodes.size).to eq(2)
|
58
92
|
end
|
93
|
+
|
94
|
+
describe "empty" do
|
95
|
+
it "should work as Enumerable" do
|
96
|
+
ele = React.create_element('div')
|
97
|
+
expect(ele.children.count).to eq(0)
|
98
|
+
expect(ele.children.none?).to eq(true)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "single child" do
|
103
|
+
it "should works as Enumerable" do
|
104
|
+
ele = React.create_element('div') { [React.create_element('a')] }
|
105
|
+
expect(ele.children.count).to eq(1)
|
106
|
+
expect(ele.children.map {|node| node.element_type}).to eq(['a'])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "single child as string" do
|
111
|
+
it "should works as Enumerable" do
|
112
|
+
ele = React.create_element('div') { "foo" }
|
113
|
+
expect(ele.children.count).to eq(1)
|
114
|
+
expect(ele.children.map {|node| node}).to eq(['foo'])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "single child as number" do
|
119
|
+
it "should works as Enumerable" do
|
120
|
+
ele = React.create_element('div') { 123 }
|
121
|
+
expect(ele.children.count).to eq(1)
|
122
|
+
expect(ele.children.map {|node| node}).to eq([123])
|
123
|
+
end
|
124
|
+
end
|
59
125
|
end
|
60
126
|
end
|
data/spec/react_spec.rb
CHANGED
@@ -7,12 +7,12 @@ describe React do
|
|
7
7
|
|
8
8
|
describe "is_valid_element" do
|
9
9
|
it "should return true if passed a valid element" do
|
10
|
-
element =
|
10
|
+
element = `React.createElement('div')`
|
11
11
|
expect(React.is_valid_element(element)).to eq(true)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return false is passed a non React element" do
|
15
|
-
element =
|
15
|
+
element = `{}`
|
16
16
|
expect(React.is_valid_element(element)).to eq(false)
|
17
17
|
end
|
18
18
|
end
|
@@ -27,7 +27,7 @@ describe React do
|
|
27
27
|
it "should create a valid element with text as only child when block yield String" do
|
28
28
|
element = React.create_element('div') { "lorem ipsum" }
|
29
29
|
expect(React.is_valid_element(element)).to eq(true)
|
30
|
-
expect(element.
|
30
|
+
expect(element.children.to_a).to eq(["lorem ipsum"])
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should create a valid element with children as array when block yield Array of element" do
|
@@ -35,7 +35,7 @@ describe React do
|
|
35
35
|
[React.create_element('span'), React.create_element('span'), React.create_element('span')]
|
36
36
|
end
|
37
37
|
expect(React.is_valid_element(element)).to eq(true)
|
38
|
-
expect(element.
|
38
|
+
expect(element.children.length).to eq(3)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should render element with children as array when block yield Array of element" do
|
@@ -56,18 +56,16 @@ describe React do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should
|
59
|
+
it "should create element with only one children correctly" do
|
60
60
|
element = React.create_element(Foo) { React.create_element('span') }
|
61
|
-
|
62
|
-
expect(
|
63
|
-
expect(instance.props.children.type).to eq("span")
|
61
|
+
expect(element.children.count).to eq(1)
|
62
|
+
expect(element.children.map{|e| e.element_type }).to eq(["span"])
|
64
63
|
end
|
65
64
|
|
66
|
-
it "should
|
65
|
+
it "should create element with more than one children correctly" do
|
67
66
|
element = React.create_element(Foo) { [React.create_element('span'), React.create_element('span')] }
|
68
|
-
|
69
|
-
expect(
|
70
|
-
expect(instance.props.children.length).to eq(2)
|
67
|
+
expect(element.children.count).to eq(2)
|
68
|
+
expect(element.children.map{|e| e.element_type }).to eq(["span", "span"])
|
71
69
|
end
|
72
70
|
|
73
71
|
it "should create a valid element provided class defined `render`" do
|
@@ -77,7 +75,7 @@ describe React do
|
|
77
75
|
|
78
76
|
it "should allow creating with properties" do
|
79
77
|
element = React.create_element(Foo, foo: "bar")
|
80
|
-
expect(element.props
|
78
|
+
expect(element.props[:foo]).to eq("bar")
|
81
79
|
end
|
82
80
|
|
83
81
|
it "should raise error if provided class doesn't defined `render`" do
|
@@ -125,17 +123,17 @@ describe React do
|
|
125
123
|
describe "create element with properties" do
|
126
124
|
it "should enforce snake-cased property name" do
|
127
125
|
element = React.create_element("div", class_name: "foo")
|
128
|
-
expect(element.props
|
126
|
+
expect(element.props[:className]).to eq("foo")
|
129
127
|
end
|
130
128
|
|
131
129
|
it "should allow custom property" do
|
132
130
|
element = React.create_element("div", foo: "bar")
|
133
|
-
expect(element.props
|
131
|
+
expect(element.props[:foo]).to eq("bar")
|
134
132
|
end
|
135
133
|
|
136
134
|
it "should not camel-case custom property" do
|
137
135
|
element = React.create_element("div", foo_bar: "foo")
|
138
|
-
expect(element.props
|
136
|
+
expect(element.props[:foo_bar]).to eq("foo")
|
139
137
|
end
|
140
138
|
end
|
141
139
|
|
@@ -144,13 +142,13 @@ describe React do
|
|
144
142
|
classes = {foo: true, bar: false, lorem: true}
|
145
143
|
element = React.create_element("div", class_name: classes)
|
146
144
|
|
147
|
-
expect(element.props
|
145
|
+
expect(element.props[:className]).to eq("foo lorem")
|
148
146
|
end
|
149
147
|
|
150
148
|
it "should not alter behavior when passing a string" do
|
151
149
|
element = React.create_element("div", class_name: "foo bar")
|
152
150
|
|
153
|
-
expect(element.props
|
151
|
+
expect(element.props[:className]).to eq("foo bar")
|
154
152
|
end
|
155
153
|
end
|
156
154
|
end
|
data/spec/reactjs/index.html.erb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,18 +9,18 @@ module ReactTestHelpers
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def renderElementToDocument(element)
|
12
|
-
instance = Native(`ReactTestUtils.renderIntoDocument(#{element
|
12
|
+
instance = Native(`ReactTestUtils.renderIntoDocument(#{element})`)
|
13
13
|
instance.class.include(React::Component::API)
|
14
14
|
return instance
|
15
15
|
end
|
16
16
|
|
17
|
-
def simulateEvent(event,
|
17
|
+
def simulateEvent(event, component, params = {})
|
18
18
|
simulator = Native(`ReactTestUtils.Simulate`)
|
19
|
-
simulator[event.to_s].call(`#{
|
19
|
+
simulator[event.to_s].call(`#{component.to_n}.getDOMNode()`, params)
|
20
20
|
end
|
21
21
|
|
22
22
|
def isElementOfType(element, type)
|
23
|
-
`React.addons.TestUtils.isElementOfType(#{element
|
23
|
+
`React.addons.TestUtils.isElementOfType(#{element}, #{type.cached_component_class})`
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* https://github.com/es-shims/es5-shim
|
3
|
+
* @license es5-shim Copyright 2009-2014 by contributors, MIT License
|
4
|
+
* see https://github.com/es-shims/es5-shim/blob/v4.1.0/LICENSE
|
5
|
+
*/
|
6
|
+
(function(t,e){"use strict";if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){var t=Array.prototype;var e=Object.prototype;var r=Function.prototype;var n=String.prototype;var i=Number.prototype;var a=t.slice;var o=t.splice;var u=t.push;var l=t.unshift;var f=r.call;var s=e.toString;var c=Array.isArray||function ye(t){return s.call(t)==="[object Array]"};var p=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var h;var v=Function.prototype.toString,g=function de(t){try{v.call(t);return true}catch(e){return false}},y="[object Function]",d="[object GeneratorFunction]";h=function me(t){if(typeof t!=="function"){return false}if(p){return g(t)}var e=s.call(t);return e===y||e===d};var m;var b=RegExp.prototype.exec,w=function be(t){try{b.call(t);return true}catch(e){return false}},T="[object RegExp]";m=function we(t){if(typeof t!=="object"){return false}return p?w(t):s.call(t)===T};var x;var O=String.prototype.valueOf,j=function Te(t){try{O.call(t);return true}catch(e){return false}},S="[object String]";x=function xe(t){if(typeof t==="string"){return true}if(typeof t!=="object"){return false}return p?j(t):s.call(t)===S};var E=function Oe(t){var e=s.call(t);var r=e==="[object Arguments]";if(!r){r=!c(t)&&t!==null&&typeof t==="object"&&typeof t.length==="number"&&t.length>=0&&h(t.callee)}return r};var N=function(t){var e=Object.defineProperty&&function(){try{Object.defineProperty({},"x",{});return true}catch(t){return false}}();var r;if(e){r=function(t,e,r,n){if(!n&&e in t){return}Object.defineProperty(t,e,{configurable:true,enumerable:false,writable:true,value:r})}}else{r=function(t,e,r,n){if(!n&&e in t){return}t[e]=r}}return function n(e,i,a){for(var o in i){if(t.call(i,o)){r(e,o,i[o],a)}}}}(e.hasOwnProperty);function I(t){var e=typeof t;return t===null||e==="undefined"||e==="boolean"||e==="number"||e==="string"}var D={ToInteger:function je(t){var e=+t;if(e!==e){e=0}else if(e!==0&&e!==1/0&&e!==-(1/0)){e=(e>0||-1)*Math.floor(Math.abs(e))}return e},ToPrimitive:function Se(t){var e,r,n;if(I(t)){return t}r=t.valueOf;if(h(r)){e=r.call(t);if(I(e)){return e}}n=t.toString;if(h(n)){e=n.call(t);if(I(e)){return e}}throw new TypeError},ToObject:function(t){if(t==null){throw new TypeError("can't convert "+t+" to object")}return Object(t)},ToUint32:function Ee(t){return t>>>0}};var M=function Ne(){};N(r,{bind:function Ie(t){var e=this;if(!h(e)){throw new TypeError("Function.prototype.bind called on incompatible "+e)}var r=a.call(arguments,1);var n;var i=function(){if(this instanceof n){var i=e.apply(this,r.concat(a.call(arguments)));if(Object(i)===i){return i}return this}else{return e.apply(t,r.concat(a.call(arguments)))}};var o=Math.max(0,e.length-r.length);var u=[];for(var l=0;l<o;l++){u.push("$"+l)}n=Function("binder","return function ("+u.join(",")+"){ return binder.apply(this, arguments); }")(i);if(e.prototype){M.prototype=e.prototype;n.prototype=new M;M.prototype=null}return n}});var F=f.bind(e.hasOwnProperty);var R=function(){var t=[1,2];var e=t.splice();return t.length===2&&c(e)&&e.length===0}();N(t,{splice:function De(t,e){if(arguments.length===0){return[]}else{return o.apply(this,arguments)}}},!R);var U=function(){var e={};t.splice.call(e,0,0,1);return e.length===1}();N(t,{splice:function Me(t,e){if(arguments.length===0){return[]}var r=arguments;this.length=Math.max(D.ToInteger(this.length),0);if(arguments.length>0&&typeof e!=="number"){r=a.call(arguments);if(r.length<2){r.push(this.length-t)}else{r[1]=D.ToInteger(e)}}return o.apply(this,r)}},!U);var k=[].unshift(0)!==1;N(t,{unshift:function(){l.apply(this,arguments);return this.length}},k);N(Array,{isArray:c});var A=Object("a");var C=A[0]!=="a"||!(0 in A);var P=function Fe(t){var e=true;var r=true;if(t){t.call("foo",function(t,r,n){if(typeof n!=="object"){e=false}});t.call([1],function(){"use strict";r=typeof this==="string"},"x")}return!!t&&e&&r};N(t,{forEach:function Re(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=arguments[1],i=-1,a=r.length>>>0;if(!h(t)){throw new TypeError}while(++i<a){if(i in r){t.call(n,r[i],i,e)}}}},!P(t.forEach));N(t,{map:function Ue(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=Array(n),a=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var o=0;o<n;o++){if(o in r){i[o]=t.call(a,r[o],o,e)}}return i}},!P(t.map));N(t,{filter:function ke(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=[],a,o=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var u=0;u<n;u++){if(u in r){a=r[u];if(t.call(o,a,u,e)){i.push(a)}}}return i}},!P(t.filter));N(t,{every:function Ae(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var a=0;a<n;a++){if(a in r&&!t.call(i,r[a],a,e)){return false}}return true}},!P(t.every));N(t,{some:function Ce(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var a=0;a<n;a++){if(a in r&&t.call(i,r[a],a,e)){return true}}return false}},!P(t.some));var Z=false;if(t.reduce){Z=typeof t.reduce.call("es5",function(t,e,r,n){return n})==="object"}N(t,{reduce:function Pe(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0;if(!h(t)){throw new TypeError(t+" is not a function")}if(!n&&arguments.length===1){throw new TypeError("reduce of empty array with no initial value")}var i=0;var a;if(arguments.length>=2){a=arguments[1]}else{do{if(i in r){a=r[i++];break}if(++i>=n){throw new TypeError("reduce of empty array with no initial value")}}while(true)}for(;i<n;i++){if(i in r){a=t.call(void 0,a,r[i],i,e)}}return a}},!Z);var J=false;if(t.reduceRight){J=typeof t.reduceRight.call("es5",function(t,e,r,n){return n})==="object"}N(t,{reduceRight:function Ze(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0;if(!h(t)){throw new TypeError(t+" is not a function")}if(!n&&arguments.length===1){throw new TypeError("reduceRight of empty array with no initial value")}var i,a=n-1;if(arguments.length>=2){i=arguments[1]}else{do{if(a in r){i=r[a--];break}if(--a<0){throw new TypeError("reduceRight of empty array with no initial value")}}while(true)}if(a<0){return i}do{if(a in r){i=t.call(void 0,i,r[a],a,e)}}while(a--);return i}},!J);var z=Array.prototype.indexOf&&[0,1].indexOf(1,2)!==-1;N(t,{indexOf:function Je(t){var e=C&&x(this)?this.split(""):D.ToObject(this),r=e.length>>>0;if(!r){return-1}var n=0;if(arguments.length>1){n=D.ToInteger(arguments[1])}n=n>=0?n:Math.max(0,r+n);for(;n<r;n++){if(n in e&&e[n]===t){return n}}return-1}},z);var $=Array.prototype.lastIndexOf&&[0,1].lastIndexOf(0,-3)!==-1;N(t,{lastIndexOf:function ze(t){var e=C&&x(this)?this.split(""):D.ToObject(this),r=e.length>>>0;if(!r){return-1}var n=r-1;if(arguments.length>1){n=Math.min(n,D.ToInteger(arguments[1]))}n=n>=0?n:r-Math.abs(n);for(;n>=0;n--){if(n in e&&t===e[n]){return n}}return-1}},$);var B=!{toString:null}.propertyIsEnumerable("toString"),G=function(){}.propertyIsEnumerable("prototype"),H=!F("x","0"),L=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],X=L.length;N(Object,{keys:function $e(t){var e=h(t),r=E(t),n=t!==null&&typeof t==="object",i=n&&x(t);if(!n&&!e&&!r){throw new TypeError("Object.keys called on a non-object")}var a=[];var o=G&&e;if(i&&H||r){for(var u=0;u<t.length;++u){a.push(String(u))}}if(!r){for(var l in t){if(!(o&&l==="prototype")&&F(t,l)){a.push(String(l))}}}if(B){var f=t.constructor,s=f&&f.prototype===t;for(var c=0;c<X;c++){var p=L[c];if(!(s&&p==="constructor")&&F(t,p)){a.push(p)}}}return a}});var Y=Object.keys&&function(){return Object.keys(arguments).length===2}(1,2);var q=Object.keys;N(Object,{keys:function Be(e){if(E(e)){return q(t.slice.call(e))}else{return q(e)}}},!Y);var K=-621987552e5;var Q="-000001";var V=Date.prototype.toISOString&&new Date(K).toISOString().indexOf(Q)===-1;N(Date.prototype,{toISOString:function Ge(){var t,e,r,n,i;if(!isFinite(this)){throw new RangeError("Date.prototype.toISOString called on non-finite value.")}n=this.getUTCFullYear();i=this.getUTCMonth();n+=Math.floor(i/12);i=(i%12+12)%12;t=[i+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()];n=(n<0?"-":n>9999?"+":"")+("00000"+Math.abs(n)).slice(0<=n&&n<=9999?-4:-6);e=t.length;while(e--){r=t[e];if(r<10){t[e]="0"+r}}return n+"-"+t.slice(0,2).join("-")+"T"+t.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"}},V);var W=false;try{W=Date.prototype.toJSON&&new Date(NaN).toJSON()===null&&new Date(K).toJSON().indexOf(Q)!==-1&&Date.prototype.toJSON.call({toISOString:function(){return true}})}catch(_){}if(!W){Date.prototype.toJSON=function He(t){var e=Object(this),r=D.ToPrimitive(e),n;if(typeof r==="number"&&!isFinite(r)){return null}n=e.toISOString;if(typeof n!=="function"){throw new TypeError("toISOString property is not callable")}return n.call(e)}}var te=Date.parse("+033658-09-27T01:46:40.000Z")===1e15;var ee=!isNaN(Date.parse("2012-04-04T24:00:00.500Z"))||!isNaN(Date.parse("2012-11-31T23:59:59.000Z"));var re=isNaN(Date.parse("2000-01-01T00:00:00.000Z"));if(!Date.parse||re||ee||!te){Date=function(t){function e(r,n,i,a,o,u,l){var f=arguments.length;if(this instanceof t){var s=f===1&&String(r)===r?new t(e.parse(r)):f>=7?new t(r,n,i,a,o,u,l):f>=6?new t(r,n,i,a,o,u):f>=5?new t(r,n,i,a,o):f>=4?new t(r,n,i,a):f>=3?new t(r,n,i):f>=2?new t(r,n):f>=1?new t(r):new t;s.constructor=e;return s}return t.apply(this,arguments)}var r=new RegExp("^"+"(\\d{4}|[+-]\\d{6})"+"(?:-(\\d{2})"+"(?:-(\\d{2})"+"(?:"+"T(\\d{2})"+":(\\d{2})"+"(?:"+":(\\d{2})"+"(?:(\\.\\d{1,}))?"+")?"+"("+"Z|"+"(?:"+"([-+])"+"(\\d{2})"+":(\\d{2})"+")"+")?)?)?)?"+"$");var n=[0,31,59,90,120,151,181,212,243,273,304,334,365];function i(t,e){var r=e>1?1:0;return n[e]+Math.floor((t-1969+r)/4)-Math.floor((t-1901+r)/100)+Math.floor((t-1601+r)/400)+365*(t-1970)}function a(e){return Number(new t(1970,0,1,0,0,0,e))}for(var o in t){e[o]=t[o]}e.now=t.now;e.UTC=t.UTC;e.prototype=t.prototype;e.prototype.constructor=e;e.parse=function u(e){var n=r.exec(e);if(n){var o=Number(n[1]),u=Number(n[2]||1)-1,l=Number(n[3]||1)-1,f=Number(n[4]||0),s=Number(n[5]||0),c=Number(n[6]||0),p=Math.floor(Number(n[7]||0)*1e3),h=Boolean(n[4]&&!n[8]),v=n[9]==="-"?1:-1,g=Number(n[10]||0),y=Number(n[11]||0),d;if(f<(s>0||c>0||p>0?24:25)&&s<60&&c<60&&p<1e3&&u>-1&&u<12&&g<24&&y<60&&l>-1&&l<i(o,u+1)-i(o,u)){d=((i(o,u)+l)*24+f+g*v)*60;d=((d+s+y*v)*60+c)*1e3+p;if(h){d=a(d)}if(-864e13<=d&&d<=864e13){return d}}return NaN}return t.parse.apply(this,arguments)};return e}(Date)}if(!Date.now){Date.now=function Le(){return(new Date).getTime()}}var ne=i.toFixed&&(8e-5.toFixed(3)!=="0.000"||.9.toFixed(0)!=="1"||1.255.toFixed(2)!=="1.25"||0xde0b6b3a7640080.toFixed(0)!=="1000000000000000128");var ie={base:1e7,size:6,data:[0,0,0,0,0,0],multiply:function Xe(t,e){var r=-1;while(++r<ie.size){e+=t*ie.data[r];ie.data[r]=e%ie.base;e=Math.floor(e/ie.base)}},divide:function Ye(t){var e=ie.size,r=0;while(--e>=0){r+=ie.data[e];ie.data[e]=Math.floor(r/t);r=r%t*ie.base}},numToString:function qe(){var t=ie.size;var e="";while(--t>=0){if(e!==""||t===0||ie.data[t]!==0){var r=String(ie.data[t]);if(e===""){e=r}else{e+="0000000".slice(0,7-r.length)+r}}}return e},pow:function Ke(t,e,r){return e===0?r:e%2===1?Ke(t,e-1,r*t):Ke(t*t,e/2,r)},log:function Qe(t){var e=0;while(t>=4096){e+=12;t/=4096}while(t>=2){e+=1;t/=2}return e}};N(i,{toFixed:function Ve(t){var e,r,n,i,a,o,u,l;e=Number(t);e=e!==e?0:Math.floor(e);if(e<0||e>20){throw new RangeError("Number.toFixed called with invalid number of decimals")}r=Number(this);if(r!==r){return"NaN"}if(r<=-1e21||r>=1e21){return String(r)}n="";if(r<0){n="-";r=-r}i="0";if(r>1e-21){a=ie.log(r*ie.pow(2,69,1))-69;o=a<0?r*ie.pow(2,-a,1):r/ie.pow(2,a,1);o*=4503599627370496;a=52-a;if(a>0){ie.multiply(0,o);u=e;while(u>=7){ie.multiply(1e7,0);u-=7}ie.multiply(ie.pow(10,u,1),0);u=a-1;while(u>=23){ie.divide(1<<23);u-=23}ie.divide(1<<u);ie.multiply(1,1);ie.divide(2);i=ie.numToString()}else{ie.multiply(0,o);ie.multiply(1<<-a,0);i=ie.numToString()+"0.00000000000000000000".slice(2,2+e)}}if(e>0){l=i.length;if(l<=e){i=n+"0.0000000000000000000".slice(0,e-l+2)+i}else{i=n+i.slice(0,l-e)+"."+i.slice(l-e)}}else{i=n+i}return i}},ne);var ae=n.split;if("ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||"tesst".split(/(s)*/)[1]==="t"||"test".split(/(?:)/,-1).length!==4||"".split(/.?/).length||".".split(/()()/).length>1){(function(){var t=typeof/()??/.exec("")[1]==="undefined";n.split=function(e,r){var n=this;if(typeof e==="undefined"&&r===0){return[]}if(!m(e)){return ae.call(this,e,r)}var i=[],a=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":""),o=0,l,f,s,c;e=new RegExp(e.source,a+"g");n+="";if(!t){l=new RegExp("^"+e.source+"$(?!\\s)",a)}r=typeof r==="undefined"?-1>>>0:D.ToUint32(r);f=e.exec(n);while(f){s=f.index+f[0].length;if(s>o){i.push(n.slice(o,f.index));if(!t&&f.length>1){f[0].replace(l,function(){for(var t=1;t<arguments.length-2;t++){if(typeof arguments[t]==="undefined"){f[t]=void 0}}})}if(f.length>1&&f.index<n.length){u.apply(i,f.slice(1))}c=f[0].length;o=s;if(i.length>=r){break}}if(e.lastIndex===f.index){e.lastIndex++}f=e.exec(n)}if(o===n.length){if(c||!e.test("")){i.push("")}}else{i.push(n.slice(o))}return i.length>r?i.slice(0,r):i}})()}else if("0".split(void 0,0).length){n.split=function We(t,e){if(typeof t==="undefined"&&e===0){return[]}return ae.call(this,t,e)}}var oe=n.replace;var ue=function(){var t=[];"x".replace(/x(.)?/g,function(e,r){t.push(r)});return t.length===1&&typeof t[0]==="undefined"}();if(!ue){n.replace=function _e(t,e){var r=h(e);var n=m(t)&&/\)[*?]/.test(t.source);if(!r||!n){return oe.call(this,t,e)}else{var i=function(r){var n=arguments.length;var i=t.lastIndex;t.lastIndex=0;var a=t.exec(r)||[];t.lastIndex=i;a.push(arguments[n-2],arguments[n-1]);return e.apply(this,a)};return oe.call(this,t,i)}}}var le=n.substr;var fe="".substr&&"0b".substr(-1)!=="b";N(n,{substr:function tr(t,e){return le.call(this,t<0?(t=this.length+t)<0?0:t:t,e)}},fe);var se=" \n\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003"+"\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028"+"\u2029\ufeff";var ce="\u200b";var pe="["+se+"]";var he=new RegExp("^"+pe+pe+"*");var ve=new RegExp(pe+pe+"*$");var ge=n.trim&&(se.trim()||!ce.trim());N(n,{trim:function er(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return String(this).replace(he,"").replace(ve,"")}},ge);if(parseInt(se+"08")!==8||parseInt(se+"0x16")!==22){parseInt=function(t){var e=/^0[xX]/;return function r(n,i){n=String(n).trim();if(!Number(i)){i=e.test(n)?16:10}return t(n,i)}}(parseInt)}});
|
7
|
+
//# sourceMappingURL=es5-shim.map
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -16,54 +16,54 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6
|
19
|
+
version: '0.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6
|
26
|
+
version: '0.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: opal-activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sprockets-es6
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: therubyracer
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -98,30 +98,44 @@ dependencies:
|
|
98
98
|
name: sinatra
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: opal-jquery
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '10'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '10'
|
125
139
|
description: Write reactive UI component with Ruby's elegancy and compiled to run
|
126
140
|
in Javascript.
|
127
141
|
email: zeta11235813@gmail.com
|
@@ -130,10 +144,13 @@ extensions: []
|
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
146
|
- ".gitignore"
|
147
|
+
- ".travis.yml"
|
148
|
+
- CHANGELOG.md
|
133
149
|
- Gemfile
|
134
150
|
- Gemfile.lock
|
135
151
|
- LICENSE
|
136
152
|
- README.md
|
153
|
+
- Rakefile
|
137
154
|
- config.ru
|
138
155
|
- example/basic-jsx/Gemfile
|
139
156
|
- example/basic-jsx/Gemfile.lock
|
@@ -183,6 +200,7 @@ files:
|
|
183
200
|
- spec/reactjs/index.html.erb
|
184
201
|
- spec/spec_helper.rb
|
185
202
|
- spec/validator_spec.rb
|
203
|
+
- spec/vendor/es5-shim.min.js
|
186
204
|
- vendor/active_support/core_ext/array/extract_options.rb
|
187
205
|
- vendor/active_support/core_ext/class/attribute.rb
|
188
206
|
- vendor/active_support/core_ext/kernel/singleton_class.rb
|
@@ -221,3 +239,4 @@ test_files:
|
|
221
239
|
- spec/reactjs/index.html.erb
|
222
240
|
- spec/spec_helper.rb
|
223
241
|
- spec/validator_spec.rb
|
242
|
+
- spec/vendor/es5-shim.min.js
|