ruby2js 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +8 -3
- data/lib/ruby2js/converter/class.rb +50 -26
- data/lib/ruby2js/converter/def.rb +8 -2
- data/lib/ruby2js/converter/hash.rb +22 -15
- data/lib/ruby2js/converter/ivar.rb +1 -1
- data/lib/ruby2js/converter/opasgn.rb +3 -0
- data/lib/ruby2js/converter/return.rb +24 -1
- data/lib/ruby2js/converter/self.rb +6 -1
- data/lib/ruby2js/converter/super.rb +11 -5
- data/lib/ruby2js/converter/undef.rb +2 -1
- data/lib/ruby2js/filter/angularrb.rb +2 -0
- data/lib/ruby2js/filter/functions.rb +48 -34
- data/lib/ruby2js/version.rb +1 -1
- data/ruby2js.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTFjZjRmN2VhMTYwOWUxNTM3ZTZlNjE2NzI2NTUzMGZjMDQ5NTlkNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWE4OTZhMDMzMDBiYjNkNTQwYWE2NmYxM2I5ZDZhZGJlNGU2ZmEyMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTBiZDljMDhmODZjMjdjOWNjMmNmOTU5MjBmOTA0ODJlMjcyOWQ4NTkyN2Ux
|
10
|
+
YjQyNzI0NmRlMjQyMjEzODkzZTYwNTliN2U5ZGMxMDQ5MzJmNWRhMjVjMmVk
|
11
|
+
Y2Q0YTZmNmRiNTE3ZGFhMGE2ZDBkNmNjYjlhOWZkMTY0NWZjMjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTVjMTE5NTQyNjdlOTY5YmQ3ZjMwNTQwY2RiM2MxZjQ3Y2U4MWFiMDZkYTQx
|
14
|
+
MzUxYWE4MmI0NGIzZWRmNGI4NDZlZDFiYjY0MDRjZTIxMTczNjRhMTg3YTNk
|
15
|
+
Y2RhZDcxMDRhNmVhMWQ3YjFhMmM3N2MwODM4ZmJhOTc5MTYwNjk=
|
data/README.md
CHANGED
@@ -141,8 +141,11 @@ the script.
|
|
141
141
|
* `.any?` becomes `.some`
|
142
142
|
* `.chr` becomes `fromCharCode`
|
143
143
|
* `.clear` becomes `.length = 0`
|
144
|
+
* `.delete` becomes `delete target[arg]`
|
145
|
+
* `.downcase` becomes `.toLowerCase`
|
144
146
|
* `.each` becomes `forEach`
|
145
|
-
* `.each_with_index` becomes
|
147
|
+
* `.each_with_index` becomes `.forEach`
|
148
|
+
* `.end_with?` becomes `.slice(-arg.length) == arg`
|
146
149
|
* `.empty?` becomes `.length == 0`
|
147
150
|
* `.first` becomes `[0]`
|
148
151
|
* `.first(n)` becomes `.slice(0, n)`
|
@@ -156,11 +159,13 @@ the script.
|
|
156
159
|
* `.ord` becomes `charCodeAt(0)`
|
157
160
|
* `puts` becomes `console.log`
|
158
161
|
* `.replace` becomes `.length = 0; ...push.apply(*)`
|
159
|
-
* `.
|
162
|
+
* `.start_with?` becomes `.substring(0, arg.length) == arg`
|
163
|
+
* `.sub` becomes `.replace`
|
160
164
|
* `.to_a` becomes `to_Array`
|
161
165
|
* `.to_f` becomes `parseFloat`
|
162
166
|
* `.to_i` becomes `parseInt`
|
163
|
-
* `.to_s` becomes
|
167
|
+
* `.to_s` becomes `.to_String`
|
168
|
+
* `.upcase` becomes `.toUpperCase`
|
164
169
|
* `[-n]` becomes `[*.length-n]` for literal values of `n`
|
165
170
|
* `[n...m]` becomes `.slice(n,m)`
|
166
171
|
* `[n..m]` becomes `.slice(n,m+1)`
|
@@ -9,13 +9,19 @@ module Ruby2JS
|
|
9
9
|
# NOTE: :prop and :method macros are defined at the bottom of this file
|
10
10
|
|
11
11
|
handle :class do |name, inheritance, *body|
|
12
|
-
|
12
|
+
if inheritance
|
13
|
+
init = s(:def, :initialize, s(:args), s(:super))
|
14
|
+
else
|
15
|
+
init = s(:def, :initialize, s(:args))
|
16
|
+
end
|
17
|
+
|
13
18
|
body.compact!
|
14
19
|
|
15
20
|
if body.length == 1 and body.first.type == :begin
|
16
21
|
body = body.first.children.dup
|
17
22
|
end
|
18
23
|
|
24
|
+
body.compact!
|
19
25
|
body.map! do |m|
|
20
26
|
if m.type == :def
|
21
27
|
if m.children.first == :initialize
|
@@ -45,10 +51,28 @@ module Ruby2JS
|
|
45
51
|
s(:block, s(:send, nil, :proc), *m.children[1..-1]))
|
46
52
|
end
|
47
53
|
end
|
54
|
+
|
48
55
|
elsif m.type == :defs and m.children.first == s(:self)
|
49
|
-
|
50
|
-
|
51
|
-
s(:
|
56
|
+
if m.children[1] =~ /=$/
|
57
|
+
# class property setter
|
58
|
+
s(:prop, name, m.children[1].to_s[0..-2],
|
59
|
+
enumerable: s(:true), configurable: s(:true),
|
60
|
+
set: s(:block, s(:send, nil, :proc), *m.children[2..-1]))
|
61
|
+
elsif m.children[2].children.length == 0 and
|
62
|
+
m.children[1] !~ /!/ and m.loc and m.loc.name and
|
63
|
+
m.loc.name.source_buffer.source[m.loc.name.end_pos] != '('
|
64
|
+
|
65
|
+
# class property getter
|
66
|
+
s(:prop, name, m.children[1].to_s,
|
67
|
+
enumerable: s(:true), configurable: s(:true),
|
68
|
+
get: s(:block, s(:send, nil, :proc), m.children[2],
|
69
|
+
s(:autoreturn, *m.children[3..-1])))
|
70
|
+
else
|
71
|
+
# class method definition: add to prototype
|
72
|
+
s(:prototype, s(:send, name, "#{m.children[1]}=",
|
73
|
+
s(:block, s(:send, nil, :proc), *m.children[2..-1])))
|
74
|
+
end
|
75
|
+
|
52
76
|
elsif m.type == :send and m.children.first == nil
|
53
77
|
if m.children[1] == :attr_accessor
|
54
78
|
m.children[2..-1].map do |sym|
|
@@ -82,6 +106,7 @@ module Ruby2JS
|
|
82
106
|
# class method call
|
83
107
|
s(:send, name, *m.children[1..-1])
|
84
108
|
end
|
109
|
+
|
85
110
|
elsif m.type == :block and m.children.first.children.first == nil
|
86
111
|
# class method calls passing a block
|
87
112
|
s(:block, s(:send, name, *m.children.first.children[1..-1]),
|
@@ -117,6 +142,7 @@ module Ruby2JS
|
|
117
142
|
merge = body[i].children[2].merge(body[j].children[2])
|
118
143
|
body[j] = s(:prop, *body[j].children[0..1], merge)
|
119
144
|
body[i] = nil
|
145
|
+
break
|
120
146
|
end
|
121
147
|
end
|
122
148
|
end
|
@@ -128,11 +154,13 @@ module Ruby2JS
|
|
128
154
|
else
|
129
155
|
body.compact!
|
130
156
|
|
131
|
-
# look for first sequence of methods and properties
|
157
|
+
# look for first sequence of instance methods and properties
|
132
158
|
methods = 0
|
133
159
|
start = 0
|
134
160
|
body.each do |node|
|
135
|
-
if [:method, :prop].include? node.type
|
161
|
+
if [:method, :prop].include? node.type and
|
162
|
+
node.children[0].type == :attr and
|
163
|
+
node.children[0].children[1] == :prototype
|
136
164
|
methods += 1
|
137
165
|
elsif methods == 0
|
138
166
|
start += 1
|
@@ -173,30 +201,26 @@ module Ruby2JS
|
|
173
201
|
end
|
174
202
|
end
|
175
203
|
|
176
|
-
#
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
*descriptor.map { |key, value| s(:pair, s(:sym, key), value) }))
|
181
|
-
end
|
182
|
-
|
183
|
-
# capture methods for use by super
|
184
|
-
handle :method do |*args|
|
185
|
-
begin
|
186
|
-
instance_method, @instance_method = @instance_method, @ast
|
187
|
-
parse s(:send, *args)
|
188
|
-
ensure
|
189
|
-
@instance_method = instance_method
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
# capture constructors for use by super
|
194
|
-
handle :constructor do |*args|
|
204
|
+
# handle properties, methods, and constructors
|
205
|
+
# @block_this and @block_depth are used by self
|
206
|
+
# @instance_method is used by super and self
|
207
|
+
handle :prop, :method, :constructor do |*args|
|
195
208
|
begin
|
196
209
|
instance_method, @instance_method = @instance_method, @ast
|
197
|
-
|
210
|
+
@block_this, @block_depth = false, 0
|
211
|
+
if @ast.type == :prop
|
212
|
+
obj, prop, descriptor = *args
|
213
|
+
parse s(:send, s(:const, nil, :Object), :defineProperty,
|
214
|
+
obj, s(:sym, prop), s(:hash,
|
215
|
+
*descriptor.map { |key, value| s(:pair, s(:sym, key), value) }))
|
216
|
+
elsif @ast.type == :method
|
217
|
+
parse s(:send, *args)
|
218
|
+
else
|
219
|
+
parse s(:def, *args)
|
220
|
+
end
|
198
221
|
ensure
|
199
222
|
@instance_method = instance_method
|
223
|
+
@block_this, @block_depth = nil, nil
|
200
224
|
end
|
201
225
|
end
|
202
226
|
end
|
@@ -86,10 +86,16 @@ module Ruby2JS
|
|
86
86
|
nl = @nl unless body == s(:begin)
|
87
87
|
begin
|
88
88
|
next_token, @next_token = @next_token, :return
|
89
|
-
|
90
|
-
|
89
|
+
@block_depth += 1 if @block_depth
|
90
|
+
body = scope body, vars
|
91
|
+
if @block_this and @block_depth == 1
|
92
|
+
body = "var self = this#{@sep}#{body}"
|
93
|
+
end
|
94
|
+
|
95
|
+
"function#{ " #{name}" if name }(#{ parse args }) {#{nl}#{ body }#{nl}}"
|
91
96
|
ensure
|
92
97
|
@next_token = next_token
|
98
|
+
@block_depth -= 1 if @block_depth
|
93
99
|
end
|
94
100
|
end
|
95
101
|
end
|
@@ -8,22 +8,29 @@ module Ruby2JS
|
|
8
8
|
|
9
9
|
handle :hash do |*pairs|
|
10
10
|
pairs.map! do |node|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
begin
|
12
|
+
@block_this, @block_depth = false, 0
|
13
|
+
|
14
|
+
left, right = node.children
|
15
|
+
if left.type == :prop
|
16
|
+
result = []
|
17
|
+
if right[:get]
|
18
|
+
result << "get #{left.children[0]}#{
|
19
|
+
parse(right[:get]).sub(/^function/,'')}"
|
20
|
+
end
|
21
|
+
if right[:set]
|
22
|
+
result << "set #{left.children[0]}#{
|
23
|
+
parse(right[:set]).sub(/^function/,'')}"
|
24
|
+
end
|
25
|
+
result
|
26
|
+
else
|
27
|
+
key = parse left
|
28
|
+
key = $1 if key =~ /\A"([a-zA-Z_$][a-zA-Z_$0-9]*)"\Z/
|
29
|
+
"#{key}: #{parse right}"
|
21
30
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
key = $1 if key =~ /\A"([a-zA-Z_$][a-zA-Z_$0-9]*)"\Z/
|
26
|
-
"#{key}: #{parse right}"
|
31
|
+
|
32
|
+
ensure
|
33
|
+
@block_this, @block_depth = nil, nil
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
@@ -42,6 +42,9 @@ module Ruby2JS
|
|
42
42
|
if vtype
|
43
43
|
parse s(asgn.type, asgn.children.first, s(type,
|
44
44
|
s(vtype, asgn.children.first), value))
|
45
|
+
elsif asgn.type == :send and asgn.children[1] == :[]
|
46
|
+
parse s(:send, asgn.children.first, :[]=,
|
47
|
+
asgn.children[2], s(type, asgn, value))
|
45
48
|
else
|
46
49
|
parse s(:send, asgn.children.first, "#{asgn.children[1]}=",
|
47
50
|
s(type, asgn, value))
|
@@ -13,7 +13,7 @@ module Ruby2JS
|
|
13
13
|
end
|
14
14
|
|
15
15
|
EXPRESSIONS = [ :array, :float, :hash, :int, :lvar, :nil, :send, :attr,
|
16
|
-
:str, :sym, :dstr, :dsym, :cvar, :ivar ]
|
16
|
+
:str, :sym, :dstr, :dsym, :cvar, :ivar, :zsuper, :super, :or, :and ]
|
17
17
|
|
18
18
|
handle :autoreturn do |*statements|
|
19
19
|
return if statements == [nil]
|
@@ -24,6 +24,29 @@ module Ruby2JS
|
|
24
24
|
|
25
25
|
if EXPRESSIONS.include? block.last.type
|
26
26
|
block.push s(:return, block.pop)
|
27
|
+
elsif block.last.type == :if
|
28
|
+
node = block.pop
|
29
|
+
if node.children[1] and node.children[2] and
|
30
|
+
EXPRESSIONS.include? node.children[1].type and
|
31
|
+
EXPRESSIONS.include? node.children[2].type
|
32
|
+
node = s(:return, node)
|
33
|
+
else
|
34
|
+
conditions = [[ node.children.first,
|
35
|
+
node.children[1] ? s(:autoreturn, node.children[1]) : nil ]]
|
36
|
+
|
37
|
+
while node.children[2] and node.children[2].type == :if
|
38
|
+
node = node.children[2]
|
39
|
+
conditions.unshift [ node.children.first,
|
40
|
+
node.children[1] ? s(:autoreturn, node.children[1]) : nil ]
|
41
|
+
end
|
42
|
+
|
43
|
+
node = node.children[2] ? s(:autoreturn, node.children[2]) : nil
|
44
|
+
|
45
|
+
conditions.each do |condition, statements|
|
46
|
+
node = s(:if, condition, statements, node)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
block.push node
|
27
50
|
end
|
28
51
|
|
29
52
|
if block.length == 1
|
@@ -11,23 +11,29 @@ module Ruby2JS
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# what to call
|
14
|
-
if @instance_method.type == :
|
15
|
-
method = ".prototype.#{ @instance_method.children[1].to_s.chomp('=') }"
|
16
|
-
else
|
14
|
+
if @instance_method.type == :constructor
|
17
15
|
method = ''
|
16
|
+
else
|
17
|
+
method = ".prototype.#{ @instance_method.children[1].to_s.chomp('=') }"
|
18
18
|
end
|
19
19
|
|
20
20
|
# what to pass
|
21
21
|
if @ast.type == :zsuper
|
22
22
|
if @instance_method.type == :method
|
23
23
|
args = @instance_method.children[2].children[1].children
|
24
|
+
elsif @instance_method.type == :prop
|
25
|
+
args = nil
|
24
26
|
else
|
25
27
|
args = @instance_method.children[1].children
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
if args
|
32
|
+
args = [s(:self), *args].map {|arg| parse arg}.join(', ')
|
33
|
+
"#{ parse @class_parent }#{ method }.call(#{ args })"
|
34
|
+
else
|
35
|
+
"#{ parse @class_parent }#{ method }"
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
@@ -120,6 +120,8 @@ module Ruby2JS
|
|
120
120
|
name = node.children.first
|
121
121
|
if name.children.first == nil
|
122
122
|
@ngClassUses, @ngClassOmit = [], []
|
123
|
+
@ngClassUses << node.children[1].children[1] if node.children[1]
|
124
|
+
|
123
125
|
block = [node.children.last]
|
124
126
|
uses = extract_uses(block)
|
125
127
|
node = s(:class, name, node.children[1],
|
@@ -6,39 +6,36 @@ module Ruby2JS
|
|
6
6
|
include SEXP
|
7
7
|
|
8
8
|
def on_send(node)
|
9
|
-
target = node.children
|
10
|
-
|
11
|
-
args = node.children[2..-1]
|
9
|
+
target, method, *args = node.children
|
12
10
|
|
13
11
|
if [:max, :min].include? node.children[1] and args.length == 0
|
14
12
|
return super unless node.is_method?
|
15
13
|
process s(:send, s(:attr, s(:const, nil, :Math), node.children[1]),
|
16
14
|
:apply, s(:const, nil, :Math), target)
|
17
15
|
|
18
|
-
elsif
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
16
|
+
elsif method == :keys and args.length == 0 and node.is_method?
|
17
|
+
process s(:send, s(:const, nil, :Object), :keys, target)
|
18
|
+
|
19
|
+
elsif method == :delete and args.length == 1
|
20
|
+
process s(:undef, s(:send, target, :[], args.first))
|
24
21
|
|
25
|
-
elsif
|
22
|
+
elsif method == :to_s
|
26
23
|
process s(:send, target, :toString, *args)
|
27
24
|
|
28
|
-
elsif
|
25
|
+
elsif method == :to_a
|
29
26
|
process s(:send, target, :toArray, *args)
|
30
27
|
|
31
|
-
elsif
|
28
|
+
elsif method == :to_i
|
32
29
|
process node.updated :send, [nil, :parseInt, target, *args]
|
33
30
|
|
34
|
-
elsif
|
31
|
+
elsif method == :to_f
|
35
32
|
process node.updated :send, [nil, :parseFloat, target, *args]
|
36
33
|
|
37
|
-
elsif
|
34
|
+
elsif method == :sub and args.length == 2
|
38
35
|
process node.updated nil, [target, :replace, *args]
|
39
36
|
|
40
|
-
elsif [:sub!, :gsub!].include?
|
41
|
-
method = :"#{
|
37
|
+
elsif [:sub!, :gsub!].include? method
|
38
|
+
method = :"#{method.to_s[0..-2]}"
|
42
39
|
if target.type == :lvar
|
43
40
|
process s(:lvasgn, target.children[0], s(:send,
|
44
41
|
s(:lvar, target.children[0]), method, *node.children[2..-1]))
|
@@ -54,8 +51,8 @@ module Ruby2JS
|
|
54
51
|
super
|
55
52
|
end
|
56
53
|
|
57
|
-
elsif
|
58
|
-
|
54
|
+
elsif method == :gsub and args.length == 2
|
55
|
+
before, after = args
|
59
56
|
if before.type == :regexp
|
60
57
|
before = s(:regexp, *before.children[0...-1],
|
61
58
|
s(:regopt, :g, *before.children.last))
|
@@ -63,16 +60,16 @@ module Ruby2JS
|
|
63
60
|
before = s(:regexp, s(:str, Regexp.escape(before.children.first)),
|
64
61
|
s(:regopt, :g))
|
65
62
|
end
|
66
|
-
process node.updated nil, [
|
63
|
+
process node.updated nil, [target, :replace, before, after]
|
67
64
|
|
68
|
-
elsif
|
65
|
+
elsif method == :ord and args.length == 0
|
69
66
|
if target.type == :str
|
70
67
|
process s(:int, target.children.last.ord)
|
71
68
|
else
|
72
69
|
process node.updated nil, [target, :charCodeAt, s(:int, 0)]
|
73
70
|
end
|
74
71
|
|
75
|
-
elsif
|
72
|
+
elsif method == :chr and args.length == 0
|
76
73
|
if target.type == :int
|
77
74
|
process s(:str, target.children.last.chr)
|
78
75
|
else
|
@@ -80,31 +77,48 @@ module Ruby2JS
|
|
80
77
|
target]
|
81
78
|
end
|
82
79
|
|
83
|
-
elsif
|
80
|
+
elsif method == :empty? and args.length == 0
|
84
81
|
process s(:send, s(:attr, target, :length), :==, s(:int, 0))
|
85
82
|
|
86
|
-
elsif
|
87
|
-
if
|
88
|
-
|
83
|
+
elsif [:start_with?, :end_with?].include? method and args.length == 1
|
84
|
+
if args.first.type == :str
|
85
|
+
length = s(:int, args.first.children.first.length)
|
89
86
|
else
|
90
|
-
|
87
|
+
length = s(:attr, *args, :length)
|
91
88
|
end
|
92
89
|
|
93
|
-
|
90
|
+
if method == :start_with?
|
91
|
+
process s(:send, s(:send, target, :substring, s(:int, 0),
|
92
|
+
length), :==, *args)
|
93
|
+
else
|
94
|
+
process s(:send, s(:send, target, :slice,
|
95
|
+
s(:send, length, :-@)), :==, *args)
|
96
|
+
end
|
97
|
+
|
98
|
+
elsif method == :clear and args.length == 0 and node.is_method?
|
99
|
+
process s(:send, target, :length=, s(:int, 0))
|
100
|
+
|
101
|
+
elsif method == :replace and args.length == 1
|
94
102
|
process s(:begin, s(:send, target, :length=, s(:int, 0)),
|
95
103
|
s(:send, target, :push, s(:splat, node.children[2])))
|
96
104
|
|
97
|
-
elsif
|
105
|
+
elsif method == :include? and args.length == 1
|
98
106
|
process s(:send, s(:send, target, :indexOf, args.first), :!=,
|
99
107
|
s(:int, -1))
|
100
108
|
|
101
|
-
elsif
|
109
|
+
elsif method == :each
|
102
110
|
process node.updated nil, [target, :forEach, *args]
|
103
111
|
|
112
|
+
elsif method == :downcase and args.length == 0
|
113
|
+
process node.updated nil, [target, :toLowerCase]
|
114
|
+
|
115
|
+
elsif method == :upcase and args.length == 0
|
116
|
+
process node.updated nil, [target, :toUpperCase]
|
117
|
+
|
104
118
|
elsif node.children[0..1] == [nil, :puts]
|
105
119
|
process s(:send, s(:attr, nil, :console), :log, *args)
|
106
120
|
|
107
|
-
elsif
|
121
|
+
elsif method == :first
|
108
122
|
if node.children.length == 2
|
109
123
|
process node.updated nil, [target, :[], s(:int, 0)]
|
110
124
|
elsif node.children.length == 3
|
@@ -114,7 +128,7 @@ module Ruby2JS
|
|
114
128
|
super
|
115
129
|
end
|
116
130
|
|
117
|
-
elsif
|
131
|
+
elsif method == :last
|
118
132
|
if node.children.length == 2
|
119
133
|
process on_send node.updated nil, [target, :[], s(:int, -1)]
|
120
134
|
elsif node.children.length == 3
|
@@ -126,7 +140,7 @@ module Ruby2JS
|
|
126
140
|
end
|
127
141
|
|
128
142
|
|
129
|
-
elsif
|
143
|
+
elsif method == :[]
|
130
144
|
index = args.first
|
131
145
|
|
132
146
|
# resolve negative literal indexes
|
@@ -171,7 +185,7 @@ module Ruby2JS
|
|
171
185
|
super
|
172
186
|
end
|
173
187
|
|
174
|
-
elsif
|
188
|
+
elsif method == :reverse! and node.is_method?
|
175
189
|
# input: a.reverse!
|
176
190
|
# output: a.splice(0, a.length, *a.reverse)
|
177
191
|
target = node.children.first
|
@@ -179,7 +193,7 @@ module Ruby2JS
|
|
179
193
|
s(:attr, target, :length), s(:splat, s(:send, target,
|
180
194
|
:"#{node.children[1].to_s[0..-2]}", *node.children[2..-1])))
|
181
195
|
|
182
|
-
elsif
|
196
|
+
elsif method == :each_with_index
|
183
197
|
process node.updated nil, [target, :forEach, *args]
|
184
198
|
|
185
199
|
else
|
data/lib/ruby2js/version.rb
CHANGED
data/ruby2js.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "ruby2js"
|
5
|
-
s.version = "1.
|
5
|
+
s.version = "1.7.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sam Ruby"]
|
9
|
-
s.date = "2014-
|
9
|
+
s.date = "2014-03-06"
|
10
10
|
s.description = " The base package maps Ruby syntax to JavaScript semantics.\n Filters may be provided to add Ruby-specific or framework specific\n behavior.\n"
|
11
11
|
s.email = "rubys@intertwingly.net"
|
12
12
|
s.files = ["ruby2js.gemspec", "README.md", "lib/ruby2js", "lib/ruby2js/rails.rb", "lib/ruby2js/version.rb", "lib/ruby2js/converter", "lib/ruby2js/converter/kwbegin.rb", "lib/ruby2js/converter/const.rb", "lib/ruby2js/converter/return.rb", "lib/ruby2js/converter/prototype.rb", "lib/ruby2js/converter/opasgn.rb", "lib/ruby2js/converter/xstr.rb", "lib/ruby2js/converter/args.rb", "lib/ruby2js/converter/defs.rb", "lib/ruby2js/converter/literal.rb", "lib/ruby2js/converter/array.rb", "lib/ruby2js/converter/if.rb", "lib/ruby2js/converter/nil.rb", "lib/ruby2js/converter/logical.rb", "lib/ruby2js/converter/next.rb", "lib/ruby2js/converter/while.rb", "lib/ruby2js/converter/whilepost.rb", "lib/ruby2js/converter/arg.rb", "lib/ruby2js/converter/case.rb", "lib/ruby2js/converter/break.rb", "lib/ruby2js/converter/hash.rb", "lib/ruby2js/converter/for.rb", "lib/ruby2js/converter/boolean.rb", "lib/ruby2js/converter/module.rb", "lib/ruby2js/converter/var.rb", "lib/ruby2js/converter/undef.rb", "lib/ruby2js/converter/blockpass.rb", "lib/ruby2js/converter/until.rb", "lib/ruby2js/converter/regexp.rb", "lib/ruby2js/converter/untilpost.rb", "lib/ruby2js/converter/masgn.rb", "lib/ruby2js/converter/cvasgn.rb", "lib/ruby2js/converter/block.rb", "lib/ruby2js/converter/super.rb", "lib/ruby2js/converter/ivar.rb", "lib/ruby2js/converter/send.rb", "lib/ruby2js/converter/vasgn.rb", "lib/ruby2js/converter/defined.rb", "lib/ruby2js/converter/def.rb", "lib/ruby2js/converter/sym.rb", "lib/ruby2js/converter/cvar.rb", "lib/ruby2js/converter/ivasgn.rb", "lib/ruby2js/converter/casgn.rb", "lib/ruby2js/converter/self.rb", "lib/ruby2js/converter/begin.rb", "lib/ruby2js/converter/dstr.rb", "lib/ruby2js/converter/class.rb", "lib/ruby2js/cgi.rb", "lib/ruby2js/converter.rb", "lib/ruby2js/filter", "lib/ruby2js/filter/return.rb", "lib/ruby2js/filter/strict.rb", "lib/ruby2js/filter/angularrb.rb", "lib/ruby2js/filter/underscore.rb", "lib/ruby2js/filter/angular-resource.rb", "lib/ruby2js/filter/functions.rb", "lib/ruby2js/filter/jquery.rb", "lib/ruby2js/filter/angular-route.rb", "lib/ruby2js/sinatra.rb", "lib/ruby2js.rb"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|