ruby2js 3.0.7 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1f6b8ccdda1317ddb72ca731897a87304b28925ed71647ce4904b05fc18daeb
4
- data.tar.gz: 4a71dd298b6c4f202036b4232b0d230617c75cea380e1f225e3869040daade3d
3
+ metadata.gz: 2990f20dc46745e6e632c5cf672ce516f3ca64819a9129024efd7cc333714638
4
+ data.tar.gz: 77df7775a4146e1e45278002737c24304b4d4f0ccdb49825c372286cfbb2a44b
5
5
  SHA512:
6
- metadata.gz: 10dd9756d3f8349b0fdb944d7a3dc2202c3cd57f23782aba500a68c02f8a5cc70a2a2c9f4dc9e5725a4bba06a45fb326ab6cdb5604aefb5ec6a397a34b10bc99
7
- data.tar.gz: 1fbb8a1e87b2215f4303718b39de422584af3e10134ae85260db649a8ddbb094edcfe7585667fc4a9cadcbf6e74939861f492bfccdce1c44c39746275f7369b4
6
+ metadata.gz: 3e0fd19ebc555112ea283f6d112cac30c47c16c3701568acd725d70115c2fe3aa9ba5870145d1ec002f8d7c7f463f26a0fe5fce9f61eb4492539638b938a8219
7
+ data.tar.gz: 8423b871acb6c37b44b4d5e2878fc8b8eba3c3114768b37a8003cccafabf137253b02f4e55c13aea447521a944662b1554d848834fe5ec61e07381dfc967d3de
@@ -335,10 +335,8 @@ module Ruby2JS
335
335
  statement.type == :defs and statement.children[0] == s(:self)
336
336
  end
337
337
 
338
- if class_methods.empty? and @vue_reactive.empty?
339
- defn
340
- else
341
- s(:begin, defn, *process_all(class_methods.map {|method|
338
+ unless class_methods.empty? and @vue_reactive.empty?
339
+ defn = s(:begin, defn, *process_all(class_methods.map {|method|
342
340
  fn = if method.is_method?
343
341
  if not method.children[1].to_s.end_with? '='
344
342
  # class method
@@ -397,6 +395,8 @@ module Ruby2JS
397
395
  fn
398
396
  }).compact, *@vue_reactive)
399
397
  end
398
+
399
+ vue_collapse_pushes(defn)
400
400
  end
401
401
 
402
402
  # expand 'wunderbar' like method calls
@@ -889,6 +889,46 @@ module Ruby2JS
889
889
  end
890
890
  end
891
891
 
892
+ # collapse consecutive pushes into a single call to push
893
+ def vue_collapse_pushes(node)
894
+ if node.type == :begin
895
+ prev = nil
896
+ (node.children.length-1).downto(0) do |i|
897
+ child = node.children[i]
898
+ if
899
+ child.type == :send and child.children[0] == s(:gvar, :$_) and
900
+ child.children[1] == :push
901
+ then
902
+ if prev
903
+ node = node.updated(nil, [*node.children[0...i],
904
+ node.children[i].updated(nil, node.children[i].children +
905
+ node.children[i+1].children[2..-1]),
906
+ *node.children[prev+1..-1]])
907
+ end
908
+ prev = i
909
+ else
910
+ prev = nil
911
+ end
912
+ end
913
+ end
914
+
915
+ # recurse
916
+ children = node.children
917
+ children.each_with_index do |child, index|
918
+ if Parser::AST::Node === child
919
+ replacement = vue_collapse_pushes(child)
920
+ unless replacement.equal? child
921
+ children = children.dup if children.frozen?
922
+ children[index] = replacement
923
+ end
924
+ end
925
+ end
926
+
927
+ node = node.updated(nil, children) unless children.frozen?
928
+
929
+ node
930
+ end
931
+
892
932
  # convert blocks to proc arguments
893
933
  def on_block(node)
894
934
  child = node.children.first
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2018-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.7.4
133
+ rubygems_version: 2.7.6
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Minimal yet extensible Ruby to JavaScript conversion.