lite-ruby 1.0.20 → 1.0.21

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: 909d00d72336279c8efe3468116cec5a51e943787fd0882175ae350a360c43f8
4
- data.tar.gz: b7a9511ab769cd3d8d8fc12287d9be829ef3d1c44c516e456de587ec42c061e4
3
+ metadata.gz: '0820619dfad934f57b67a5faa46ff2ab0f89ca1aaa24bbc739958a1cf61ac9e7'
4
+ data.tar.gz: e1ce115ea05862624cf0d64836d898030a8fba0aaa2c66acc01268cecec59493
5
5
  SHA512:
6
- metadata.gz: b3fd86475d15693d2ab400190375ba322e6f72eac7a08582a1bf52b4593a6ff5d70f96355e8526d372f7af609e9d38023a5576d48a120c4afc6f1a9556e43011
7
- data.tar.gz: e8ee6392456cb8370cc237a05cabbb014f61e90fb4b0c4223ab32cdbd2baab643d3ce34515e4b42abb575e3dc0ca89ee8adbd77b4f4e4c81b9eb9e499a3b33b3
6
+ metadata.gz: 0c7cdff31df3ba265ea340b853058dc067aeaf12fe539999a005eb81190c8ad03a20074deadcf0c08ed804866c7636a943ad724eae837e9c00d2152104e93af3
7
+ data.tar.gz: 7dfbdf038e781405a248c293e3b0d78934c9bac86e8039f28b57bfe486c2b5a42480bf44e28f746e8827549ca8cfb801afbef2a786b84897e5e6c6db4f2c6fbc
@@ -5,8 +5,6 @@ AllCops:
5
5
  TargetRubyVersion: 2.6
6
6
  DisplayCopNames: true
7
7
  DisplayStyleGuide: true
8
- LineLength:
9
- Max: 100
10
8
  Layout/EmptyLinesAroundBlockBody:
11
9
  Exclude:
12
10
  - 'spec/**/**/*'
@@ -20,6 +18,8 @@ Metrics/BlockLength:
20
18
  - '*.gemspec'
21
19
  Metrics/ClassLength:
22
20
  Enabled: false
21
+ Metrics/LineLength:
22
+ Max: 100
23
23
  Metrics/ModuleLength:
24
24
  Enabled: false
25
25
  RSpec/DescribeClass:
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.21] - 2019-11-02
10
+ ### Added
11
+ - Added Enumerable => `excluding`
12
+ - Added Enumerable => `including`
13
+ - Added Enumerable => `pluck`
14
+
9
15
  ## [1.0.20] - 2019-09-29
10
16
  ### Added
11
17
  - Added Array => `rand_sample`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (1.0.20)
4
+ lite-ruby (1.0.21)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -29,28 +29,28 @@ GEM
29
29
  builder (3.2.3)
30
30
  colorize (0.8.1)
31
31
  concurrent-ruby (1.1.5)
32
- crass (1.0.4)
32
+ crass (1.0.5)
33
33
  diff-lcs (1.3)
34
34
  erubi (1.9.0)
35
- fasterer (0.7.0)
35
+ fasterer (0.7.1)
36
36
  colorize (~> 0.7)
37
37
  ruby_parser (>= 3.13.0)
38
38
  generator_spec (0.9.4)
39
39
  activesupport (>= 3.0.0)
40
40
  railties (>= 3.0.0)
41
- i18n (1.6.0)
41
+ i18n (1.7.0)
42
42
  concurrent-ruby (~> 1.0)
43
- jaro_winkler (1.5.3)
44
- loofah (2.3.0)
43
+ jaro_winkler (1.5.4)
44
+ loofah (2.3.1)
45
45
  crass (~> 1.0.2)
46
46
  nokogiri (>= 1.5.9)
47
47
  method_source (0.9.2)
48
48
  mini_portile2 (2.4.0)
49
- minitest (5.12.2)
50
- nokogiri (1.10.4)
49
+ minitest (5.13.0)
50
+ nokogiri (1.10.5)
51
51
  mini_portile2 (~> 2.4.0)
