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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9bae4e784ecbd35da45f7418b910a4d64707894
4
- data.tar.gz: e594b3c0bd12351eb78b18c1dc9a84514e943360
3
+ metadata.gz: 18e8c89d415a12358783e4e1a063a64dfcbacb0f
4
+ data.tar.gz: c88f67156a520789a37dd3985c4b1bb3b38f41d8
5
5
  SHA512:
6
- metadata.gz: b78f8e2885ebb7d2d66adf851c90a0a1aa4511d4ae616169d9a9af2b3f55f07c4cc6d5a3c9c68f486d4bc73ab19645f4307ab49b3c2f27b0aede0a2ba9b93134
7
- data.tar.gz: 579f7f3a0904d54a8b56ca8e722b970676c01d0c3e3aad2625e778d0e772f61712c1d54991ec448553177c39b0400fea3cca1c6950923e20faaf818a268c890e
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
- * `hash.iteraptor.each(**params, ->(full_key, value))`
38
- * `hash.iteraptor.map(**params, ->(full_key, (key, value)))`
39
- * `hash.iteraptor.select(*filters, **params, ->(full_key, value)`
40
- * `hash.iteraptor.reject(*filters, **params, ->(full_key, value)`
41
- * `hash.iteraptor.flat_map(**params, ->(full_key, value))`
42
- * `hash.iteraptor.flatten(**params, ->(full_key, value))`
43
- * `hash.iteraptor.collect(**params, ->(full_key, value))`
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
@@ -6,11 +6,12 @@ module Iteraptor
6
6
 
7
7
  select: :escoger,
8
8
  reject: :rechazar,
9
+ compact: :compactar,
9
10
 
10
11
  flatten: :aplanar,
11
12
  collect: :recoger,
12
13
  flat_map: :plana_mapa
13
- }
14
+ }.freeze
14
15
 
15
16
  def initialize(receiver)
16
17
  @receiver = receiver
@@ -1,3 +1,3 @@
1
1
  module Iteraptor
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
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.7.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-04-06 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler