opal 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b7a4b076832e2c4f5cf807f40bf1a9d7e1a0328e1ef4b245f1514ae2ff145dd
4
- data.tar.gz: 5df94eda8d910641c918d913b7421796b5e513b05600e51d1debd0cd3944cf20
3
+ metadata.gz: 3a33a6b0ec566d750d22d1bca26dcad96c9410b6c9f009c2d576d5d034d78b76
4
+ data.tar.gz: cc9550e4097c954b66d556ed11a1cb90a88336383b4ff1fc8d732117f773117e
5
5
  SHA512:
6
- metadata.gz: 04050f1589cf7ee4a3be39907e4618434659157968b63f225c6ae27a46da5f9e77c57080ca0c741aa333c3a3e48e2bbe38a3719f8540e55aefe26a3b6c4d3710
7
- data.tar.gz: 867a69aa3810572ff1636f4b6dc0df14435fa54dc06655101dde8017e71ab1892393e5a61517194f4828d596301097876e36734d9c4039f2d2109c70a011a3cb
6
+ metadata.gz: fb47426dadf8b67198eaf7efcfb5b2d91bc1c567d34247fa170e8a4644236d308bcfabf53e8e428b64728feb81da6692325b9f4dd6d93ebf14a0f0345f020e80
7
+ data.tar.gz: b2bbd78addde393c3489fd4d55f3df1d259457415a1593c2a46343943ff227bde4b668a829a434ad57444284681591fab31dcd73e68c6f1acb3677b2c3496649
data/CHANGELOG.md CHANGED
@@ -15,6 +15,20 @@ Changes are grouped as follows:
15
15
 
16
16
 
17
17
 
