ruby2js 3.5.0 → 3.5.1

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
  SHA256:
3
- metadata.gz: 2cdffdc5d823c8e1c36abf924de9f8a489508a5c472b5ac0dd11c42f14dfa7e1
4
- data.tar.gz: bfa2a41e9865fef31f7502ab1027f5486103434050aec92d3fe4d6044d165d52
3
+ metadata.gz: f659d6312b558d08a3ca6c1f30183d602445ed580910715909ea2b4334a114a9
4
+ data.tar.gz: 3f07730f5727ea25b95e095c7b45c19f3fb85dcc5d640e822a3a629fa88b8056
5
5
  SHA512:
6
- metadata.gz: ce19f04471f515a27d5cd13fb8beea734fb88246efe03a7ac746e29b07a96696afc5751de9d5f73f0d81d761de7bd8d853197e7d0ce7ce68eab0796524f2b222
7
- data.tar.gz: 70080cf83c65cfe8d8c6aaa6067ae191df714dfe838977e5be50902624f4e516a680ee0459fcdd8d7274834e29841df5ec592e6ee31dfe990dea305f457c1707
6
+ metadata.gz: a85a3d7f144485575608cd136d764e36868d095fb8dbf4f6bc8b8adb8a218379775eeb12934c148574cac0f03dc6e12fc6223ef302973b5f4cb0a0629ba41de4
7
+ data.tar.gz: 4c154cd393ce76cc0f72e23180fbfdd1b0b8e876a5d60686d246e9f53effff1c4f4ce4ea3c5573cf9ac5cb7cfcda3d2300ee865c2d8d21855a717fa8f203de4a
data/README.md CHANGED
@@ -81,6 +81,12 @@ require 'ruby2js/filter/functions'
81
81
  puts Ruby2JS.convert('"2A".to_i(16)')
82
82
  ```
83
83
 
84
+ Host variable substitution:
85
+
86
+ ```ruby
87
+ puts Ruby2JS.convert("@name", ivars: {:@name => "Joe"})
88
+ ```
89
+
84
90
  Enable ES2015 support:
85
91
 
86
92
  ```ruby
@@ -3,9 +3,11 @@ require 'ruby2js/serializer'
3
3
  module Ruby2JS
4
4
  class Error < NotImplementedError
5
5
  def initialize(message, ast)
6
- message += ' at ' + ast.loc.expression.source_buffer.name.to_s
7
- message += ':' + ast.loc.expression.line.inspect
8
- message += ':' + ast.loc.expression.column.to_s
6
+ if ast.loc
7
+ message += ' at ' + ast.loc.expression.source_buffer.name.to_s
8
+ message += ':' + ast.loc.expression.line.inspect
9
+ message += ':' + ast.loc.expression.column.to_s
10
+ end
9
11
  super(message)
10
12
  end
11
13
  end
@@ -16,8 +16,16 @@ module Ruby2JS
16
16
  handle :hostvalue do |value|
17
17
  case value
18
18
  when Hash
19
- parse s(:hash, *value.map {|key, hvalue| s(:pair, s(:hostvalue, key),
20
- s(:hostvalue, hvalue))})
19
+ parse s(:hash, *value.map {|key, hvalue|
20
+ case key
21
+ when String
22
+ s(:pair, s(:str, key), s(:hostvalue, hvalue))
23
+ when Symbol
24
+ s(:pair, s(:sym, key), s(:hostvalue, hvalue))
25
+ else
26
+ s(:pair, s(:hostvalue, key), s(:hostvalue, hvalue))
27
+ end
28
+ })
21
29
  when Array
22
30
  parse s(:array, *value.map {|hvalue| s(:hostvalue, hvalue)})
23
31
  when String
@@ -0,0 +1,23 @@
1
+ require 'ruby2js'
2
+
3
+ module Ruby2JS
4
+ module Filter
5
+ module Fast_Deep_Equal
6
+ include SEXP
7
+
8
+ SCALAR = [ :float, :int, :nil, :str ]
9
+
10
+ def on_send(node)
11
+ return super unless node.children.length == 3
12
+ left, method, right = node.children
13
+ return super unless method == :==
14
+ return super if SCALAR.include? left.type
15
+ return super if SCALAR.include? right.type
16
+
17
+ node.updated nil, [nil, :$eq, left, right]
18
+ end
19
+ end
20
+
21
+ DEFAULTS.push Fast_Deep_Equal
22
+ end
23
+ end
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 5
5
- TINY = 0
5
+ TINY = 1
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.5.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-31 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -125,6 +125,7 @@ files:
125
125
  - lib/ruby2js/filter/cjs.rb
126
126
  - lib/ruby2js/filter/esm.rb
127
127
  - lib/ruby2js/filter/esm_migration.rb
128
+ - lib/ruby2js/filter/fast-deep-equal.rb
128
129
  - lib/ruby2js/filter/functions.rb
129
130
  - lib/ruby2js/filter/jquery.rb
130
131
  - lib/ruby2js/filter/matchAll.rb
@@ -149,7 +150,7 @@ homepage: http://github.com/rubys/ruby2js
149
150
  licenses:
150
151
  - MIT
151
152
  metadata: {}
152
- post_install_message:
153
+ post_install_message:
153
154
  rdoc_options: []
154
155
  require_paths:
155
156
  - lib
@@ -164,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  - !ruby/object:Gem::Version
165
166
  version: '0'
166
167
  requirements: []
167
- rubygems_version: 3.2.0.rc.1
168
- signing_key:
168
+ rubygems_version: 3.1.2
169
+ signing_key:
169
170
  specification_version: 4
170
171
  summary: Minimal yet extensible Ruby to JavaScript conversion.
171
172
  test_files: []