polyfill 1.3.0 → 1.4.0
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 +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +10 -2
- data/README.md +4 -4
- data/lib/polyfill/v2_5.rb +1 -0
- data/lib/polyfill/v2_5/string.rb +20 -0
- data/lib/polyfill/v2_5/struct.rb +29 -0
- data/lib/polyfill/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bd877508c8ce8e1361edc7a6110a52e4aba47c286002b4856e65a09eb1d9946
|
4
|
+
data.tar.gz: a6714f4cad4877c2e3ca70ffa5d34dbd88ce7b1bcd8085aa3e5d706701051bd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75accf09cefb4d4a646cfdbdf2470766003a8eabdfc415cb2d3060e97dd7a188e15b65e9f874750138bebe4ae68ce3ee01753f2132d1be7dfff0ddf94d3e9d2e
|
7
|
+
data.tar.gz: d8a7b0903aed5160246fd64b72d28aec498d104e0912112e9fe8d5e2e110296bca265dde0850c311554c88d2d143fe2dbe7d1badb81a43ffeea075a60d766af2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# [1.3.0][] (2018-09-09)
|
2
2
|
|
3
|
-
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- v2.5 String#each_grapheme_cluster
|
6
|
+
- v2.5 String#grapheme_clusters
|
7
|
+
- v2.5 Struct.new
|
8
|
+
|
9
|
+
# [1.3.0][] (2018-03-20)
|
4
10
|
|
5
11
|
## Added
|
6
12
|
|
@@ -242,6 +248,8 @@ incorrect type was passed:
|
|
242
248
|
- v2.4 String#concat?
|
243
249
|
- v2.4 String#prepend?
|
244
250
|
|
251
|
+
[1.4.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.3.0...v1.4.0
|
252
|
+
[1.3.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.2.0...v1.3.0
|
245
253
|
[1.2.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.1.0...v1.2.0
|
246
254
|
[1.1.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.0.1...v1.1.0
|
247
255
|
[1.0.1]: https://github.com/AaronLasseigne/polyfill/compare/v1.0.0...v1.0.1
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ monkey patching** that may cause issues outside of your use.
|
|
27
27
|
Add it to your Gemfile:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem 'polyfill', '~> 1.
|
30
|
+
gem 'polyfill', '~> 1.4'
|
31
31
|
```
|
32
32
|
|
33
33
|
Or install it manually:
|
@@ -219,15 +219,15 @@ though they have techically changed. `FrozenError` is a subclass of
|
|
219
219
|
| P | | #delete_prefix! | New **Differences:** Throws `RuntimeError` instead of `FrozenError` when attempting to modify a frozen string.
|
220
220
|
| ✓ | | #delete_suffix | New (alias of `chomp`)
|
221
221
|
| P | | #delete_suffix! | New (alias of `chomp!`) **Differences:** Throws `RuntimeError` instead of `FrozenError` when attempting to modify a frozen string.
|
222
|
-
|
|
223
|
-
|
|
222
|
+
| ✓ | | #each_grapheme_cluster | New
|
223
|
+
| ✓ | | #grapheme_clusters | New
|
224
224
|
| P | | #start_with? | Accepts regular expression arguments. **Differences:** Does not set `Regexp` globals.
|
225
225
|
| ✗ | | #undump | New
|
226
226
|
| ✗ | StringIO | #write | Accepts multiple arguments.
|
227
227
|
| ✗ | StringScanner | #captures | New
|
228
228
|
| ✗ | | #size | New
|
229
229
|
| ✗ | | #values_at | New
|
230
|
-
|
|
230
|
+
| ✓ | Struct | .new | Accepts a new optional keyword argument, `:keyword_init`.
|
231
231
|
| ✗ | Thread | #fetch | New
|
232
232
|
| ✗ | | #name= | Description set by `Thread#name=` is now visible on Windows 10.
|
233
233
|
| ✓ | Time | .at | Accepts a third argument which specifies the unit of the second argument.
|
data/lib/polyfill/v2_5.rb
CHANGED
data/lib/polyfill/v2_5/string.rb
CHANGED
@@ -38,6 +38,26 @@ module Polyfill
|
|
38
38
|
prefix.is_a?(Regexp) ? self[/\A#{prefix}/] : super(prefix)
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
def grapheme_clusters
|
43
|
+
return scan(/\X/, &::Proc.new) if block_given?
|
44
|
+
|
45
|
+
scan(/\X/)
|
46
|
+
end
|
47
|
+
|
48
|
+
def each_grapheme_cluster
|
49
|
+
unless block_given?
|
50
|
+
grapheme_clusters = scan(/\X/)
|
51
|
+
|
52
|
+
return ::Enumerator.new(grapheme_clusters.size) do |yielder|
|
53
|
+
grapheme_clusters.each do |grapheme_cluster|
|
54
|
+
yielder.yield(grapheme_cluster)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
scan(/\X/, &::Proc.new)
|
60
|
+
end
|
41
61
|
end
|
42
62
|
end
|
43
63
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_5
|
3
|
+
module Struct
|
4
|
+
module ClassMethods
|
5
|
+
def new(*args, keyword_init: false)
|
6
|
+
obj = super(*args)
|
7
|
+
|
8
|
+
if keyword_init
|
9
|
+
attrs = args
|
10
|
+
attrs.shift if attrs.first.class != Symbol
|
11
|
+
|
12
|
+
ignore_warnings do
|
13
|
+
obj.send(:define_method, :initialize) do |**kwargs|
|
14
|
+
invalid_args = kwargs.reject { |k, _| attrs.include?(k) }.keys
|
15
|
+
unless invalid_args.empty?
|
16
|
+
raise ArgumentError, "unknown keywords: #{invalid_args.join(', ')}"
|
17
|
+
end
|
18
|
+
|
19
|
+
super(*kwargs.values_at(*attrs))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
obj
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/polyfill/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyfill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/polyfill/v2_5/integer.rb
|
132
132
|
- lib/polyfill/v2_5/kernel.rb
|
133
133
|
- lib/polyfill/v2_5/string.rb
|
134
|
+
- lib/polyfill/v2_5/struct.rb
|
134
135
|
- lib/polyfill/v2_5/time.rb
|
135
136
|
- lib/polyfill/version.rb
|
136
137
|
- polyfill.gemspec
|
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
requirements: []
|
156
157
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.7.
|
158
|
+
rubygems_version: 2.7.6
|
158
159
|
signing_key:
|
159
160
|
specification_version: 4
|
160
161
|
summary: Adds newer Ruby methods to older versions.
|