52
- parallel (1.17.0)
53
- parser (2.6.4.1)
52
+ parallel (1.18.0)
53
+ parser (2.6.5.0)
54
54
  ast (~> 2.4.0)
55
55
  rack (2.0.7)
56
56
  rack-test (1.1.0)
@@ -58,8 +58,8 @@ GEM
58
58
  rails-dom-testing (2.0.3)
59
59
  activesupport (>= 4.2.0)
60
60
  nokogiri (>= 1.6)
61
- rails-html-sanitizer (1.2.0)
62
- loofah (~> 2.2, >= 2.2.2)
61
+ rails-html-sanitizer (1.3.0)
62
+ loofah (~> 2.3)
63
63
  railties (6.0.0)
64
64
  actionpack (= 6.0.0)
65
65
  activesupport (= 6.0.0)
@@ -68,32 +68,32 @@ GEM
68
68
  thor (>= 0.20.3, < 2.0)
69
69
  rainbow (3.0.0)
70
70
  rake (13.0.0)
71
- rspec (3.8.0)
72
- rspec-core (~> 3.8.0)
73
- rspec-expectations (~> 3.8.0)
74
- rspec-mocks (~> 3.8.0)
75
- rspec-core (3.8.2)
76
- rspec-support (~> 3.8.0)
77
- rspec-expectations (3.8.4)
71
+ rspec (3.9.0)
72
+ rspec-core (~> 3.9.0)
73
+ rspec-expectations (~> 3.9.0)
74
+ rspec-mocks (~> 3.9.0)
75
+ rspec-core (3.9.0)
76
+ rspec-support (~> 3.9.0)
77
+ rspec-expectations (3.9.0)
78
78
  diff-lcs (>= 1.2.0, < 2.0)
79
- rspec-support (~> 3.8.0)
80
- rspec-mocks (3.8.1)
79
+ rspec-support (~> 3.9.0)
80
+ rspec-mocks (3.9.0)
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.8.0)
83
- rspec-support (3.8.2)
84
- rubocop (0.74.0)
82
+ rspec-support (~> 3.9.0)
83
+ rspec-support (3.9.0)
84
+ rubocop (0.76.0)
85
85
  jaro_winkler (~> 1.5.1)
86
86
  parallel (~> 1.10)
87
87
  parser (>= 2.6)
88
88
  rainbow (>= 2.2.2, < 4.0)
89
89
  ruby-progressbar (~> 1.7)
90
90
  unicode-display_width (>= 1.4.0, < 1.7)
91
- rubocop-performance (1.4.1)
91
+ rubocop-performance (1.5.0)
92
92
  rubocop (>= 0.71.0)
93
93
  rubocop-rspec (1.36.0)
94
94
  rubocop (>= 0.68.1)
95
95
  ruby-progressbar (1.10.1)
96
- ruby_parser (3.14.0)
96
+ ruby_parser (3.14.1)
97
97
  sexp_processor (~> 4.9)
98
98
  sexp_processor (4.13.0)
99
99
  thor (0.20.3)
@@ -101,7 +101,7 @@ GEM
101
101
  tzinfo (1.2.5)
102
102
  thread_safe (~> 0.1)
103
103
  unicode-display_width (1.6.0)
104
- zeitwerk (2.1.10)
104
+ zeitwerk (2.2.1)
105
105
 
106
106
  PLATFORMS
107
107
  ruby
@@ -118,4 +118,4 @@ DEPENDENCIES
118
118
  rubocop-rspec
119
119
 
120
120
  BUNDLED WITH
121
- 2.0.1
121
+ 2.0.2
@@ -74,6 +74,15 @@ Returns if the collection does not include an object.
74
74
  [1,2,3].exclude?(3) #=> false
75
75
  ```
76
76
 
77
+ `excluding` aka `without`
78
+ ------
79
+ Returns the object without the given keys.
80
+
81
+ ```ruby
82
+ [1, 2, 3].excluding(2, 3) #=> [1]
83
+ { foo: 1, bar: 2, baz: 3 }.excluding(:foo, :baz) #=> { bar: 2 }
84
+ ```
85
+
77
86
  `expand`
78
87
  ------
79
88
  Expand all elements of an Enumerable object.
@@ -117,6 +126,14 @@ Returns an Enumerator to add seperators.
117
126
  [1,2,'a'].interpose(:sep).to_a #=> [1,:sep,2,:sep,'a']
118
127
  ```
