darthjee-core_ext 1.5.1 → 1.5.2

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: 9166c9a826895d9f039aa73a5460746dd7e48b5f
4
- data.tar.gz: 1146695820d6fc7dfabe38a2145d3b8ba34670b5
3
+ metadata.gz: f4e412855a254f3c8334a1485327c880be5bbf9c
4
+ data.tar.gz: 676209baf8fe045c8824eebad20d570881087a35
5
5
  SHA512:
6
- metadata.gz: 45fdd45a6e6378421e3db191839ee898ff31a4145bd54445f1a481b1d5db78d640cc6e8adc38ac161a9788d73fdb5c4e269c5ea98ff1686ad9d754d91eb34cf5
7
- data.tar.gz: f35df70664a0e2b3f1e307fc44fe3932ecf58b8694f49c0e1be4263a32e19456e0b255d6765795a411942253d11b8ec560d89233c80bad8332b723304eac7397
6
+ metadata.gz: 7688e35d2cc25b0001e617cd484a6e6f1251bc3e5c6c5958b1662d571ad940ab2467780211fbb9609e9ace834cc37e03a6e68c029fffa571847bddb48cf8e40e
7
+ data.tar.gz: c6dbd9bc92839a16f158571599d3d1aced950f1973fb04dd0902254f82066b9b9c1fb2a4dfb869196d78cecafb7ef6e542eabe73c7464f59ddef9456e77d0fca
@@ -1,6 +1,12 @@
1
1
  class Array
2
2
  autoload :HashBuilder, 'darthjee/core_ext/array/hash_builder'
3
3
 
4
+ def mapk(*keys)
5
+ keys.inject(self) do |enum, key|
6
+ enum.map { |hash| hash[key] }
7
+ end
8
+ end
9
+
4
10
  def procedural_join(mapper = proc(&:to_s))
5
11
  return '' if empty?
6
12
  list = dup
@@ -1,5 +1,5 @@
1
1
  module Darthjee
2
2
  module CoreExt
3
- VERSION = '1.5.1'
3
+ VERSION = '1.5.2'
4
4
  end
5
5
  end
@@ -3,6 +3,14 @@ require 'spec_helper'
3
3
  describe Array do
4
4
  it_behaves_like 'an array with map_to_hash method'
5
5
 
6
+ describe '#mapk' do
7
+ let(:array) { [{a: { b: 1 }, b: 2}, {a: { b: 3 }, b: 4}] }
8
+
9
+ it 'maps using the keys given as arguments' do
10
+ expect(array.mapk(:a, :b)).to eq([ 1, 3 ])
11
+ end
12
+ end
13
+
6
14
  describe '#procedural_join' do
7
15
  let(:array) { [1, 2, -3, -4, 5] }
8
16
  let(:map_proc) { proc { |v| v > 0 ? v + 1 : v - 1 } }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darthjee-core_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darthjee