ruby2js 2.0.1 → 2.0.2
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.
- data/lib/ruby2js/filter/react.rb +36 -1
- data/lib/ruby2js/version.rb +1 -1
- data/ruby2js.gemspec +2 -2
- metadata +2 -2
data/lib/ruby2js/filter/react.rb
CHANGED
@@ -152,7 +152,10 @@ module Ruby2JS
|
|
152
152
|
end
|
153
153
|
|
154
154
|
elsif mname == :render
|
155
|
-
if
|
155
|
+
if
|
156
|
+
block.length != 1 or not block.last or
|
157
|
+
not [:send, :block].include? block.last.type
|
158
|
+
then
|
156
159
|
# wrap multi-line blocks with a 'span' element
|
157
160
|
block = [s(:return,
|
158
161
|
s(:block, s(:send, nil, :_span), s(:args), *block))]
|
@@ -161,7 +164,9 @@ module Ruby2JS
|
|
161
164
|
elsif mname == :componentWillReceiveProps
|
162
165
|
if args.children.length == 0
|
163
166
|
args = s(:args, s(:arg, :"$$props"))
|
167
|
+
comments = @comments[child]
|
164
168
|
child = child.updated(:def, [mname, args, *block])
|
169
|
+
@comments[child] = comments unless comments.empty?
|
165
170
|
@reactProps = s(:lvar, :"$$props")
|
166
171
|
else
|
167
172
|
@reactProps = s(:lvar, args.children.first.children.last)
|
@@ -732,6 +737,36 @@ module Ruby2JS
|
|
732
737
|
end
|
733
738
|
end
|
734
739
|
end
|
740
|
+
|
741
|
+
# collapse consecutive setState calls into a single call
|
742
|
+
def on_begin(node)
|
743
|
+
node = super
|
744
|
+
(node.children.length-2).downto(0) do |i|
|
745
|
+
if
|
746
|
+
node.children[i].type == :send and
|
747
|
+
node.children[i].children[0] and
|
748
|
+
node.children[i].children[0].type == :self and
|
749
|
+
node.children[i].children[1] == :setState and
|
750
|
+
node.children[i].children[2].type == :hash and
|
751
|
+
node.children[i+1].type == :send and
|
752
|
+
node.children[i+1].children[0] and
|
753
|
+
node.children[i+1].children[0].type == :self and
|
754
|
+
node.children[i+1].children[1] == :setState and
|
755
|
+
node.children[i+1].children[2].type == :hash and
|
756
|
+
@comments[node.children[i+1]].empty?
|
757
|
+
then
|
758
|
+
pairs = node.children[i].children[2].children +
|
759
|
+
node.children[i+1].children[2].children
|
760
|
+
children = node.children.dup
|
761
|
+
children.delete_at(i)
|
762
|
+
children[i] = children[i].updated(nil, [
|
763
|
+
*children[i].children[0..1],
|
764
|
+
children[i].children[2].updated(nil, pairs)])
|
765
|
+
node = node.updated(nil, children)
|
766
|
+
end
|
767
|
+
end
|
768
|
+
node
|
769
|
+
end
|
735
770
|
end
|
736
771
|
|
737
772
|
DEFAULTS.push React
|
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 = "2.0.
|
5
|
+
s.version = "2.0.2"
|
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 = "2015-04-
|
9
|
+
s.date = "2015-04-10"
|
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/execjs.rb", "lib/ruby2js/converter.rb", "lib/ruby2js/version.rb", "lib/ruby2js/filter", "lib/ruby2js/filter/jquery.rb", "lib/ruby2js/filter/return.rb", "lib/ruby2js/filter/underscore.rb", "lib/ruby2js/filter/require.rb", "lib/ruby2js/filter/angularrb.rb", "lib/ruby2js/filter/minitest-jasmine.rb", "lib/ruby2js/filter/camelCase.rb", "lib/ruby2js/filter/rubyjs.rb", "lib/ruby2js/filter/strict.rb", "lib/ruby2js/filter/functions.rb", "lib/ruby2js/filter/angular-resource.rb", "lib/ruby2js/filter/react.rb", "lib/ruby2js/filter/angular-route.rb", "lib/ruby2js/sinatra.rb", "lib/ruby2js/rails.rb", "lib/ruby2js/serializer.rb", "lib/ruby2js/cgi.rb", "lib/ruby2js/converter", "lib/ruby2js/converter/self.rb", "lib/ruby2js/converter/arg.rb", "lib/ruby2js/converter/dstr.rb", "lib/ruby2js/converter/xstr.rb", "lib/ruby2js/converter/sym.rb", "lib/ruby2js/converter/return.rb", "lib/ruby2js/converter/break.rb", "lib/ruby2js/converter/for.rb", "lib/ruby2js/converter/defined.rb", "lib/ruby2js/converter/cvasgn.rb", "lib/ruby2js/converter/whilepost.rb", "lib/ruby2js/converter/logical.rb", "lib/ruby2js/converter/in.rb", "lib/ruby2js/converter/args.rb", "lib/ruby2js/converter/def.rb", "lib/ruby2js/converter/prototype.rb", "lib/ruby2js/converter/class.rb", "lib/ruby2js/converter/nthref.rb", "lib/ruby2js/converter/opasgn.rb", "lib/ruby2js/converter/module.rb", "lib/ruby2js/converter/kwbegin.rb", "lib/ruby2js/converter/send.rb", "lib/ruby2js/converter/boolean.rb", "lib/ruby2js/converter/masgn.rb", "lib/ruby2js/converter/hash.rb", "lib/ruby2js/converter/cvar.rb", "lib/ruby2js/converter/ivasgn.rb", "lib/ruby2js/converter/case.rb", "lib/ruby2js/converter/const.rb", "lib/ruby2js/converter/vasgn.rb", "lib/ruby2js/converter/untilpost.rb", "lib/ruby2js/converter/begin.rb", "lib/ruby2js/converter/ivar.rb", "lib/ruby2js/converter/while.rb", "lib/ruby2js/converter/next.rb", "lib/ruby2js/converter/nil.rb", "lib/ruby2js/converter/blockpass.rb", "lib/ruby2js/converter/super.rb", "lib/ruby2js/converter/defs.rb", "lib/ruby2js/converter/array.rb", "lib/ruby2js/converter/block.rb", "lib/ruby2js/converter/if.rb", "lib/ruby2js/converter/until.rb", "lib/ruby2js/converter/regexp.rb", "lib/ruby2js/converter/casgn.rb", "lib/ruby2js/converter/undef.rb", "lib/ruby2js/converter/literal.rb", "lib/ruby2js/converter/var.rb", "lib/ruby2js.rb"]
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: ruby2js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.0.
|
5
|
+
version: 2.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sam Ruby
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|