array_include_methods 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +14 -8
- data/VERSION +1 -1
- data/array_include_methods.gemspec +6 -4
- data/lib/array_include_methods.rb +18 -3
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8de965f1a7a26091cfd9b1f2bdbb7191b92148afa5acf2b15b623c7950bc93b9
|
4
|
+
data.tar.gz: e8e4892cb0cbdd33d0cbf53dbf41d2e5927cbd364ac002e4983d948a0b418760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42a8e991852c1539669847b94b214d11ad7c47011670d432634fff64516ec2ffb8d749df18b165bc18b676539540eb5d7836dac215152909f5e12b27ad8e4f2a
|
7
|
+
data.tar.gz: 42be75002418adf80e9c7177f6d420dabaa0db20950cbc2d54ef4558773e75697269f0ed9f0849bacc40084c0e7296c55ca163d5f07215592a495f03c3479b54
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.1.0
|
4
|
+
|
5
|
+
- Perform contiguous-element `include_all?([...])` check against an array argument (not splatted)
|
6
|
+
- Perform sorted `include_all?([...])` check against an array argument (not splatted)
|
7
|
+
- Perform non-repetition `include_all?([...])` check against an array argument (not splatted)
|
8
|
+
|
3
9
|
## 1.0.4
|
4
10
|
|
5
11
|
- Support splat args (e.g. `include_any?(1, 2, 3)` instead of `include_any?([1, 2, 3])`)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ArrayIncludeMethods 1.0
|
1
|
+
# ArrayIncludeMethods 1.1.0 - Ruby Refinement
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/array_include_methods.svg)](http://badge.fury.io/rb/array_include_methods)
|
3
3
|
[![Build Status](https://travis-ci.com/AndyObtiva/array_include_methods.svg?branch=master)](https://travis-ci.com/AndyObtiva/array_include_methods)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/array_include_methods/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/array_include_methods?branch=master)
|
@@ -12,7 +12,7 @@
|
|
12
12
|
Include the following in Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'array_include_methods', '~> 1.0
|
15
|
+
gem 'array_include_methods', '~> 1.1.0'
|
16
16
|
```
|
17
17
|
|
18
18
|
Run:
|
@@ -26,7 +26,7 @@ bundle
|
|
26
26
|
Run:
|
27
27
|
|
28
28
|
```
|
29
|
-
gem install array_include_methods -v1.0
|
29
|
+
gem install array_include_methods -v1.1.0
|
30
30
|
```
|
31
31
|
|
32
32
|
## Usage
|
@@ -50,10 +50,16 @@ Now, you have `#include_all?` and `#include_any?` methods on `Array` objects.
|
|
50
50
|
### `Array#include_all?(other_array)`
|
51
51
|
|
52
52
|
```ruby
|
53
|
-
[1, 2, 3, 4].include_all?(
|
53
|
+
[1, 2, 3, 4].include_all?(2, 3) # returns true
|
54
|
+
[1, 2, 3, 4].include_all?([2, 3]) # returns true
|
54
55
|
[1, 2, 3, 4].include_all?(2, 4) # returns true
|
55
|
-
[1, 2, 3, 4].include_all?([2, 4
|
56
|
+
[1, 2, 3, 4].include_all?([2, 4]) # returns false (checks true array containment)
|
57
|
+
[1, 2, 3, 4].include_all?(4, 2) # returns true
|
58
|
+
[1, 2, 3, 4].include_all?([4, 2]) # returns false (checks true array containment)
|
59
|
+
[1, 2, 3, 4].include_all?(2, 4, 4) # returns true
|
60
|
+
[1, 2, 3, 4].include_all?([2, 4, 4]) # returns false (checks true array containment)
|
56
61
|
[1, 2, 3, 4].include_all?(2, 4, 5) # returns false
|
62
|
+
[1, 2, 3, 4].include_all?([2, 4, 5]) # returns false
|
57
63
|
[1, 2, 3, 4].include_all?([]) # returns true
|
58
64
|
[1, 2, 3, 4].include_all?(nil) # returns false
|
59
65
|
```
|
@@ -61,17 +67,17 @@ Now, you have `#include_all?` and `#include_any?` methods on `Array` objects.
|
|
61
67
|
### `Array#include_any?(other_array)`
|
62
68
|
|
63
69
|
```ruby
|
64
|
-
[1, 2, 3, 4].include_any?([2, 4, 5]) # returns true
|
65
70
|
[1, 2, 3, 4].include_any?(2, 4, 5) # returns true
|
66
|
-
[1, 2, 3, 4].include_any?([
|
71
|
+
[1, 2, 3, 4].include_any?([2, 4, 5]) # returns true
|
67
72
|
[1, 2, 3, 4].include_any?(6, 7) # returns false
|
73
|
+
[1, 2, 3, 4].include_any?([6, 7]) # returns false
|
68
74
|
[1, 2, 3, 4].include_any?([]) # returns true
|
69
75
|
[1, 2, 3, 4].include_any?(nil) # returns false
|
70
76
|
```
|
71
77
|
|
72
78
|
## Opal Compatibility
|
73
79
|
|
74
|
-
This gem degrades gracefully to monkey-patching in Opal Ruby and provides a `using` method shim so consumer code does not have to change if it used gems that rely on the Ruby refinement
|
80
|
+
This gem degrades gracefully to monkey-patching in [Opal Ruby](https://opalrb.com) and provides a `using` method shim so consumer code does not have to change if it used gems that rely on the Ruby refinement
|
75
81
|
|
76
82
|
## TODO
|
77
83
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: array_include_methods 1.0
|
5
|
+
# stub: array_include_methods 1.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "array_include_methods".freeze
|
9
|
-
s.version = "1.0
|
9
|
+
s.version = "1.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andy Maleh".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2021-09-25"
|
15
15
|
s.description = "Array#include_all? & Array#include_any? methods missing from basic Ruby Array API".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
]
|
30
30
|
s.homepage = "http://github.com/AndyObtiva/array_include_methods".freeze
|
31
31
|
s.licenses = ["MIT".freeze]
|
32
|
-
s.rubygems_version = "3.
|
32
|
+
s.rubygems_version = "3.2.22".freeze
|
33
33
|
s.summary = "Array#include_all? & Array#include_any? methods missing from basic Ruby Array API".freeze
|
34
34
|
|
35
35
|
if s.respond_to? :specification_version then
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
|
44
44
|
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
45
45
|
s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
46
|
+
s.add_development_dependency(%q<rake-tui>.freeze, ["> 0"])
|
46
47
|
else
|
47
48
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
48
49
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
@@ -50,6 +51,7 @@ Gem::Specification.new do |s|
|
|
50
51
|
s.add_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
|
51
52
|
s.add_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
52
53
|
s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
54
|
+
s.add_dependency(%q<rake-tui>.freeze, ["> 0"])
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
@@ -10,13 +10,28 @@ module ArrayIncludeMethods
|
|
10
10
|
# Always returns `true` if the given `array` is empty
|
11
11
|
# Always returns `false` if the given `array` is nil
|
12
12
|
def include_all?(*array)
|
13
|
-
|
13
|
+
array_argument = false
|
14
|
+
if array.size == 1 && array[0].is_a?(Array)
|
15
|
+
array_argument = true
|
16
|
+
array = array[0]
|
17
|
+
end
|
14
18
|
return false if array.nil?
|
15
19
|
array_include_other_array_same_class_elements = lambda do |a1, a2|
|
16
20
|
begin
|
17
|
-
|
21
|
+
if array_argument
|
22
|
+
if a2.size > a1.size
|
23
|
+
false
|
24
|
+
else
|
25
|
+
size_diff = a1.size - a2.size
|
26
|
+
(size_diff + 1).times.any? do |start_index|
|
27
|
+
a1[start_index, a2.size] == a2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
(a1 & a2).uniq.sort == a2.uniq.sort
|
32
|
+
end
|
18
33
|
rescue ArgumentError => e
|
19
|
-
a2.uniq.
|
34
|
+
a2.uniq.all? { |element| a1.include?(element) }
|
20
35
|
end
|
21
36
|
end
|
22
37
|
self_grouped_by = self.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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.7.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake-tui
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Array#include_all? & Array#include_any? methods missing from basic Ruby
|
98
112
|
Array API
|
99
113
|
email: andy.am@gmail.com
|
@@ -129,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
143
|
- !ruby/object:Gem::Version
|
130
144
|
version: '0'
|
131
145
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.2.22
|
133
147
|
signing_key:
|
134
148
|
specification_version: 4
|
135
149
|
summary: Array#include_all? & Array#include_any? methods missing from basic Ruby Array
|