execjs 2.9.0 → 2.10.0

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: 62270ddc7b87cd04ea4c4c652a0a58a22b067051a07e31c2f48b05246566bfbc
4
- data.tar.gz: b5ba2f65f36600db563faeb4e526e67f01927879d239e16e96e4861fa83121da
3
+ metadata.gz: b5608786a34b58a8a7f8a09df2a3fec055a1e00064b5f56e0c24b05c01c33088
4
+ data.tar.gz: b5c80c0022c4c8d15466effb2f58fb1fc07f8e7cb2ba7bb44b0a0c764c82438d
5
5
  SHA512:
6
- metadata.gz: 79e1992e371a9e182eed6aaa4b0efef15db4909f44cd981a701c83f954a9e0b7a59fb1459e5a9b332d2cd3f0f8aa3f9273789badfefe89fe5f3bcfc918d02c50
7
- data.tar.gz: aec6e50425979484e5913f5c64c3acb1417a1ac2c72659f01defec23704bee3a0be558800fd486df1bb8eb575b0daa7b86cd15bcbfd04c1242b400fe37f70667
6
+ metadata.gz: 0e889653dcb5c76b7b7bfad4ac46135174f8f0cd0fd5e58b63d2d3c1ed6812b1e37e772223c46aba1afeab58b9eb32b7fed8d7686e55465ae12fa67640405ded
7
+ data.tar.gz: 327326bebc0135ba9d2964d28bff46e6db20801d9842760e247e960a4da55789efc5046071f34314bbe9e0e0f978c50289412dde9b10d03daa95e87b5eb8f608
data/README.md CHANGED
@@ -31,14 +31,30 @@ A longer example, demonstrating how to invoke the CoffeeScript compiler:
31
31
 
32
32
  ``` ruby
33
33
  require "execjs"
34
- require "open-uri"
35
- source = open("http://coffeescript.org/extras/coffee-script.js").read
34
+ require "net/http"
35
+ source = Net::HTTP.get(URI("https://coffeescript.org/browser-compiler-legacy/coffeescript.js"))
36
36
 
37
37
  context = ExecJS.compile(source)
38
38
  context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true)
39
39
  # => "var square;\nsquare = function(x) {\n return x * x;\n};"
40
40
  ```
41
41
 
