array_include_methods 1.0.1 → 1.0.2
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/README.md +7 -3
- data/lib/array_include_methods.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c2ea9883b39246baae032b965a82ae5d6cec5f15393ffa3e8c68e698a0cb6d3
|
4
|
+
data.tar.gz: a8e2cfeef8241433ad043c358d285d349ee4ba8ea2b40b73dcb4863e30f0fd7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ad14e48a3d730fef05fad287cd3232b052462961ec91a4094713b2dc80803806e99bc3b52e1e80ce0638b6f8e833fb757132c2646037d791a8faefb78c2802a
|
7
|
+
data.tar.gz: 15f9bac604634a862cf1d582c26523ef375659371fb3151a8b69c2158b4e75c58b17d202753b85b1c4060016274813d4e2f1b68a75fbc805b616efbd211b9f4a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ArrayIncludeMethods 1.0.
|
1
|
+
# ArrayIncludeMethods 1.0.2 - Ruby Refinement
|
2
2
|
[](http://badge.fury.io/rb/array_include_methods)
|
3
3
|
|
4
4
|
`Array#include_all?` & `Array#include_any?` methods missing from basic Ruby `Array` API.
|
@@ -10,7 +10,7 @@
|
|
10
10
|
Include the following in Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'array_include_methods', '~> 1.0.
|
13
|
+
gem 'array_include_methods', '~> 1.0.2'
|
14
14
|
```
|
15
15
|
|
16
16
|
Run:
|
@@ -24,7 +24,7 @@ bundle
|
|
24
24
|
Run:
|
25
25
|
|
26
26
|
```
|
27
|
-
gem install array_include_methods -v1.0.
|
27
|
+
gem install array_include_methods -v1.0.2
|
28
28
|
```
|
29
29
|
|
30
30
|
## Usage
|
@@ -65,6 +65,10 @@ Now, you have `#include_all?` and `#include_any?` methods on `Array` objects.
|
|
65
65
|
|
66
66
|
## Change Log
|
67
67
|
|
68
|
+
### 1.0.2
|
69
|
+
|
70
|
+
- Handled case of two arrays with elements of unsortable object types (e.g. Hash)
|
71
|
+
|
68
72
|
### 1.0.1
|
69
73
|
|
70
74
|
- Handled case of two arrays with different ordering of common elements
|
@@ -7,7 +7,11 @@ module ArrayIncludeMethods
|
|
7
7
|
def include_all?(array)
|
8
8
|
return false if array.nil?
|
9
9
|
array_include_other_array_same_class_elements = lambda do |a1, a2|
|
10
|
-
|
10
|
+
begin
|
11
|
+
(a1 & a2).uniq.sort == a2.uniq.sort
|
12
|
+
rescue ArgumentError => e
|
13
|
+
a2.uniq.reduce(true) { |result, element| result && a1.include?(element) }
|
14
|
+
end
|
11
15
|
end
|
12
16
|
self_grouped_by = self.group_by(&:class)
|
13
17
|
array_grouped_by = array.group_by(&:class)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_include_methods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|