ruby2js 2.1.18 → 2.1.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a08fc298d4b735b9baf096df5cfd8400bd0a835b
4
- data.tar.gz: '00480bb656522c7b65d21626a94383bddf9ea9f1'
3
+ metadata.gz: f7b23a1eb7fd7935ab82f280f2f2f5a4821b6166
4
+ data.tar.gz: 94d15ef972ce2ddf3f2d9e91c51197ffceed47cd
5
5
  SHA512:
6
- metadata.gz: f0e1232149f304e953d69992632d45e9dcab0ec0accd3a1a56257af1d7e32c38db29fcfdee0ca5b4decde5ee3f10159a3adc12fb9f106bcf9888fc4e47552002
7
- data.tar.gz: d9b20d5925b96b1425fe64d8febb9b9b8b640caa155db784d1fa64376c720b7940d5f62fcfafc9a7cacba72b247339ca8ee5254b15624f8418ca1cd808d7b333
6
+ metadata.gz: 1a1f7af042c2594af8ccb07dd21fcf996f4b79746dad1cf9edfddc89c5bc90cb2fbcaab4f6baeddd341a4c330db16bf76d2431463fe81b1e869cf27f1c0f02e4
7
+ data.tar.gz: dd5232baf9d596fe77a80f66372e911c5c0c504807e8e672e8e9484c8f2a5ca7f673776307510bc724843d4f55aa69591ffc094cb0e0cccc112615e5ff35b920
@@ -145,8 +145,11 @@ module Ruby2JS
145
145
 
146
146
  walk = proc do |ast|
147
147
  if ast.loc and ast.loc.expression
148
- filename = ast.loc.expression.source_buffer.name.dup.untaint
149
- @timestamps[filename] ||= File.mtime(filename) if filename
148
+ filename = ast.loc.expression.source_buffer.name
149
+ if filename
150
+ filename = filename.dup.untaint
151
+ @timestamps[filename] ||= File.mtime(filename)
152
+ end
150
153
  end
151
154
 
152
155
  ast.children.each do |child|
@@ -604,26 +604,39 @@ module Ruby2JS
604
604
  # search for the presence of a 'value' attribute
605
605
  value = hash[:attrs]['value']
606
606
 
607
- # search for the presence of a 'onChange' attribute
608
- onChange = hash['on']['input'] ||
609
- hash['on']['change'] ||
610
- hash['nativeOn']['input'] ||
611
- hash['nativeOn']['change']
607
+ if value
608
+ # search for the presence of a 'onChange' attribute
609
+ onChange = hash['on']['input'] ||
610
+ hash['on']['change'] ||
611
+ hash['nativeOn']['input'] ||
612
+ hash['nativeOn']['change']
613
+ attr = 'value'
614
+ event = 'input'
615
+ elsif tag == 'input'
616
+ value = hash[:attrs]['checked']
617
+ onChange = hash['on']['click'] ||
618
+ hash['nativeOn']['click']
619
+ attr = 'checked'
620
+ event = 'click'
621
+ end
612
622
 
613
623
  # test if value is assignable
614
624
  test = value
615
- while
616
- test and test.type == :send and test.children.length == 2 and
617
- test.children.last.instance_of? Symbol do
625
+ loop do
626
+ break unless test and test.type == :send
627
+ break unless (test.children.length == 2 and
628
+ test.children.last.instance_of? Symbol and
629
+ not [:not, :!, :*, :+, :-].include? test.children.last) or
630
+ test.children[1] == :[]
618
631
  test = test.children.first
619
632
  end
620
633
 
621
634
  if value and value.type != :cvar and (not test or
622
635
  test.is_a? Symbol or [:ivar, :cvar, :self].include? test.type)
623
636
  then
624
- hash[:domProps]['value'] ||= value
637
+ hash[:domProps][attr] ||= value
625
638
  hash[:domProps]['textContent'] ||= value if tag == 'textarea'
626
- hash[:attrs].delete('value')
639
+ hash[:attrs].delete(attr)
627
640
 
628
641
  # disable control until script is ready
629
642
  unless hash[:domProps]['disabled'] or hash[:attrs]['disabled']
@@ -633,7 +646,13 @@ module Ruby2JS
633
646
 
