opal 1.8.1 → 1.8.2

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: 8af8b2b4d485065e48d45e66e00075cf3b2f3d58c358355f5cbf5c97c46cd607
4
- data.tar.gz: 87b7e4d8443eeb45953d48ca6ebb321b27269d9e7bbe2c4770c5189bcd44bcf9
3
+ metadata.gz: b8f2fff5a3c3229c43f5390af4758bb523362ea6ee1a1df8d2d90c53d502b575
4
+ data.tar.gz: 70966774cb6f97e29ed4b8516831ea94492c6f1cb83d42493a3ed88d146956a9
5
5
  SHA512:
6
- metadata.gz: 615891333955fa65566ccad7f18d7a2a65905076db6268775bb5e9f06604b56e4ebfcb8fc05d181353c1bcfbba64c195c2eb4f71b37f805e9f7984f990e56a41
7
- data.tar.gz: 1566eb09bf04acbcb49c7386ab9259cd13f8d94810e9dfecadf109b57ad2eaf479d1df419359a4a776b11aba2c7cc97d7df761c9ade46a2b8512d2718503ab69
6
+ metadata.gz: 693fe7106ef50e1bda17b92c8d548e5cd8419cfce0a4b5f2bde7accc87c905b0e407c5dd9ade1ff47249d0ffa2b8ca3d7fcbe2a12b5d1a2e45453a8a3400c72f
7
+ data.tar.gz: 22958073241a8d912931f9f3ce5c2d05674d82e74a2952f60f28664474ddc58fdf4639778ff3ac9cc67e9040ed8496aac91ab49c7de3d44a26f9687a33c96ba5
data/CHANGELOG.md CHANGED
@@ -16,7 +16,7 @@ Changes are grouped as follows:
16
16
 
17
17
 
18
18
 
19
- ## [1.8.1](https://github.com/opal/opal/compare/v1.8.0...v1.8.1) - 2023-11-09
19
+ ## [1.8.2](https://github.com/opal/opal/compare/v1.8.1...v1.8.2) - 2023-11-23
20
20
 
21
21
 
22
22
  <!--
@@ -25,9 +25,21 @@ Changes are grouped as follows:
25
25
  ### Added
26
26
  ### Removed
27
27
  ### Deprecated
28
+ -->
29
+
28
30
  ### Performance
