iteraptor 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -8
- data/lib/iteraptor.rb +9 -0
- data/lib/iteraptor/delegator.rb +2 -1
- data/lib/iteraptor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18e8c89d415a12358783e4e1a063a64dfcbacb0f
|
4
|
+
data.tar.gz: c88f67156a520789a37dd3985c4b1bb3b38f41d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4455a4152188b0b02f0362e1489a17c6e6a21ff20ec20e8bd74f2f91f2ed0ebed5a2fd2c43f45d7844deda17df6034f6903e87ec64eef25a779533120c8691
|
7
|
+
data.tar.gz: fbac0c9ccb98eb321de7c5a49773e7ab173e5046dd7508853c33dfc080e370b0d56d54a1c4f4d0d274b18b79c603a466cfa75a5e7c324277a24a565d19ee37e2
|
data/README.md
CHANGED
@@ -34,13 +34,14 @@ latter is just a dot in current release.
|
|
34
34
|
```ruby
|
35
35
|
enum = [{foo: {bar: [:baz, 42]}}, [:foo, {bar: {baz: 42}}]].random
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
— enum.iteraptor.each(**params, ->(full_key, value))
|
38
|
+
— enum.iteraptor.map(**params, ->(full_key, (key, value)))
|
39
|
+
— enum.iteraptor.select(*filters, **params, ->(full_key, value))
|
40
|
+
— enum.iteraptor.reject(*filters, **params, ->(full_key, value))
|
41
|
+
— enum.iteraptor.compact(**params)
|
42
|
+
— enum.iteraptor.flat_map(**params, ->(full_key, value))
|
43
|
+
— enum.iteraptor.flatten(**params, ->(full_key, value))
|
44
|
+
— enum.iteraptor.collect(**params, ->(full_key, value))
|
44
45
|
```
|
45
46
|
|
46
47
|
### Direct 🐒 patching in 🇪🇸
|
@@ -60,7 +61,8 @@ the deep enumerable into `Hash` instance
|
|
60
61
|
the nested structure out of flattened hash
|
61
62
|
* `segar` (_sp._ `yield`), alias `escoger` (_sp._ `select`) allows to filter
|
62
63
|
and collect elelements
|
63
|
-
* `rechazar` (_sp._ `reject`) allows to filter out and collect elelements
|
64
|
+
* `rechazar` (_sp._ `reject`) allows to filter out and collect elelements
|
65
|
+
* `compactar` (_sp._ `compact`), allows to filter out all `nil`s
|
64
66
|
|
65
67
|
### Words are cheap, show me the code
|
66
68
|
|
data/lib/iteraptor.rb
CHANGED
@@ -32,6 +32,15 @@ module Iteraptor
|
|
32
32
|
rechazar_o_escoger true, *filter, **params, &λ
|
33
33
|
end
|
34
34
|
|
35
|
+
def compactar **params
|
36
|
+
mapa(yield_all: true) do |p, (k, v)|
|
37
|
+
v.is_a?(Array) ? [k, v.compact] : [k, v]
|
38
|
+
end.mapa(**params) do |parent, (k, v)|
|
39
|
+
p = parent.split(H.iteraptor_delimiter(params)).last
|
40
|
+
(p.to_i.to_s != p && v.nil?) ? nil : [k, v]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
# rubocop:disable Style/Alias
|
36
45
|
alias_method :segar, :escoger
|
37
46
|
# rubocop:enable Style/Alias
|
data/lib/iteraptor/delegator.rb
CHANGED
data/lib/iteraptor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iteraptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksei Matiushkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|