42
+ # Forcing a specific runtime
43
+
44
+ If you'd like to use a specific runtime rather than the autodetected one, you can assign `ExecJS.runtime`:
45
+
46
+ ```ruby
47
+ ExecJS.runtime = ExecJS::Runtimes::Node
48
+ ```
49
+
50
+ Alternatively, you can define it via the `EXECJS_RUNTIME` environment variable:
51
+
52
+ ```bash
53
+ EXECJS_RUNTIME=Node ruby ...
54
+ ```
55
+
56
+ You can find the list of possible runtimes in [`lib/execjs/runtimes.rb`](https://github.com/rails/execjs/blob/master/lib/execjs/runtimes.rb).
57
+
42
58
  # Installation
43
59
 
44
60
  ```
@@ -49,7 +65,7 @@ $ gem install execjs
49
65
 
50
66
  **Why can't I use CommonJS `require()` inside ExecJS?**
51
67
 
52
- ExecJS provides a lowest common denominator interface to any JavaScript runtime.
68
+ ExecJS provides the lowest common denominator interface to any JavaScript runtime.
53
69
  Use ExecJS when it doesn't matter which JavaScript interpreter your code runs
54
70
  in. If you want to access the Node API, you should check another library like
55
71
  [commonjs.rb](https://github.com/cowboyd/commonjs.rb) designed to provide a
@@ -76,7 +92,7 @@ You shouldn't use `ExecJS.eval` on any inputs you wouldn't feel comfortable Ruby
76
92
 
77
93
  ## Contributing to ExecJS
78
94
 
79
- ExecJS is work of dozens of contributors. You're encouraged to submit pull requests, propose
95
+ ExecJS is the work of dozens of contributors. You're encouraged to submit pull requests, propose
80
96
  features and discuss issues.
81
97
 
82
98
  See [CONTRIBUTING](CONTRIBUTING.md).
@@ -194,7 +194,7 @@ module ExecJS
194
194
  require 'shellwords'
195
195
 
196
196
  def exec_runtime(filename)
197
- command = "#{Shellwords.join(binary.split(' ') << filename)} 2>&1"
197
+ command = "#{Shellwords.join(binary.split(' ') << filename)}"
198
198
  io = IO.popen(command, **@popen_options)
199
199
  output = io.read
200
200
  io.close
@@ -207,7 +207,7 @@ module ExecJS
207
207
  end
208
208
  else
209
209
  def exec_runtime(filename)
210
- io = IO.popen(binary.split(' ') << filename, **(@popen_options.merge({err: [:child, :out]})))
210
+ io = IO.popen(binary.split(' ') << filename, **@popen_options)
211
211
  output = io.read
212
212
  io.close
213
213
 
@@ -136,8 +136,7 @@ module ExecJS
136
136
 
137
137
  unless Polyglot.languages.include? "js"
138
138
  warn "The language 'js' is not available, you likely need to `export TRUFFLERUBYOPT='--jvm --polyglot'`", uplevel: 0 if $VERBOSE
139
- warn "You also need to install the 'js' component with 'gu install js' on GraalVM 22.2+", uplevel: 0 if $VERBOSE
140
- warn "Note that you need TruffleRuby+GraalVM and not just the TruffleRuby standalone to use #{self.class}", uplevel: 0 if $VERBOSE
139
+ warn "You also need to install the 'js' component, see https://github.com/oracle/truffleruby/blob/master/doc/user/polyglot.md#installing-other-languages", uplevel: 0 if $VERBOSE
141
140
  return @available = false
142
141
  end
143
142
 
@@ -1,17 +1,17 @@
1
- (function(program, execJS) { (function() {execJS(program) }).call({}); })(function(self, global, process, module, exports, require, console, setTimeout, setInterval, clearTimeout, clearInterval, setImmediate, clearImmediate) { #{source}
2
- }, function(program) {
1
+ (function(program, execJS) { (function() {execJS(program) }).call({}); })(async function(self, global, process, module, exports, require, console, setTimeout, setInterval, clearTimeout, clearInterval, setImmediate, clearImmediate) { #{source}
2
+ }, async function(program) {
3
3
  // Force BunJS to use sloppy mode see https://github.com/oven-sh/bun/issues/4527#issuecomment-1709520894
4
4
  exports.abc = function(){}
5
5
  var __process__ = process;
6
6
  var printFinal = function(string) {
7
- process.stdout.write('' + string, function() {
7
+ Bun.write(Bun.stdout, '' + string).then(function() {
8
8
  __process__.exit(0);
9
9
  });
10
10
  };
11
11
  try {
12
12
  delete this.process;
13
13
  delete this.console;
14
- result = program();
14
+ result = await program();
15
15
  process = __process__;
16
16
  if (typeof result == 'undefined' && result !== null) {
17
17
  printFinal('["ok"]');
@@ -1,3 +1,3 @@
1
1
  module ExecJS
2
- VERSION = "2.9.0"
2
+ VERSION = "2.10.0"
3
3
  end
data/lib/execjs.rb CHANGED
@@ -2,5 +2,7 @@ require "execjs/module"
2
2
  require "execjs/runtimes"
3
3
 
4
4
  module ExecJS
5
- self.runtime ||= Runtimes.autodetect
5
+ def self.runtime
6
+ @runtime ||= Runtimes.autodetect
7
+ end
6
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: execjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-11 00:00:00.000000000 Z
12
+ date: 2024-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -65,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.9.3
68
+ version: 2.5.0
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.3.7
75
+ rubygems_version: 3.5.11
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Run JavaScript code from Ruby