18
+ ## [3.0.1](https://github.com/opal/opal/compare/v1.3.0...v3.0.1) - 2021-11-03
19
+
20
+
21
+ ### Fixed
22
+
23
+ * Fix REPL if bundler environment isn't set ([#2338](https://github.com/opal/opal/pull/2338))
24
+ * Fix Chrome runner if bundler environment isn't set and make it work on other Unixes ([#2339](https://github.com/opal/opal/pull/2339))
25
+ * `Proc#binding` to return a binding if `Binding` is defined (#2341, #2340)
26
+ * `Array#zip` to correctly `yield` (#2342, #1611)
27
+ * `String#scan` to correctly `yield` (#2342, #1660)
28
+
29
+
30
+
31
+
18
32
  ## [1.3.0](https://github.com/opal/opal/compare/v1.2.0...v1.3.0) - 2021-10-27
19
33
 
20
34
 
data/UNRELEASED.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ### Added
2
2
  ### Fixed
3
+
4
+ * Fix REPL if bundler environment isn't set (#2338)
5
+ * Fix Chrome runner if bundler environment isn't set and make it work on other Unixes (#2339)
6
+ * `Proc#binding` to return a binding if `Binding` is defined (#2341, #2340)
7
+ * `Array#zip` to correctly `yield` (#2342, #1611)
8
+ * `String#scan` to correctly `yield` (#2342, #1660)
9
+
3
10
  ### Changed
4
11
  ### Deprecated
5
12
  ### Removed
data/docs/releasing.md CHANGED
@@ -14,5 +14,20 @@ _This guide is a work-in-progress._
14
14
 
15
15
  ## The commit
16
16
 
17
- - Commit the updated changelog along with the version bump using this commmit message:
17
+ - Commit the updated changelog along with the version bump using this commit message:
18
18
  "Release v1.2.3"
19
+
20
+ ## Opal docs
21
+
22
+ - Open `opal-docs` and run `bin/build v1.2.3`
23
+ - Then run `bin/deploy`
24
+
25
+ ## Opal site
26
+
27
+ - Open `opal.github.io` and update the opal version in the `Gemfile`
28
+ - run `bin/build`
29
+ - `git push` the latest changes
30
+
31
+ ## Opal CDN
32
+
33
+ - Run `bin/release v1.2.3`
@@ -4,6 +4,7 @@ require 'shellwords'
4
4
  require 'socket'
5
5
  require 'timeout'
6
6
  require 'tmpdir'
7
+ require 'rbconfig'
7
8
 
8
9
  module Opal
9
10
  module CliRunners
@@ -45,7 +46,8 @@ module Opal
45
46
  }
46
47
 
47
48
  cmd = [
48
- 'bundle', 'exec', 'opal',
49
+ RbConfig.ruby,
50
+ "#{__dir__}/../../../exe/opal",
49
51
  '--no-exit',
50
52
  '-I', __dir__,
51
53
  '-r', 'source-map-support-node',
@@ -158,7 +160,7 @@ module Opal
158
160
  end
159
161
  when /darwin|mac os/
160
162
  '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
161
- when /linux/
163
+ else
162
164
  %w[
163
165
  google-chrome-stable
164
166
  chromium
@@ -169,8 +171,6 @@ module Opal
169
171
  return name
170
172
  end
171
173
  raise 'Cannot find chrome executable'
172
- when /solaris|bsd/
173
- raise 'Headless chrome is supported only by Mac OS and Linux'
174
174
  end
175
175
  end
176
176
 
@@ -385,7 +385,7 @@ module Opal
385
385
  push ')' if push_nesting
386
386
  end
387
387
 
388
- # This can be refactored in terms of binding, but it would 'corelib/binding'
388
+ # This can be refactored in terms of binding, but it would need 'corelib/binding'
389
389
  # to be required in existing code.
390
390
  add_special :eval do |compile_default|
391
391
  next compile_default.call if arglist.children.length != 1 || ![s(:self), nil].include?(recvr)
@@ -399,7 +399,9 @@ module Opal
399
399
  push "self.$eval(#{temp}))"
400
400
  end
401
401
 
402
- add_special :binding do
402
+ add_special :binding do |compile_default|
403
+ next compile_default.call unless recvr.nil?
404
+
403
405
  push "Opal.Binding.$new("
404
406
  push " function($code, $value) {"
405
407
  push " if (typeof $value === 'undefined') {"
data/lib/opal/repl.rb CHANGED
@@ -4,6 +4,7 @@ require 'opal'
4
4
  require 'securerandom'
5
5
  require 'stringio'
6
6
  require 'fileutils'
7
+ require 'rbconfig'
7
8
 
8
9
  module Opal
9
10
  class REPL
@@ -44,7 +45,7 @@ module Opal
44
45
  def load_opal
45
46
  runner = @argv.reject { |i| i == '--repl' }
46
47
  runner += ['-e', 'require "opal/repl_js"']
47
- runner = %w[bundle exec opal] + runner
48
+ runner = [RbConfig.ruby, "#{__dir__}/../../exe/opal"] + runner
48
49
 
49
50
  @pipe = IO.popen(runner, 'r+',
50
51
  # What I try to achieve here: let the runner ignore
data/lib/opal/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  module Opal
4
4
  # WHEN RELEASING:
5
5
  # Remember to update RUBY_ENGINE_VERSION in opal/corelib/constants.rb too!
6
- VERSION = '1.3.0'
6
+ VERSION = '1.3.1'
7
7
  end
@@ -2386,7 +2386,7 @@ class Array < `Array`
2386
2386
 
2387
2387
  if (block !== nil) {
2388
2388
  for (i = 0; i < size; i++) {
2389
- block(result[i]);
2389
+ Opal.yield1(block, result[i]);
2390
2390
  }
2391
2391
 
2392
2392
  return nil;
@@ -6,7 +6,11 @@ class Binding
6
6
  end
7
7
 
8
8
  def js_eval(*args)
9
- @jseval.call(*args)
9
+ if @jseval
10
+ @jseval.call(*args)
11
+ else
12
+ raise 'Evaluation on a Proc#binding is not supported'
13
+ end
10
14
  end
11
15
 
12
16
  def local_variable_get(symbol)
@@ -1,8 +1,8 @@
1
1
  RUBY_PLATFORM = 'opal'
2
2
  RUBY_ENGINE = 'opal'
3
3
  RUBY_VERSION = '3.0.2'
4
- RUBY_ENGINE_VERSION = '1.3.0'
5
- RUBY_RELEASE_DATE = '2021-10-27'
4
+ RUBY_ENGINE_VERSION = '1.3.1'
5
+ RUBY_RELEASE_DATE = '2021-11-03'
6
6
  RUBY_PATCHLEVEL = 0
7
7
  RUBY_REVISION = '0'
8
8
  RUBY_COPYRIGHT = 'opal - Copyright (C) 2013-2021 Adam Beynon and the Opal contributors'
data/opal/corelib/proc.rb CHANGED
@@ -95,7 +95,10 @@ class Proc < `Function`
95
95
 
96
96
  def binding
97
97
  `if (self.$$is_curried) { #{raise ArgumentError, "Can't create Binding"} }`
98
- nil
98
+
99
+ if defined? Binding
100
+ Binding.new(nil, [], `self.$$s`, source_location)
101
+ end
99
102
  end
100
103
 
101
104
  def parameters
@@ -1010,7 +1010,7 @@ class String < `String`
1010
1010
  if (block === nil) {
1011
1011
  match.length == 1 ? result.push(match[0]) : result.push(#{`match_data`.captures});
1012
1012
  } else {
1013
- match.length == 1 ? block(match[0]) : block.call(self, #{`match_data`.captures});
1013
+ match.length == 1 ? Opal.yield1(block, match[0]) : Opal.yield1(block, #{`match_data`.captures});
1014
1014
  }
1015
1015
  if (pattern.lastIndex === match.index) {
1016
1016
  pattern.lastIndex += 1;
@@ -70,7 +70,9 @@ opal_filter "Kernel" do
70
70
  fails "Kernel#eval activates refinements from the binding" # NoMethodError: undefined method `refine' for #<Module:0x1ad8>
71
71
  fails "Kernel#eval activates refinements from the eval scope" # NoMethodError: undefined method `refine' for #<Module:0x20d4>
72
72
  fails "Kernel#eval allows a binding to be captured inside an eval"
73
+ fails "Kernel#eval allows creating a new class in a binding" # RuntimeError: Evaluation on a Proc#binding is not supported
73
74
  fails "Kernel#eval can be aliased"
75
+ fails "Kernel#eval does not make Proc locals visible to evaluated code" # Expected NameError but got: RuntimeError (Evaluation on a Proc#binding is not supported)
74
76
  fails "Kernel#eval does not share locals across eval scopes"
75
77
  fails "Kernel#eval doesn't accept a Proc object as a binding"
76
78
  fails "Kernel#eval evaluates string with given filename and negative linenumber" # NameError: uninitialized constant TOPLEVEL_BINDING
@@ -0,0 +1,12 @@
1
+ describe "Array#zip" do
2
+ it "respects block arity" do
3
+ foo = ['A', 'B']
4
+ values = []
5
+
6
+ foo.zip(foo) do | a,b |
7
+ values << [a, b]
8
+ end
9
+
10
+ values.should == [['A', 'A'], ['B', 'B']]
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ describe 'String#scan' do
2
+ it 'supports block argument destructuring' do
3
+ foo = []
4
+ "/foo/:bar".scan(/:(\w+)/) { |name,| foo << name }
5
+
6
+ foo.should == ["bar"]
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-10-27 00:00:00.000000000 Z
13
+ date: 2021-11-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ast
@@ -784,6 +784,7 @@ files:
784
784
  - spec/opal/core/array/minus_spec.rb
785
785
  - spec/opal/core/array/union_spec.rb
786
786
  - spec/opal/core/array/uniq_spec.rb
787
+ - spec/opal/core/array/zip_spec.rb
787
788
  - spec/opal/core/boolean_spec.rb
788
789
  - spec/opal/core/class/inherited_spec.rb
789
790
  - spec/opal/core/enumerable/all_break_spec.rb
@@ -866,6 +867,7 @@ files:
866
867
  - spec/opal/core/runtime_spec.rb
867
868
  - spec/opal/core/string/each_byte_spec.rb
868
869
  - spec/opal/core/string/gsub_spec.rb
870
+ - spec/opal/core/string/scan_spec.rb
869
871
  - spec/opal/core/string/subclassing_spec.rb
870
872
  - spec/opal/core/string/to_sym_spec.rb
871
873
  - spec/opal/core/string/unpack_spec.rb
@@ -1121,10 +1123,10 @@ licenses:
1121
1123
  metadata:
1122
1124
  homepage_uri: https://opalrb.com/
1123
1125
  bug_tracker_uri: https://github.com/opal/opal/issues
1124
- changelog_uri: https://github.com/opal/opal/blob/v1.3.0/CHANGELOG.md
1125
- readme_uri: https://github.com/opal/opal/blob/v1.3.0/README.md
1126
- api_documentation_uri: http://opalrb.com/docs/api/v1.3.0/index.html
1127
- guides_uri: http://opalrb.com/docs/guides/v1.3.0/index.html
1126
+ changelog_uri: https://github.com/opal/opal/blob/v1.3.1/CHANGELOG.md
1127
+ readme_uri: https://github.com/opal/opal/blob/v1.3.1/README.md
1128
+ api_documentation_uri: http://opalrb.com/docs/api/v1.3.1/index.html
1129
+ guides_uri: http://opalrb.com/docs/guides/v1.3.1/index.html
1128
1130
  chat_uri: https://gitter.im/opal/opal
1129
1131
  source_code_uri: https://github.com/opal/opal
1130
1132
  post_install_message: