polyfill 1.6.0 → 1.7.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
- SHA1:
3
- metadata.gz: abbe75af7f9dd890000179e6ff1bf1e1b318f80c
4
- data.tar.gz: b40604b5b2f481a52bd7267611c58087722d369e
2
+ SHA256:
3
+ metadata.gz: da8a7a5cae9da8f2896ddbc1c753dbe8251fa5f5f5390f868a7305a7551b3af8
4
+ data.tar.gz: 8ed0b4fecb7f5e0dd252c5bc4b09fa691e47845180cd8d1cc694a2c7ddedba40
5
5
  SHA512:
6
- metadata.gz: 5eae3186647933600a334c9cc55140ed025c8ff2ba152f6aedad77e43f4fd143e2a05809ff3482f6fd752ea001eba943fe290374cb4b94c08698cd98241c97d9
7
- data.tar.gz: 32b261215a431459c34dfaaf8728d9d31f3db30b1bf2a49c51f814d75c1246f4a41ec36fcf83964c3998d2a469175c25020f00b6263102b06548eb0d4b345236
6
+ metadata.gz: d364680af4e24583da1d5a3e4487878c9785ba0c3c1c2f34022b2c04740416fd825ac2b25937d648aa47539f4896b30a1e09a32a5bdcefeb95da19263d72c1f6
7
+ data.tar.gz: 967a450eaa070cbea6b228ef2dc56c527e34a5a8d31f283e48cb8ec440ebf876bef76b6db6186fa9c0822ea877dd26738549f50d63fb28b66cdbb896187da4e2
@@ -1,5 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.1
3
+ Layout/MultilineMethodCallIndentation:
4
+ EnforcedStyle: indented
3
5
  Metrics/AbcSize:
4
6
  Enabled: false
5
7
  Metrics/BlockLength:
@@ -12,20 +14,22 @@ Metrics/MethodLength:
12
14
  Enabled: false
13
15
  Metrics/PerceivedComplexity:
14
16
  Enabled: false
17
+ Naming/ClassAndModuleCamelCase:
18
+ Enabled: false
19
+ Naming/UncommunicativeMethodParamName:
20
+ Enabled: false
21
+ Style/AccessModifierDeclarations:
22
+ Enabled: false
15
23
  Style/AsciiComments:
16
24
  Enabled: false
17
25
  Style/BarePercentLiterals:
18
26
  EnforcedStyle: percent_q
19
- Style/ClassAndModuleCamelCase:
20
- Enabled: false
21
27
  Style/Documentation:
22
28
  Enabled: false
23
29
  Style/DoubleNegation:
24
30
  Enabled: false
25
31
  Style/FrozenStringLiteralComment:
26
32
  Enabled: false
27
- Style/MultilineMethodCallIndentation:
28
- EnforcedStyle: indented
29
33
  Style/NumericPredicate:
30
34
  EnforcedStyle: comparison
31
35
  Style/PercentLiteralDelimiters:
@@ -33,3 +37,5 @@ Style/PercentLiteralDelimiters:
33
37
  '%W': '[]'
34
38
  '%i': '[]'
35
39
  '%w': '[]'
40
+ Style/YodaCondition:
41
+ Enabled: false
@@ -1,3 +1,13 @@
1
+ # [1.7.0][] (2019-02-17)
2
+
3
+ ## Added
4
+
5
+ - v2.6 Array#difference
6
+ - v2.6 Array#union
7
+ - v2.6 Hash#merge!
8
+ - v2.6 Hash#update
9
+ - v2.6 String#split
10
+
1
11
  # [1.6.0][] (2019-02-01)
2
12
 
3
13
  ## Added
@@ -264,6 +274,7 @@ incorrect type was passed:
264
274
  - v2.4 String#concat?
265
275
  - v2.4 String#prepend?
266
276
 
