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 +4 -4
- data/CHANGELOG.md +14 -2
- data/lib/opal/version.rb +1 -1
- data/opal/corelib/constants.rb +2 -2
- data/opal/corelib/runtime.js +1 -1
- data/opal/corelib/string.rb +3 -3
- data/spec/opal/core/string_spec.rb +35 -0
- data/spec/opal/stdlib/native/hash_spec.rb +2 -2
- data/stdlib/native.rb +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8f2fff5a3c3229c43f5390af4758bb523362ea6ee1a1df8d2d90c53d502b575
|
4
|
+
data.tar.gz: 70966774cb6f97e29ed4b8516831ea94492c6f1cb83d42493a3ed88d146956a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
data/opal/corelib/constants.rb
CHANGED
@@ -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.
|
5
|
-
::RUBY_RELEASE_DATE = '2023-11-
|
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'
|
data/opal/corelib/runtime.js
CHANGED
data/opal/corelib/string.rb
CHANGED
@@ -724,7 +724,7 @@ class ::String < `String`
|
|
724
724
|
end
|
725
725
|
|
726
726
|
def lstrip
|
727
|
-
`self.replace(/^[\
|
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(/[\
|
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(/^[\
|
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}.
|
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}.
|
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
|
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 =
|
594
|
+
var result = {};
|
595
595
|
|
596
596
|
Opal.hash_each(self, false, function(key, value) {
|
597
|
-
result
|
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.
|
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-
|
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.
|
1234
|
-
readme_uri: https://github.com/opal/opal/blob/v1.8.
|
1235
|
-
api_documentation_uri: http://opalrb.com/docs/api/v1.8.
|
1236
|
-
guides_uri: http://opalrb.com/docs/guides/v1.8.
|
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:
|