ruby2js 4.2.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/lib/ruby2js/converter/match.rb +22 -1
- data/lib/ruby2js/filter/camelCase.rb +1 -1
- data/lib/ruby2js/filter/functions.rb +13 -2
- data/lib/ruby2js/sinatra.rb +1 -1
- data/lib/ruby2js/version.rb +3 -3
- data/ruby2js.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40cd0d8969ad8042e83eaad5d0c870a05e949907a8d8429ca295f12ccdce5b45
|
4
|
+
data.tar.gz: f03789a32881ceca5fb7310e9e88c96882a76a9782c8940bdfe01bf00354fcef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 719e4a55b5eb62ffd31e53eeeebfb80140d0692d3cf7675a33eb10188d1845267b4a35fe3590ed589af49c9f576430c261e568184a8a13675036510fdc01493a
|
7
|
+
data.tar.gz: d4a0962d3534066225b8500b20af25124784de5ac7d5b62d25d363b8d781d09d4a359ef2fbd945ccd2aa7b48f34b8d3564e52b18bb15c09df7e0da0b01115e42
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Minimal yet extensible Ruby to JavaScript conversion.
|
|
7
7
|
[![Gitter](https://badges.gitter.im/ruby2js/community.svg)](https://gitter.im/ruby2js/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
8
8
|
|
9
9
|
|
10
|
-
Documentation
|
10
|
+
## Documentation
|
11
11
|
---
|
12
12
|
|
13
13
|
* Visit **[ruby2js.com](https://www.ruby2js.com)** for detailed setup instructions and API reference.
|
@@ -15,8 +15,8 @@ Documentation
|
|
15
15
|
* [Try Ruby2JS online](https://ruby2js.com/demo)
|
16
16
|
|
17
17
|
|
18
|
-
Synopsis
|
19
|
-
|
18
|
+
## Synopsis
|
19
|
+
|
20
20
|
|
21
21
|
Basic:
|
22
22
|
|
@@ -44,9 +44,17 @@ Enable ES2015 support:
|
|
44
44
|
puts Ruby2JS.convert('"#{a}"', eslevel: 2015)
|
45
45
|
```
|
46
46
|
|
47
|
+
## Testing
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
1. Run `bundle install`
|
50
|
+
2. Run `bundle exec rake test_all`
|
51
|
+
|
52
|
+
## Release Process for Maintainers
|
53
|
+
|
54
|
+
1. Update the version in both `packages/ruby2js/package.json` and `lib/ruby2js/version`, ensuring they match.
|
55
|
+
2. Run `bundle exec rake release_core`
|
56
|
+
|
57
|
+
## License
|
50
58
|
|
51
59
|
(The MIT License)
|
52
60
|
|
@@ -1,7 +1,28 @@
|
|
1
1
|
module Ruby2JS
|
2
2
|
class Converter
|
3
3
|
handle :match_pattern do |value, name|
|
4
|
-
|
4
|
+
if name.type == :match_var
|
5
|
+
parse @ast.updated(:lvasgn, [name.children.first, value]), @state
|
6
|
+
elsif name.type == :hash_pattern and name.children.all? {|child| child.type == :match_var}
|
7
|
+
if es2015
|
8
|
+
put 'let { '
|
9
|
+
put name.children.map {|child| child.children[0].to_s}.join(', ')
|
10
|
+
put ' } = '
|
11
|
+
parse value
|
12
|
+
else
|
13
|
+
name.children.each_with_index do |child, index|
|
14
|
+
put @sep unless index == 0
|
15
|
+
put 'var '
|
16
|
+
put child.children[0].to_s
|
17
|
+
put ' = '
|
18
|
+
parse value
|
19
|
+
put '.'
|
20
|
+
put child.children[0].to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
raise Error.new("complex match patterns are not supported", @ast)
|
25
|
+
end
|
5
26
|
end
|
6
27
|
end
|
7
28
|
end
|
@@ -69,7 +69,7 @@ module Ruby2JS
|
|
69
69
|
def handle_generic_node(node, node_type)
|
70
70
|
return node if node.type != node_type
|
71
71
|
|
72
|
-
if node.children[0] =~ /_.*[?!\w]$/ and !ALLOWLIST.include?(node.children[0].to_s)
|
72
|
+
if node.children[0].to_s =~ /_.*[?!\w]$/ and !ALLOWLIST.include?(node.children[0].to_s)
|
73
73
|
S(node_type , camelCase(node.children[0]), *node.children[1..-1])
|
74
74
|
else
|
75
75
|
node
|
@@ -442,8 +442,12 @@ module Ruby2JS
|
|
442
442
|
S(:send, s(:const, nil, :JSON), :stringify, process(target))
|
443
443
|
|
444
444
|
elsif method == :* and target.type == :str
|
445
|
-
|
446
|
-
|
445
|
+
if es2015
|
446
|
+
process S(:send, target, :repeat, args.first)
|
447
|
+
else
|
448
|
+
process S(:send, s(:send, s(:const, nil, :Array), :new,
|
449
|
+
s(:send, args.first, :+, s(:int, 1))), :join, target)
|
450
|
+
end
|
447
451
|
|
448
452
|
elsif [:is_a?, :kind_of?].include? method and args.length == 1
|
449
453
|
if args[0].type == :const
|
@@ -589,6 +593,13 @@ module Ruby2JS
|
|
589
593
|
super
|
590
594
|
end
|
591
595
|
|
596
|
+
elsif method == :chars and args.length == 0
|
597
|
+
if es2015
|
598
|
+
S(:send, s(:const, nil, :Array), :from, target)
|
599
|
+
else
|
600
|
+
super
|
601
|
+
end
|
602
|
+
|
592
603
|
else
|
593
604
|
super
|
594
605
|
end
|
data/lib/ruby2js/sinatra.rb
CHANGED
data/lib/ruby2js/version.rb
CHANGED
data/ruby2js.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = %w(ruby2js.gemspec README.md bin/ruby2js demo/ruby2js.rb) + Dir.glob("{lib}/**/*")
|
16
16
|
s.homepage = "http://github.com/rubys/ruby2js".freeze
|
17
17
|
s.licenses = ["MIT".freeze]
|
18
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.
|
18
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.7".freeze)
|
19
19
|
s.summary = "Minimal yet extensible Ruby to JavaScript conversion.".freeze
|
20
20
|
|
21
21
|
s.executables << 'ruby2js'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parser
|
@@ -187,14 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
187
|
requirements:
|
188
188
|
- - ">="
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version: '2.
|
190
|
+
version: '2.7'
|
191
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
193
|
- - ">="
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
|
-
rubygems_version: 3.1.
|
197
|
+
rubygems_version: 3.1.4
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Minimal yet extensible Ruby to JavaScript conversion.
|