277
+ [1.7.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.6.0...v1.7.0
267
278
  [1.6.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.5.0...v1.6.0
268
279
  [1.5.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.4.0...v1.5.0
269
280
  [1.4.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.3.0...v1.4.0
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Polyfill
2
2
 
3
- [![Version](https://badge.fury.io/rb/polyfill.svg)](https://rubygems.org/gems/polyfill)
4
- [![Build](https://travis-ci.org/AaronLasseigne/polyfill.svg?branch=master)](https://travis-ci.org/AaronLasseigne/polyfill)
3
+ [![Version](https://img.shields.io/gem/v/polyfill.svg?style=flat-square)](https://rubygems.org/gems/polyfill)
4
+ [![Build](https://img.shields.io/travis/AaronLasseigne/polyfill.svg?style=flat-square)](https://travis-ci.org/AaronLasseigne/polyfill)
5
5
 
6
6
  Polyfill implements newer Ruby features into older versions. If the Ruby
7
7
  version already supports the polyfill then calling it does nothing. This is
@@ -28,7 +28,7 @@ monkey patching** that may cause issues outside of your use.
28
28
  Add it to your Gemfile:
29
29
 
30
30
  ```ruby
31
- gem 'polyfill', '~> 1.6'
31
+ gem 'polyfill', '~> 1.7'
32
32
  ```
33
33
 
34
34
  Or install it manually:
@@ -130,11 +130,11 @@ table. The explanation will follow "**Differences:**".
130
130
 
131
131
  | | Object | Method | Changes |
132
132
  |:-:| ---------------- | -------------------------- | ------- |
133
- | | Array | #difference | New
133
+ | | Array | #difference | New
134
134
  | ✗ | | #filter | New (alias of `select`)
135
135
  | ✗ | | #filter! | New (alias of `select!`)
136
136
  | ✗ | | #to_h | Accepts a block that maps elements to new key/value pairs.
137
- | | | #union | New
137
+ | | | #union | New
138
138
  | ✗ | Binding | #source_location | New
139
139
  | ✗ | Coverage | .line_stub | New
140
140
  | ✗ | | .result | Accepts new optional keyword arguments, `:clear` and `:stop`.
@@ -149,19 +149,19 @@ table. The explanation will follow "**Differences:**".
149
149
  | ✗ | ENV | #to_h | Accepts a block that maps elements to new key/value pairs.
150
150
  | ✗ | ERB | .new | Accepts new optional keyword arguments, `:eoutvar` and `:trim_mode`.
151
151
  | ✗ | Exception | #full_message | Accepts new optional keyword arguments, `:highlight` and `:order`.
152
- | ✗ | File | .binread | Does not invoke external commands even if the path starts with `|`.
153
- | ✗ | | .binwrite | Does not invoke external commands even if the path starts with `|`.
154
- | ✗ | | .foreach | Does not invoke external commands even if the path starts with `|`.
155
- | ✗ | | .read | Does not invoke external commands even if the path starts with `|`.
156
- | ✗ | | .readlines | Does not invoke external commands even if the path starts with `|`.
157
- | ✗ | | .write | Does not invoke external commands even if the path starts with `|`.
152
+ | ✗ | File | .binread | Does not invoke external commands even if the path starts with `\|`.
153
+ | ✗ | | .binwrite | Does not invoke external commands even if the path starts with `\|`.
154
+ | ✗ | | .foreach | Does not invoke external commands even if the path starts with `\|`.
155
+ | ✗ | | .read | Does not invoke external commands even if the path starts with `\|`.
156
+ | ✗ | | .readlines | Does not invoke external commands even if the path starts with `\|`.
157
+ | ✗ | | .write | Does not invoke external commands even if the path starts with `\|`.
158
158
  | ✗ | FileUtils | #cp_lr | New
159
159
  | ✗ | Hash | #filter | New (alias of `select`)
160
160
  | ✗ | | #filter! | New (alias of `select!`)
161
161
  | ✓ | | #merge | Accepts multiple arguments.
162
- | | | #merge! | Accepts multiple arguments.
162
+ | | | #merge! | Accepts multiple arguments.
163
163
  | ✗ | | #to_h | Accepts a block that maps elements to new key/value pairs.
164
- | | | #update | Accepts multiple arguments.
164
+ | | | #update | Accepts multiple arguments.
165
165
  | ✗ | Kernel | #BigDecimal | Accepts a new optional keyword argument, `:exception`.
166
166
  | ✗ | | #Complex | Accepts a new optional keyword argument, `:exception`.
167
167
  | ✗ | | #exec | Does not close non-standard file descriptors.
@@ -188,7 +188,6 @@ table. The explanation will follow "**Differences:**".
188
188
  | ✗ | NilClass | #=~ | New
189
189
  | ✗ | NoMethodError | .new | Accepts new optional keyword arguments, `:receiver` and `:key`.
190
190
  | ✗ | Numeric | #step | Now returns an instance of the Enumerator::ArithmeticSequence class rather than one of the Enumerator class.
191
- | ✗ | Object | #=~ | Warns that it is deprecated.
192
191
  | ✗ | OpenStruct | #to_h | Accepts a block that maps keys and values to new keys and values.
193
192
  | ✗ | Proc | #<< | New
194
193
  | ✗ | | #>> | New
@@ -200,8 +199,7 @@ table. The explanation will follow "**Differences:**".
200
199
  | ✗ | | #step | Now returns an instance of the Enumerator::ArithmeticSequence class rather than one of the Enumerator class.
201
200
  | ✗ | RSS::Parser | .parse | Accepts options as a Hash. Options are `:ignore_unknown_element`, `:parser_class`, and `:validate`.
202
201
  | ✗ | Set | #filter! | New (alias of `select!`)
203
- | | String | #crypt | Warns that it is deprecated.
204
- | ✗ | | #split | Yields each substring to a block if given.
202
+ | | String | #split | Yields each substring to a block if given.
205
203
  | ✗ | Struct | #filter | New (alias of `select`)
206
204
  | ✗ | | #to_h | Accepts a block that maps keys and values to new keys and values.
207
205
  | ✗ | Time | #+ | Preserves the timezone.
@@ -487,7 +485,6 @@ though they have techically changed. `FrozenError` is a subclass of
487
485
  | ✓ | Numeric | #negative? | New
488
486
  | ✓ | | #positive? | New
489
487
  | ✗ | Object | #define_singleton_method | Now requires a method body, `Proc`, `Method`, or a block.
490
- | ✗ | | #timeout | Warns that it is deprecated.
491
488
  | ✗ | ObjectSpace | .count_symbols | New
492
489
  | ✗ | | .count_imemo_objects | New
493
490
  | ✗ | | .internal_class_of | New
@@ -61,7 +61,7 @@ module Polyfill
61
61
  module_function :get
62
62
  end
63
63
 
64
- def Polyfill(options = {}) # rubocop:disable Style/MethodName
64
+ def Polyfill(options = {}) # rubocop:disable Naming/MethodName
65
65
  #
66
66
  # parse options
67
67
  #
@@ -27,7 +27,7 @@ module Polyfill
27
27
  def polyfill_versions_to_use(desired_version = nil)
28
28
  desired_version = VERSIONS.keys.max if desired_version.nil?
29
29
 
30
- unless VERSIONS.keys.include?(desired_version)
30
+ unless VERSIONS.key?(desired_version)
31
31
  raise ArgumentError, "invalid value for keyword version: #{desired_version}"
32
32
  end
33
33
 
@@ -2,7 +2,7 @@ module Polyfill
2
2
  module V2_4
3
3
  module Regexp
4
4
  def match?(string, position = 0)
5
- !!(string[position..-1] =~ self) # rubocop:disable Style/InverseMethods
5
+ !!(string[position..-1] =~ self)
6
6
  end
7
7
  end
8
8
  end
@@ -95,7 +95,7 @@ module Polyfill
95
95
  end
96
96
 
97
97
  def match?(pattern, position = 0)
98
- !!(self[position..-1] =~ pattern) # rubocop:disable Style/InverseMethods
98
+ !!(self[position..-1] =~ pattern)
99
99
  end
100
100
 
101
101
  def prepend(*others)
@@ -16,7 +16,7 @@ module Polyfill
16
16
  end
17
17
 
18
18
  def match?(pattern, position = 0)
19
- !!(self[position..-1] =~ pattern) # rubocop:disable Style/InverseMethods
19
+ !!(self[position..-1] =~ pattern)
20
20
  end
21
21
  end
22
22
  end
@@ -1,5 +1,7 @@
1
+ require_relative 'v2_6/array'
1
2
  require_relative 'v2_6/hash'
2
3
  require_relative 'v2_6/kernel'
4
+ require_relative 'v2_6/string'
3
5
 
4
6
  module Polyfill
5
7
  module V2_6
@@ -0,0 +1,19 @@
1
+ module Polyfill
2
+ module V2_6
3
+ module Array
4
+ def difference(*arrays)
5
+ arrays.reduce([*self]) do |me, array|
6
+ me - array
7
+ end
8
+ end
9
+
10
+ def union(*arrays)
11
+ return self | [] if arrays.empty?
12
+
13
+ arrays.reduce(self) do |me, array|
14
+ me | array
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -14,6 +14,34 @@ module Polyfill
14
14
  end
15
15
  end
16
16
  end
17
+
18
+ def merge!(*args)
19
+ if block_given?
20
+ block = ::Proc.new
21
+
22
+ args.each_with_object(self) do |arg, h|
23
+ h.merge!(arg, &block)
24
+ end
25
+ else
26
+ args.each_with_object(self) do |arg, h|
27
+ h.merge!(arg)
28
+ end
29
+ end
30
+ end
31
+
32
+ def update(*args)
33
+ if block_given?
34
+ block = ::Proc.new
35
+
36
+ args.each_with_object(self) do |arg, h|
37
+ h.update(arg, &block)
38
+ end
39
+ else
40
+ args.each_with_object(self) do |arg, h|
41
+ h.update(arg)
42
+ end
43
+ end
44
+ end
17
45
  end
18
46
  end
19
47
  end
@@ -0,0 +1,16 @@
1
+ module Polyfill
2
+ module V2_6
3
+ module String
4
+ def split(*)
5
+ result = super
6
+
7
+ if block_given?
8
+ result.each(&::Proc.new)
9
+ self
10
+ else
11
+ result
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Polyfill
2
- VERSION = Gem::Version.new('1.6.0'.freeze)
2
+ VERSION = Gem::Version.new('1.7.0'.freeze)
3
3
  end
@@ -1,6 +1,4 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'polyfill/version'
6
4
 
@@ -23,8 +21,7 @@ Gem::Specification.new do |spec|
23
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
22
  spec.require_paths = ['lib']
25
23
 
26
- spec.add_development_dependency 'bundler', '~> 1.14'
27
- spec.add_development_dependency 'rake', '~> 12.0'
28
- spec.add_development_dependency 'rspec', '~> 3.6'
29
- spec.add_development_dependency 'rubocop', '~> 0.48.1'
24
+ spec.add_development_dependency 'rake', '~> 12.3'
25
+ spec.add_development_dependency 'rspec', '~> 3.8'
26
+ spec.add_development_dependency 'rubocop', '~> 0.57.0' # highest supporting 2.1
30
27
  end
metadata CHANGED
@@ -1,71 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyfill
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.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: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.14'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.14'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '12.0'
19
+ version: '12.3'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '12.0'
26
+ version: '12.3'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '3.6'
33
+ version: '3.8'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '3.6'
40
+ version: '3.8'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rubocop
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 0.48.1
47
+ version: 0.57.0
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 0.48.1
54
+ version: 0.57.0
69
55
  description:
70
56
  email:
71
57
  - aaron.lasseigne@gmail.com
@@ -136,8 +122,10 @@ files:
136
122
  - lib/polyfill/v2_5/struct.rb
137
123
  - lib/polyfill/v2_5/time.rb
138
124
  - lib/polyfill/v2_6.rb
125
+ - lib/polyfill/v2_6/array.rb
139
126
  - lib/polyfill/v2_6/hash.rb
140
127
  - lib/polyfill/v2_6/kernel.rb
128
+ - lib/polyfill/v2_6/string.rb
141
129
  - lib/polyfill/version.rb
142
130
  - polyfill.gemspec
143
131
  homepage: ''
@@ -159,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
147
  - !ruby/object:Gem::Version
160
148
  version: '0'
161
149
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 2.5.2.3
150
+ rubygems_version: 3.0.1
164
151
  signing_key:
165
152
  specification_version: 4
166
153
  summary: Adds newer Ruby methods to older versions.