jsrb 0.2.1 → 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/.rubocop.yml +6 -5
- data/.yardopts +3 -0
- data/README.md +108 -95
- data/jsrb.gemspec +0 -2
- data/lib/jsrb/base.rb +157 -26
- data/lib/jsrb/cond_chain.rb +17 -12
- data/lib/jsrb/expr_chain.rb +90 -295
- data/lib/jsrb/js_statement_context.rb +8 -8
- data/lib/jsrb/railtie.rb +1 -1
- data/lib/jsrb/version.rb +1 -1
- metadata +2 -2
@@ -37,10 +37,10 @@ module Jsrb
|
|
37
37
|
def ruby_to_js_ast(rbv)
|
38
38
|
case rbv
|
39
39
|
when ExprChain
|
40
|
-
rbv.
|
40
|
+
rbv.object
|
41
41
|
when Proc
|
42
42
|
chainables = rbv.parameters.map do |_type, name|
|
43
|
-
new_expression
|
43
|
+
new_expression[name.to_s]
|
44
44
|
end
|
45
45
|
result, statements = in_new_context { rbv.call(*chainables) }
|
46
46
|
if result
|
@@ -63,7 +63,7 @@ module Jsrb
|
|
63
63
|
statements = rbv.map do |key, v|
|
64
64
|
{
|
65
65
|
type: 'ExpressionStatement',
|
66
|
-
expression: new_expression
|
66
|
+
expression: new_expression[var_name][key].set(v).object
|
67
67
|
}
|
68
68
|
end
|
69
69
|
{
|
@@ -71,14 +71,14 @@ module Jsrb
|
|
71
71
|
callee: {
|
72
72
|
type: 'FunctionExpression',
|
73
73
|
id: nil,
|
74
|
-
params: [new_expression
|
74
|
+
params: [new_expression[var_name].object],
|
75
75
|
body: {
|
76
76
|
type: 'BlockStatement',
|
77
77
|
body: statements.concat(
|
78
78
|
[
|
79
79
|
{
|
80
80
|
type: 'ReturnStatement',
|
81
|
-
argument: new_expression
|
81
|
+
argument: new_expression[var_name].object
|
82
82
|
}
|
83
83
|
]
|
84
84
|
)
|
@@ -99,12 +99,12 @@ module Jsrb
|
|
99
99
|
when TrueClass, FalseClass, String, NilClass
|
100
100
|
build_literal_ast(rbv)
|
101
101
|
when Float::INFINITY
|
102
|
-
new_expression
|
102
|
+
new_expression[:Number][:POSITIVE_INFINITY].object
|
103
103
|
when -Float::INFINITY
|
104
|
-
new_expression
|
104
|
+
new_expression[:Number][:NEGATIVE_INFINITY].object
|
105
105
|
when Float
|
106
106
|
if rbv.nan?
|
107
|
-
new_expression
|
107
|
+
new_expression[:Number][:NaN].object
|
108
108
|
else
|
109
109
|
build_finite_number_ast(rbv)
|
110
110
|
end
|
data/lib/jsrb/railtie.rb
CHANGED
data/lib/jsrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shun MIZUKAMI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|