polyfill 1.3.0 → 1.4.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: e4a9568a9912f29fcfe5b3d7a9df9710ac88a860f964cff51134563cb5d436b5
4
- data.tar.gz: c448ec3ff53bcb22390a631a72a06c6a6f33463c4b17b394e27c4315c093fb5f
3
+ metadata.gz: 5bd877508c8ce8e1361edc7a6110a52e4aba47c286002b4856e65a09eb1d9946
4
+ data.tar.gz: a6714f4cad4877c2e3ca70ffa5d34dbd88ce7b1bcd8085aa3e5d706701051bd4
5
5
  SHA512:
6
- metadata.gz: '03719c7924952b097c8b104a550701edb7afc5ee3335944b738eec527e11f0e7bf66f1bf10851c62a072675dc9fe05d3dc30faef085db6d79be4feee0a7bb4c0'
7
- data.tar.gz: b6b01572c50499d6865fd55ecc516814a6fa03a5ce8853281d4ea4263465535860d2a33e1c7bf22bc8840b151e7786ec9e6c50dba7601eedabfe102e8b546911
6
+ metadata.gz: 75accf09cefb4d4a646cfdbdf2470766003a8eabdfc415cb2d3060e97dd7a188e15b65e9f874750138bebe4ae68ce3ee01753f2132d1be7dfff0ddf94d3e9d2e
7
+ data.tar.gz: d8a7b0903aed5160246fd64b72d28aec498d104e0912112e9fe8d5e2e110296bca265dde0850c311554c88d2d143fe2dbe7d1badb81a43ffeea075a60d766af2
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.0
4
- - 2.4.2
5
- - 2.3.4
6
- - 2.2.7
3
+ - 2.5.1
4
+ - 2.4.4
5
+ - 2.3.7
6
+ - 2.2.10
7
7
  - 2.1.10
@@ -1,6 +1,12 @@
1
- # Master
1
+ # [1.3.0][] (2018-09-09)
2
2
 
3
- # [1.3.0][] (TBD)
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.3'
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
- | | | #each_grapheme_cluster | New
223
- | | | #grapheme_clusters | New
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
- | | Struct | .new | Accepts a new optional keyword argument, `:keyword_init`.
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.
@@ -4,6 +4,7 @@ require_relative 'v2_5/hash'
4
4
  require_relative 'v2_5/integer'
5
5
  require_relative 'v2_5/kernel'
6
6
  require_relative 'v2_5/string'
7
+ require_relative 'v2_5/struct'
7
8
  require_relative 'v2_5/time'
8
9
 
9
10
  require_relative 'v2_5/big_decimal'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Polyfill
2
- VERSION = Gem::Version.new('1.3.0'.freeze)
2
+ VERSION = Gem::Version.new('1.4.0'.freeze)
3
3
  end
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.3.0
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-03-20 00:00:00.000000000 Z
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.3
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.