119
128
 
129
+ `including` aka `with`
130
+ ------
131
+ Returns an array with the given values.
132
+
133
+ ```ruby
134
+ [1, 2, 3].including(4, 5) #=> [1,2,3,4,5]
135
+ ```
136
+
120
137
  `many?`
121
138
  ------
122
139
  Returns if a collection has more than one element while respecting `nil` and `false` as an element.
@@ -134,11 +151,22 @@ Returns if a collection has more than one element while respecting `nil` and `fa
134
151
  Returns an array of elements for the elements that occur n times.
135
152
 
136
153
  ```ruby
137
- a1 = [1, 1, 2, 3, 3, 4, 5, 5]
154
+ a1 = [1,1,2,3,3,4,5,5]
155
+
156
+ a1.occur(2) #=> [1,3,5]
157
+ a1.occur(2..3) #=> [1,3,5]
158
+ a1.occur { |n| n > 1 } #=> [1,3,5]
159
+ ```
160
+
161
+ `pluck`
162
+ ------
163
+ Returns an array of values from a set of given keys.
164
+
165
+ ```ruby
166
+ a1 = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }]
138
167
 
139
- a1.occur(2) #=> [1, 3, 5]
140
- a1.occur(2..3) #=> [1, 3, 5]
141
- a1.occur { |n| n > 1 } #=> [1, 3, 5]
168
+ a1.pluck(:id) #=> [1,2]
169
+ a1.pluck(:id, :name) #=> [[1,'a'], [2,'b']]
142
170
  ```
143
171
 
144
172
  `produce`
@@ -177,11 +205,11 @@ Returns if collection has more than one element while not respecting `nil` and `
177
205
  Squeeze out the same elements.
178
206
 
179
207
  ```ruby
180
- a1 = [1, 2, 2, 3, 3, 2, 1]
208
+ a1 = [1,2,2,3,3,2,1]
181
209
 
182
- a1.squeeze #=> [1, 2, 3, 2, 1]
183
- a1.sort.squeeze #=> [1, 2, 3]
184
- a1.squeeze(3) #=> [1, 2, 2, 3, 2, 1]
210
+ a1.squeeze #=> [1,2,3,2,1]
211
+ a1.sort.squeeze #=> [1,2,3]
212
+ a1.squeeze(3) #=> [1,2,2,3,2,1]
185
213
  ```
186
214
 
187
215
  `take_last`
@@ -65,6 +65,13 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
65
65
  !include?(object)
66
66
  end
67
67
 
68
+ def excluding(*elements)
69
+ elements.flatten!(1)
70
+ reject { |element| elements.include?(element) }
71
+ end
72
+
73
+ alias without excluding
74
+
68
75
  def expand
69
76
  map { |val| val.is_a?(Enumerable) ? val.expand : val }
70
77
  end
@@ -89,6 +96,12 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
89
96
  end
90
97
  # rubocop:enable Style/CaseEquality
91
98
 
99
+ def including(*elements)
100
+ to_a.including(*elements)
101
+ end
102
+
103
+ alias with including
104
+
92
105
  # rubocop:disable Metrics/MethodLength
93
106
  def interpose(sep, &block)
94
107
  enum = Enumerator.new do |val|
@@ -165,6 +178,14 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
165
178
  end
166
179
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
167
180
 
181
+ def pluck(*keys)
182
+ if keys.many?
183
+ map { |element| keys.map { |key| element[key] } }
184
+ else
185
+ map { |element| element[keys.first] }
186
+ end
187
+ end
188
+
168
189
  def produce(identity = 0, &block)
169
190
  if block_given?
170
191
  map(&block).produce(identity)
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION ||= '1.0.20'
6
+ VERSION ||= '1.0.21'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.20
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2019-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []
205
- rubygems_version: 3.0.4
205
+ rubygems_version: 3.0.6
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Collection of useful Ruby methods for its primitive classes