31
+
32
+ - Optimize `Hash#rehash` for the common case, avoid calling `$slice` when no hash collision is present ([#2571](https://github.com/opal/opal/pull/2571))
33
+
29
34
  ### Fixed
30
- -->
35
+
36
+ - `String#{r,l,}strip`: Make them work like in MRI for non-breaking white-space ([#2612](https://github.com/opal/opal/pull/2612))
37
+ - Compat regression fix: `Hash#to_n` should return a JS object ([#2613](https://github.com/opal/opal/pull/2613))
38
+
39
+
40
+
41
+
42
+ ## [1.8.1](https://github.com/opal/opal/compare/v1.8.0...v1.8.1) - 2023-11-09
31
43
 
32
44
 
33
45
  ### Fixed
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.8.1'
6
+ VERSION = '1.8.2'
7
7
  end
@@ -1,8 +1,8 @@
1
1
  ::RUBY_PLATFORM = 'opal'
2
2
  ::RUBY_ENGINE = 'opal'
3
3
  ::RUBY_VERSION = '3.2.0'
4
- ::RUBY_ENGINE_VERSION = '1.8.1'
5
- ::RUBY_RELEASE_DATE = '2023-11-09'
4
+ ::RUBY_ENGINE_VERSION = '1.8.2'
5
+ ::RUBY_RELEASE_DATE = '2023-11-23'
6
6
  ::RUBY_PATCHLEVEL = 0
7
7
  ::RUBY_REVISION = '0'
8
8
  ::RUBY_COPYRIGHT = 'opal - Copyright (C) 2011-2023 Adam Beynon and the Opal contributors'
@@ -2403,7 +2403,7 @@
2403
2403
  }
2404
2404
 
2405
2405
  var objects = keys.get(key_hash),
2406
- objects_copy = $slice(objects),
2406
+ objects_copy = (objects.length === 1) ? objects : $slice(objects),
2407
2407
  object;
2408
2408
 
2409
2409
  for (var i=0; i<objects_copy.length; i++) {
@@ -724,7 +724,7 @@ class ::String < `String`
724
724
  end
725
725
 
726
726
  def lstrip
727
- `self.replace(/^[\u0000\s]*/, '')`
727
+ `self.replace(/^[\x00\x09\x0a-\x0d\x20]*/, '')`
728
728
  end
729
729
 
730
730
  def ascii_only?
@@ -1023,7 +1023,7 @@ class ::String < `String`
1023
1023
  end
1024
1024
 
1025
1025
  def rstrip
1026
- `self.replace(/[\s\u0000]*$/, '')`
1026
+ `self.replace(/[\x00\x09\x0a-\x0d\x20]*$/, '')`
1027
1027
  end
1028
1028
 
1029
1029
  def scan(pattern, no_matchdata: false, &block)
@@ -1201,7 +1201,7 @@ class ::String < `String`
1201
1201
  end
1202
1202
 
1203
1203
  def strip
1204
- `self.replace(/^[\s\u0000]*|[\s\u0000]*$/g, '')`
1204
+ `self.replace(/^[\x00\x09\x0a-\x0d\x20]*|[\x00\x09\x0a-\x0d\x20]*$/g, '')`
1205
1205
  end
1206
1206
 
1207
1207
  def sub(pattern, replacement = undefined, &block)
@@ -26,3 +26,38 @@ describe 'Encoding' do
26
26
  end
27
27
  end
28
28
  end
29
+
30
+ describe 'strip methods' do
31
+ def strip_cases(before, after, method)
32
+ before = before ? 1 : 0
33
+ after = after ? 1 : 0
34
+
35
+ it 'strip spaces' do
36
+ "#{" " * before}ABC#{" " * after}".send(method).should == "ABC"
37
+ end
38
+
39
+ it 'strips NUL bytes' do
40
+ "#{"\0" * before}ABC#{"\0" * after}".send(method).should == "ABC"
41
+ end
42
+
43
+ it "doesn't strip NBSPs" do
44
+ "#{"\u{a0}" * before}ABC#{"\u{a0}" * after}".send(method).should != "ABC"
45
+ end
46
+
47
+ it "strips all other supported whitespace characters" do
48
+ "#{"\r\n\t\v\f" * before}ABC#{"\r\n\t\v\f" * after}".send(method).should == "ABC"
49
+ end
50
+ end
51
+
52
+ describe '#lstrip' do
53
+ strip_cases true, false, :lstrip
54
+ end
55
+
56
+ describe '#rstrip' do
57
+ strip_cases false, true, :rstrip
58
+ end
59
+
60
+ describe '#strip' do
61
+ strip_cases true, true, :strip
62
+ end
63
+ end
@@ -82,14 +82,14 @@ describe Hash do
82
82
  it 'converts a hash with native objects as values' do
83
83
  obj = { 'a_key' => `{ key: 1 }` }
84
84
  native = obj.to_n
85
- `#{native}.get('a_key').key`.should == 1
85
+ `#{native}.a_key.key`.should == 1
86
86
  end
87
87
 
88
88
  it 'passes Ruby objects that cannot be converted' do
89
89
  object = Object.new
90
90
  hash = { foo: object }
91
91
  native = hash.to_n
92
- expect(`#{native}.get('foo')`).to eq object
92
+ expect(`#{native}.foo`).to eq object
93
93
  end
94
94
  end
95
95
  end
data/stdlib/native.rb CHANGED
@@ -587,14 +587,14 @@ unless Hash.method_defined? :_initialize
587
587
  }
588
588
  end
589
589
 
590
- # @return a JavaScript Map but calling #to_n on
590
+ # @return a JavaScript object, in turn also calling #to_n on
591
591
  # all keys and values.
592
592
  def to_n
593
593
  %x{
594
- var result = new Map();
594
+ var result = {};
595
595
 
596
596
  Opal.hash_each(self, false, function(key, value) {
597
- result.set(#{Native.try_convert(`key`, `key`)} , #{Native.try_convert(`value`, `value`)});
597
+ result[#{Native.try_convert(`key`, `key`)}] = #{Native.try_convert(`value`, `value`)};
598
598
  return [false, false];
599
599
  });
600
600
 
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.8.1
4
+ version: 1.8.2
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: 2023-11-09 00:00:00.000000000 Z
13
+ date: 2023-11-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ast
@@ -1230,10 +1230,10 @@ licenses:
1230
1230
  metadata:
1231
1231
  homepage_uri: https://opalrb.com/
1232
1232
  bug_tracker_uri: https://github.com/opal/opal/issues
1233
- changelog_uri: https://github.com/opal/opal/blob/v1.8.1/CHANGELOG.md
1234
- readme_uri: https://github.com/opal/opal/blob/v1.8.1/README.md
1235
- api_documentation_uri: http://opalrb.com/docs/api/v1.8.1/index.html
1236
- guides_uri: http://opalrb.com/docs/guides/v1.8.1/index.html
1233
+ changelog_uri: https://github.com/opal/opal/blob/v1.8.2/CHANGELOG.md
1234
+ readme_uri: https://github.com/opal/opal/blob/v1.8.2/README.md
1235
+ api_documentation_uri: http://opalrb.com/docs/api/v1.8.2/index.html
1236
+ guides_uri: http://opalrb.com/docs/guides/v1.8.2/index.html
1237
1237
  chat_uri: https://gitter.im/opal/opal
1238
1238
  source_code_uri: https://github.com/opal/opal
1239
1239
  post_install_message: