totally_lazy 0.1.52 → 0.1.53

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2NkOTk0YzkwOGE5NTgwMjI3MzA4NTdlNGEwZDgyZmYxODQ2ZjE4MA==
4
+ ZTdhZDRmMzNkZmNiODRjYjcxMTFjM2Y1NDgwN2MxZWFiMjU1YzQ2MA==
5
5
  data.tar.gz: !binary |-
6
- NTgzYWNiNmEyM2I4M2IzOWM3YWE4NGZhMjY3ZDI3MDE2OWRkMjM4Zg==
6
+ NTllOGQ4MjEwY2UyZDNiMDI3YTAyNTgwY2UwNGU5NWRhYmFhOTY4ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2YwMmU2Mzg0YWEzZWJjYWI5NzAyYzhkYzdiYzQ5YzYzOTFlYmU4OTRhMTQz
10
- MjQzMzExYTQ0OWFkNWNiZjk4YWQ5OGE2MzRmZTU1ZDZjMjcwODNhNzNiMDU1
11
- Y2EyNmQ1ZDhmODI4NGY2ZDcxYjIzZDc2M2EyYWQ0MDBkOGFiMzE=
9
+ Yjc5M2JmOTBmNWMyNWRiMmU3YzE5ZWE3OGMyYzM0MzM4OTQ5ZGExYjdjMjZm
10
+ NWM4YWQwNDJmZjQ1MjBlNzBjY2M2YjlmMTRhYTE1YjZiYmZjMjdhNzZjMTNj
11
+ ZTZiMTM2OWMwYmI3MDQ1ODhkNGYxMzcyN2RhZjI3N2ExNTgzNTM=
12
12
  data.tar.gz: !binary |-
13
- NGYyMGVkMmVmZjMwMGZmM2JmOGUxNGMyNmFmYzgyODk4ZTIwNWIwZjExMjIy
14
- NDBkMjBkZWYxOTRmNzU1YzEwMzI2MzBlNGJlZDY0ZTE5ODA2YzZiMmI3MGU3
15
- NTM0YjFiYmQ0YTQ5NzZkYzAyOGRhODljMmJjNDNhZGU0ZjhmYjE=
13
+ NmZjYWIxMjM4MWMzNzE0MTlmMDg1Y2ZmOGNiYzgxZGFmYzNmNzljNDc0Mzk0
14
+ ODc4MmNhMDNmMWU3MmU5NGE5Y2VhODFjYjY1ZDdkMWFkYjA4MjI5NDg4MTU3
15
+ ZWMwMzEzMTRiM2QwMDllODBkMjA3ZDVmOTcwYmJiYjQwZjk3NzM=
@@ -1,6 +1,21 @@
1
1
  require 'concurrent/executors'
2
2
  require 'concurrent/promise'
3
3
 
4
+ class Proc
5
+ def self.compose(f, g)
6
+ lambda { |*args| f[g[*args]] }
7
+ end
8
+
9
+ def *(g)
10
+ Proc.compose(self, g)
11
+ end
12
+
13
+ def and(g)
14
+ Proc.compose(g, self)
15
+ end
16
+ alias and_then and
17
+ end
18
+
4
19
  module Functions
5
20
  private
6
21
  def monoid(fn, id)
@@ -0,0 +1,10 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe 'Functions' do
4
+ it 'should allow function composition and method chaining' do
5
+ add_2 = ->(value) { value+2 }
6
+ divide_by_2 = ->(value) { value/2 }
7
+ expect(sequence(10).map(divide_by_2 * add_2)).to eq(sequence(6))
8
+ expect(sequence(10).map(divide_by_2.and(add_2))).to eq(sequence(7))
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totally_lazy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.52
4
+ version: 0.1.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raymond Barlow
@@ -170,6 +170,7 @@ files:
170
170
  - readme.md
171
171
  - spec/spec_helper.rb
172
172
  - spec/totally_lazy/either_spec.rb
173
+ - spec/totally_lazy/functions_spec.rb
173
174
  - spec/totally_lazy/maps_spec.rb
174
175
  - spec/totally_lazy/option_spec.rb
175
176
  - spec/totally_lazy/predicates_spec.rb