634
647
  # define event handler to update ivar on input events
635
648
  if not onChange
636
- update = s(:attr, s(:attr, s(:lvar, :event), :target), :value)
649
+ if attr == 'value'
650
+ update = s(:attr, s(:attr, s(:lvar, :event), :target), :value)
651
+ upargs = [s(:arg, :event)]
652
+ else
653
+ update = s(:send, value, :!)
654
+ upargs = []
655
+ end
637
656
 
638
657
  if value.type == :ivar
639
658
  assign = s(:ivasgn, value.children.first, update)
@@ -641,60 +660,16 @@ module Ruby2JS
641
660
  assign = s(:cvasgn, value.children.first, update)
642
661
  elsif value.type == :send and value.children.first == nil
643
662
  assign = value.updated :lvasgn, [value.children[1], update]
663
+ elsif value.children[1] == :[]
664
+ assign = value.updated nil, [value.children[0], :[]=,
665
+ value.children[2], update]
644
666
  else
645
667
  assign = value.updated nil, [value.children.first,
646
668
  "#{value.children[1]}=", update]
647
669
  end
648
670
 
649
- hash['on']['input'] ||=
650
- s(:block, s(:send, nil, :proc), s(:args, s(:arg, :event)),
651
- assign)
652
- end
653
- end
654
-
655
- if not value and not onChange and tag == 'input'
656
- # search for the presence of a 'checked' attribute
657
- checked = hash[:attrs]['checked']
658
-
659
- # test if value is assignable
660
- test = checked
661
- while
662
- test and test.type == :send and test.children.length == 2 and
663
- test.children.last.instance_of? Symbol do
664
- test = test.children.first
665
- end
666
-
667
- if checked and checked.type != :cvar and (not test or
668
- test.is_a? Symbol or [:ivar, :cvar, :self].include? test.type)
669
- then
670
- hash[:domProps]['checked'] ||= checked
671
- hash[:attrs].delete('checked')
672
-
673
- # disable control until script is ready
674
- unless hash[:domProps]['disabled'] or hash[:attrs]['disabled']
675
- hash[:domProps]['disabled'] = s(:false)
676
- hash[:attrs]['disabled'] = s(:true)
677
- end
678
-
679
- # define event handler to update ivar on click events
680
- if not onChange
681
- update = s(:send, checked, :!)
682
-
683
- if checked.type == :ivar
684
- assign = s(:ivasgn, checked.children.first, update)
685
- elsif checked.type == :cvar
686
- assign = s(:cvasgn, checked.children.first, update)
687
- elsif checked.type == :send and checked.children.first == nil
688
- assign = checked.updated :lvasgn, [checked.children[1],
689
- update]
690
- else
691
- assign = checked.updated nil, [checked.children.first,
692
- "#{checked.children[1]}=", update]
693
- end
694
-
695
- hash['on']['click'] ||=
696
- s(:block, s(:send, nil, :proc), s(:args), assign)
697
- end
671
+ hash['on'][event] ||=
672
+ s(:block, s(:send, nil, :proc), s(:args, *upargs), assign)
698
673
  end
699
674
  end
700
675
  end
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 1
5
- TINY = 18
5
+ TINY = 19
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/ruby2js.gemspec CHANGED
@@ -1,21 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ruby2js 2.1.18 ruby lib
2
+ # stub: ruby2js 2.1.19 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ruby2js".freeze
6
- s.version = "2.1.18"
6
+ s.version = "2.1.19"
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-30"
11
+ s.date = "2017-10-08"
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]
15
15
  s.homepage = "http://github.com/rubys/ruby2js".freeze
16
16
  s.licenses = ["MIT".freeze]
17
17
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.3".freeze)
18
- s.rubygems_version = "2.6.11".freeze
18
+ s.rubygems_version = "2.6.8".freeze
19
19
  s.summary = "Minimal yet extensible Ruby to JavaScript conversion.".freeze
20
20
 
21
21
  if s.respond_to? :specification_version then
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.18
4
+ version: 2.1.19
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-30 00:00:00.000000000 Z
11
+ date: 2017-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.6.11
128
+ rubygems_version: 2.6.8
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Minimal yet extensible Ruby to JavaScript conversion.