ruby2js 2.1.12 → 2.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby2js/filter/vue.rb +58 -7
- data/lib/ruby2js/version.rb +1 -1
- data/ruby2js.gemspec +3 -3
- 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: aa0964592b03f2fb107cd059b0be53ce6af09f2c
|
4
|
+
data.tar.gz: 6e6d30ac12b9814b00bd975cf18fe293e64a5fda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cbb3f66dc9ca5f90194c014dca58e16eb84fa2f968edef959b5b9556b13261825cbcc6b6d59d7d8ecbf1e9a10739b93c7288a4ac2166f8c623e35f77d08b6ab
|
7
|
+
data.tar.gz: ecc003b41211afd67b5de07d266a51c1664d58a3a7f74548419cde92f76eec944a49ed2c37b7656d112137a2d3f615c5493daaa5a4e5d84db45bf1b8c9fc8c2f
|
data/lib/ruby2js/filter/vue.rb
CHANGED
@@ -27,6 +27,7 @@ module Ruby2JS
|
|
27
27
|
@vue_inventory = Hash.new {|h, k| h[k] = []}
|
28
28
|
@vue_methods = []
|
29
29
|
@vue_props = []
|
30
|
+
@vue_reactive = []
|
30
31
|
super
|
31
32
|
end
|
32
33
|
|
@@ -76,8 +77,10 @@ module Ruby2JS
|
|
76
77
|
@vue_inventory = vue_walk(node)
|
77
78
|
@vue_methods = []
|
78
79
|
@vue_props = []
|
80
|
+
@vue_reactive = []
|
79
81
|
|
80
|
-
# collect instance methods (including getters and setters)
|
82
|
+
# collect instance methods (including getters and setters) and
|
83
|
+
# reactive class attributes
|
81
84
|
body.each do |statement|
|
82
85
|
if statement.type == :def
|
83
86
|
method = statement.children.first
|
@@ -91,6 +94,16 @@ module Ruby2JS
|
|
91
94
|
@vue_props << method unless @vue_props.include? method
|
92
95
|
end
|
93
96
|
end
|
97
|
+
|
98
|
+
elsif
|
99
|
+
statement.type == :send and statement.children[0] == cname and
|
100
|
+
statement.children[1].to_s.end_with? '='
|
101
|
+
then
|
102
|
+
@vue_reactive << statement.updated(:send, [
|
103
|
+
s(:attr, s(:const, nil, :Vue), :util), :defineReactive, cname,
|
104
|
+
s(:sym, statement.children[1].to_s[0..-2]),
|
105
|
+
process(statement.children[2])])
|
106
|
+
|
94
107
|
end
|
95
108
|
end
|
96
109
|
|
@@ -285,14 +298,52 @@ module Ruby2JS
|
|
285
298
|
statement.type == :defs and statement.children[0] == s(:self)
|
286
299
|
end
|
287
300
|
|
288
|
-
if class_methods.empty?
|
301
|
+
if class_methods.empty? and @vue_reactive.empty?
|
289
302
|
defn
|
290
303
|
else
|
291
304
|
s(:begin, defn, *process_all(class_methods.map {|method|
|
292
305
|
fn = if method.is_method?
|
293
|
-
|
294
|
-
|
295
|
-
s(:
|
306
|
+
if not method.children[1].to_s.end_with? '='
|
307
|
+
# class method
|
308
|
+
s(:send, s(:const, nil, cname), "#{method.children[1]}=",
|
309
|
+
s(:block, s(:send , nil, :proc), method.children[2],
|
310
|
+
*process_all(method.children[3..-1])))
|
311
|
+
else
|
312
|
+
getter = class_methods.find do |other_method|
|
313
|
+
"#{other_method.children[1]}=" == method.children[1].to_s
|
314
|
+
end
|
315
|
+
|
316
|
+
if getter
|
317
|
+
# both a getter and setter
|
318
|
+
s(:send, s(:const, nil, :Object), :defineProperty,
|
319
|
+
s(:const, nil, cname), s(:str, getter.children[1].to_s),
|
320
|
+
s(:hash, s(:pair, s(:sym, :enumerable), s(:true)),
|
321
|
+
s(:pair, s(:sym, :configurable), s(:true)),
|
322
|
+
s(:pair, s(:sym, :get), s(:block, s(:send, nil, :proc),
|
323
|
+
getter.children[2],
|
324
|
+
s(:autoreturn, process(getter.children[3])))),
|
325
|
+
s(:pair, s(:sym, :set), s(:block, s(:send, nil, :proc),
|
326
|
+
method.children[2],
|
327
|
+
*process_all(method.children[3..-1])))))
|
328
|
+
else
|
329
|
+
# setter only
|
330
|
+
s(:send, s(:const, nil, :Object), :defineProperty,
|
331
|
+
s(:const, nil, cname),
|
332
|
+
s(:str, method.children[1].to_s[0..-2]),
|
333
|
+
s(:hash, s(:pair, s(:sym, :enumerable), s(:true)),
|
334
|
+
s(:pair, s(:sym, :configurable), s(:true)),
|
335
|
+
s(:pair, s(:sym, :set), s(:block, s(:send, nil, :proc),
|
336
|
+
method.children[2],
|
337
|
+
*process_all(method.children[3..-1])))))
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
elsif
|
342
|
+
class_methods.any? do |other_method|
|
343
|
+
other_method.children[1].to_s == "#{method.children[1]}="
|
344
|
+
end
|
345
|
+
then
|
346
|
+
nil
|
296
347
|
|
297
348
|
elsif
|
298
349
|
method.children.length == 4 and
|
@@ -309,12 +360,12 @@ module Ruby2JS
|
|
309
360
|
s(:hash, s(:pair, s(:sym, :enumerable), s(:true)),
|
310
361
|
s(:pair, s(:sym, :configurable), s(:true)),
|
311
362
|
s(:pair, s(:sym, :get), s(:block, s(:send, nil, :proc),
|
312
|
-
*method.children[
|
363
|
+
method.children[2], *process_all(method.children[3..-1])))))
|
313
364
|
end
|
314
365
|
|
315
366
|
@comments[fn] = @comments[method]
|
316
367
|
fn
|
317
|
-
}))
|
368
|
+
}).compact, *@vue_reactive)
|
318
369
|
end
|
319
370
|
end
|
320
371
|
|
data/lib/ruby2js/version.rb
CHANGED
data/ruby2js.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ruby2js 2.1.
|
2
|
+
# stub: ruby2js 2.1.13 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ruby2js".freeze
|
6
|
-
s.version = "2.1.
|
6
|
+
s.version = "2.1.13"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Sam Ruby".freeze]
|
11
|
-
s.date = "2017-09-
|
11
|
+
s.date = "2017-09-28"
|
12
12
|
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".freeze
|
13
13
|
s.email = "rubys@intertwingly.net".freeze
|
14
14
|
s.files = ["README.md".freeze, "lib/ruby2js".freeze, "lib/ruby2js.rb".freeze, "lib/ruby2js/cgi.rb".freeze, "lib/ruby2js/converter".freeze, "lib/ruby2js/converter.rb".freeze, "lib/ruby2js/converter/arg.rb".freeze, "lib/ruby2js/converter/args.rb".freeze, "lib/ruby2js/converter/array.rb".freeze, "lib/ruby2js/converter/begin.rb".freeze, "lib/ruby2js/converter/block.rb".freeze, "lib/ruby2js/converter/blockpass.rb".freeze, "lib/ruby2js/converter/boolean.rb".freeze, "lib/ruby2js/converter/break.rb".freeze, "lib/ruby2js/converter/case.rb".freeze, "lib/ruby2js/converter/casgn.rb".freeze, "lib/ruby2js/converter/class.rb".freeze, "lib/ruby2js/converter/const.rb".freeze, "lib/ruby2js/converter/cvar.rb".freeze, "lib/ruby2js/converter/cvasgn.rb".freeze, "lib/ruby2js/converter/def.rb".freeze, "lib/ruby2js/converter/defined.rb".freeze, "lib/ruby2js/converter/defs.rb".freeze, "lib/ruby2js/converter/dstr.rb".freeze, "lib/ruby2js/converter/for.rb".freeze, "lib/ruby2js/converter/hash.rb".freeze, "lib/ruby2js/converter/if.rb".freeze, "lib/ruby2js/converter/in.rb".freeze, "lib/ruby2js/converter/ivar.rb".freeze, "lib/ruby2js/converter/ivasgn.rb".freeze, "lib/ruby2js/converter/kwbegin.rb".freeze, "lib/ruby2js/converter/literal.rb".freeze, "lib/ruby2js/converter/logical.rb".freeze, "lib/ruby2js/converter/masgn.rb".freeze, "lib/ruby2js/converter/module.rb".freeze, "lib/ruby2js/converter/next.rb".freeze, "lib/ruby2js/converter/nil.rb".freeze, "lib/ruby2js/converter/nthref.rb".freeze, "lib/ruby2js/converter/opasgn.rb".freeze, "lib/ruby2js/converter/prototype.rb".freeze, "lib/ruby2js/converter/regexp.rb".freeze, "lib/ruby2js/converter/return.rb".freeze, "lib/ruby2js/converter/self.rb".freeze, "lib/ruby2js/converter/send.rb".freeze, "lib/ruby2js/converter/super.rb".freeze, "lib/ruby2js/converter/sym.rb".freeze, "lib/ruby2js/converter/undef.rb".freeze, "lib/ruby2js/converter/until.rb".freeze, "lib/ruby2js/converter/untilpost.rb".freeze, "lib/ruby2js/converter/var.rb".freeze, "lib/ruby2js/converter/vasgn.rb".freeze, "lib/ruby2js/converter/while.rb".freeze, "lib/ruby2js/converter/whilepost.rb".freeze, "lib/ruby2js/converter/xstr.rb".freeze, "lib/ruby2js/execjs.rb".freeze, "lib/ruby2js/filter".freeze, "lib/ruby2js/filter/angular-resource.rb".freeze, "lib/ruby2js/filter/angular-route.rb".freeze, "lib/ruby2js/filter/angularrb.rb".freeze, "lib/ruby2js/filter/camelCase.rb".freeze, "lib/ruby2js/filter/functions.rb".freeze, "lib/ruby2js/filter/jquery.rb".freeze, "lib/ruby2js/filter/minitest-jasmine.rb".freeze, "lib/ruby2js/filter/react.rb".freeze, "lib/ruby2js/filter/require.rb".freeze, "lib/ruby2js/filter/return.rb".freeze, "lib/ruby2js/filter/rubyjs.rb".freeze, "lib/ruby2js/filter/strict.rb".freeze, "lib/ruby2js/filter/underscore.rb".freeze, "lib/ruby2js/filter/vue.rb".freeze, "lib/ruby2js/rails.rb".freeze, "lib/ruby2js/serializer.rb".freeze, "lib/ruby2js/sinatra.rb".freeze, "lib/ruby2js/version.rb".freeze, "ruby2js.gemspec".freeze]
|
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: 2.1.
|
4
|
+
version: 2.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|