ruby2js 3.5.2 → 3.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby2js.rb +1 -1
- data/lib/ruby2js/rails.rb +15 -9
- data/lib/ruby2js/version.rb +1 -1
- metadata +6 -7
- data/lib/ruby2js/filter/fast-deep-equal.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0cc1907c261ee4de0bf29def31b92148ceb0b1247035db8553515106cc800b
|
4
|
+
data.tar.gz: 8141a424cf50daa57e96aea4d2a601b283377a05769e455c0c8f4ffadd3690ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2836e4593b6f4fa15be750e8c83231e90c62d5bce75768119d4ba54b7b3459601018744eba95952db906d1e5ca64a40658d6449348239056cb9297647f424f88
|
7
|
+
data.tar.gz: f009c9829447798d8b1a21fc2cf6e6033cb21c22999d73f7289de08d03edbbd1ce35b1a6f125693803758e779a779379cbd78ed291a9224e4b7cbb0a257ef1ad
|
data/lib/ruby2js.rb
CHANGED
@@ -209,7 +209,7 @@ module Ruby2JS
|
|
209
209
|
|
210
210
|
if filter.prepend_list
|
211
211
|
prepend = filter.prepend_list.sort_by {|ast| ast.type == :import ? 0 : 1}
|
212
|
-
ast = Parser::AST::Node.new(:begin, [*prepend, ast])
|
212
|
+
ast = Parser::AST::Node.new(:begin, [*prepend, ast], location: ast.location)
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
data/lib/ruby2js/rails.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Example usage:
|
2
2
|
#
|
3
|
-
# $ echo gem 'ruby2js', require: 'ruby2js/rails'
|
3
|
+
# $ echo "gem 'ruby2js', require: 'ruby2js/rails'" >> Gemfile
|
4
4
|
# $ bundle update
|
5
5
|
# $ rails generate controller Say hello
|
6
6
|
# $ echo 'alert "Hello world!"' > app/views/say/hello.js.rb
|
@@ -13,8 +13,8 @@
|
|
13
13
|
#
|
14
14
|
# Asset Pipeline:
|
15
15
|
#
|
16
|
-
# Ruby2JS registers ".
|
17
|
-
# You can add "ruby_thing.js.
|
16
|
+
# Ruby2JS registers ".rb.js" extension.
|
17
|
+
# You can add "ruby_thing.js.rb" to your app/javascript folder
|
18
18
|
# and '= require ruby_thing' from other js sources.
|
19
19
|
#
|
20
20
|
# (options are not yet supported, but by requiring the appropriate files
|
@@ -26,15 +26,17 @@ module Ruby2JS
|
|
26
26
|
class Template
|
27
27
|
cattr_accessor :default_format
|
28
28
|
self.default_format = Mime[:js]
|
29
|
-
def self.call(template)
|
30
|
-
"Ruby2JS.convert(#{template.source.inspect}).to_s"
|
29
|
+
def self.call(template, source)
|
30
|
+
"Ruby2JS.convert(#{template.source.inspect}, file: source).to_s"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
ActiveSupport.on_load(:action_view) do
|
35
|
+
ActionView::Template.register_template_handler :rb, Template
|
36
|
+
end
|
35
37
|
|
36
38
|
class SprocketProcessor
|
37
|
-
def initialize(
|
39
|
+
def initialize(file = nil)
|
38
40
|
@file = file
|
39
41
|
end
|
40
42
|
def render(context , _)
|
@@ -46,10 +48,14 @@ module Ruby2JS
|
|
46
48
|
class Engine < ::Rails::Engine
|
47
49
|
engine_name "ruby2js"
|
48
50
|
|
51
|
+
config.app_generators.javascripts true
|
52
|
+
config.app_generators.javascript_engine :rb
|
53
|
+
|
49
54
|
config.assets.configure do |env|
|
50
|
-
env.
|
55
|
+
env.register_mime_type 'text/ruby', extensions: ['.js.rb', '.rb']
|
56
|
+
env.register_transformer 'text/ruby', 'text/javascript', SprocketProcessor
|
57
|
+
env.register_preprocessor 'text/javascript', SprocketProcessor
|
51
58
|
end
|
52
|
-
|
53
59
|
end
|
54
60
|
|
55
61
|
end
|
data/lib/ruby2js/version.rb
CHANGED
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.
|
4
|
+
version: 3.5.3
|
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-11-
|
11
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -125,7 +125,6 @@ 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
|
129
128
|
- lib/ruby2js/filter/functions.rb
|
130
129
|
- lib/ruby2js/filter/jquery.rb
|
131
130
|
- lib/ruby2js/filter/matchAll.rb
|
@@ -151,7 +150,7 @@ homepage: http://github.com/rubys/ruby2js
|
|
151
150
|
licenses:
|
152
151
|
- MIT
|
153
152
|
metadata: {}
|
154
|
-
post_install_message:
|
153
|
+
post_install_message:
|
155
154
|
rdoc_options: []
|
156
155
|
require_paths:
|
157
156
|
- lib
|
@@ -166,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
165
|
- !ruby/object:Gem::Version
|
167
166
|
version: '0'
|
168
167
|
requirements: []
|
169
|
-
rubygems_version: 3.1
|
170
|
-
signing_key:
|
168
|
+
rubygems_version: 3.2.0.rc.1
|
169
|
+
signing_key:
|
171
170
|
specification_version: 4
|
172
171
|
summary: Minimal yet extensible Ruby to JavaScript conversion.
|
173
172
|
test_files: []
|
@@ -1,23 +0,0 @@
|
|
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
|