abstractivator 0.0.16 → 0.0.18
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: d228a0ed6f537d3f752f6a46912bad4619047db0
|
4
|
+
data.tar.gz: 4d304955258c6138dc8eddd7a7d9dc716b39ce1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e48954a97bf6a2d352f952709df932497688d2360d68d4531dac5ca44540b02322d0b21ab0626ad05cf38ea22a60c1af49102eed5e4d3c2bac24d84b9f74c4ff
|
7
|
+
data.tar.gz: 573161dc96da1502eceed8bb3a17f7877384521a1756b390ba2a21ec17d60655dfc1bb22b7135add3748af38f66c98f8147e45584b6968e18f49e7d724fcddb6
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'abstractivator/enumerable_ext'
|
2
|
+
|
1
3
|
module MethodAndProcExtensions
|
2
4
|
def loosen_args
|
3
5
|
proc do |*args, &block|
|
@@ -14,7 +16,7 @@ class Proc
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def self.compose(*procs)
|
17
|
-
procs.inject_right(identity) { |inner, p| p.compose(inner) }
|
19
|
+
procs.map(&:to_proc).inject_right(identity) { |inner, p| p.compose(inner) }
|
18
20
|
end
|
19
21
|
|
20
22
|
def self.identity
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'abstractivator/array_ext'
|
3
|
+
|
4
|
+
describe Array do
|
5
|
+
describe '#key' do
|
6
|
+
it 'returns the first element' do
|
7
|
+
expect([:k, :v].key).to eql :k
|
8
|
+
end
|
9
|
+
it 'raises an error if the array is not of size 2' do
|
10
|
+
expect{[:k].key}.to raise_error
|
11
|
+
expect{[:k, :v, :z].key}.to raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#value' do
|
16
|
+
it 'returns the second element' do
|
17
|
+
expect([:k, :v].value).to eql :v
|
18
|
+
end
|
19
|
+
it 'raises an error if the array is not of size 2' do
|
20
|
+
expect{[:k].value}.to raise_error
|
21
|
+
expect{[:k, :v, :z].value}.to raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -19,6 +19,10 @@ context 'in the world of functional programming' do
|
|
19
19
|
expect(Proc.compose(square, double).call(3)).to eql 36
|
20
20
|
expect(Proc.compose(negate, square, double).call(3)).to eql -36
|
21
21
|
end
|
22
|
+
it 'coerces the args to a proc with to_proc' do
|
23
|
+
p = Proc.compose(:abs, :first)
|
24
|
+
expect(p.call([-5, 6])).to eql 5
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
describe 'Proc#reverse_args' do
|
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.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Winton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- abstractivator.gemspec
|
83
83
|
- lib/abstractivator.rb
|
84
|
+
- lib/abstractivator/array_ext.rb
|
84
85
|
- lib/abstractivator/collections.rb
|
85
86
|
- lib/abstractivator/cons.rb
|
86
87
|
- lib/abstractivator/enum.rb
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- lib/abstractivator/trees/block_collector.rb
|
91
92
|
- lib/abstractivator/version.rb
|
92
93
|
- lib/enumerable_ext.rb
|
94
|
+
- spec/lib/abstractivator/array_ext_spec.rb
|
93
95
|
- spec/lib/abstractivator/collections_spec.rb
|
94
96
|
- spec/lib/abstractivator/cons_spec.rb
|
95
97
|
- spec/lib/abstractivator/enumerable_ext_spec.rb
|
@@ -121,6 +123,7 @@ signing_key:
|
|
121
123
|
specification_version: 4
|
122
124
|
summary: Utilities
|
123
125
|
test_files:
|
126
|
+
- spec/lib/abstractivator/array_ext_spec.rb
|
124
127
|
- spec/lib/abstractivator/collections_spec.rb
|
125
128
|
- spec/lib/abstractivator/cons_spec.rb
|
126
129
|
- spec/lib/abstractivator/enumerable_ext_spec.rb
|