abstractivator 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45c8fba3280c1d29b04f039b41ad5f9f1fb0d9ce
|
4
|
+
data.tar.gz: 466908745cf321c32d574ab98df30f0329656fba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca79e31fdece1d82be3be63147f30ec618ce81b3290d5418778ff5620604e9dbaab86dbe4f6c8181bfbbfb23792cff7def8fe2b73263fdcb2c28dc314b9093b
|
7
|
+
data.tar.gz: f9a2a806b5a48721bd2969cb9e9f38826b33d0db14794ed4072f05493333414d6b57ba4c81ad2d2fd8eeb6f318950cd45aec3d229e4c72b4e551c5f706bf1313
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# like Enumerable#map, except if the receiver is not enumerable,
|
2
2
|
# i.e., a single value, then it transforms the single value.
|
3
3
|
|
4
|
-
|
4
|
+
class Array
|
5
5
|
alias_method :value_map, :map
|
6
6
|
end
|
7
7
|
|
@@ -16,9 +16,3 @@ class Object
|
|
16
16
|
yield self
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
class Struct
|
21
|
-
def value_map
|
22
|
-
yield self
|
23
|
-
end
|
24
|
-
end
|
@@ -5,9 +5,8 @@ describe '#value_map' do
|
|
5
5
|
|
6
6
|
Foo = Struct.new(:a)
|
7
7
|
|
8
|
-
it 'maps
|
8
|
+
it 'maps arrays' do
|
9
9
|
expect([[:a, 1], [:b, 2]].value_map(&:reverse)).to eql [[1, :a], [2, :b]]
|
10
|
-
expect({a: 1, b: 2}.value_map(&:reverse)).to eql [[1, :a], [2, :b]]
|
11
10
|
end
|
12
11
|
|
13
12
|
it 'maps single values' do
|
@@ -18,6 +17,10 @@ describe '#value_map' do
|
|
18
17
|
expect(Foo.new(42).value_map { |x| x.a }).to eql 42
|
19
18
|
end
|
20
19
|
|
20
|
+
it 'hashes are treated as single values' do
|
21
|
+
expect({a: 1, b: 2}.value_map { |x| x[:a] }).to eql 1
|
22
|
+
end
|
23
|
+
|
21
24
|
it 'maps nil' do
|
22
25
|
expect(nil.value_map(&method(:square))).to be nil
|
23
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstractivator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Winton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|