totally_lazy 0.1.52 → 0.1.53
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 +8 -8
 - data/lib/totally_lazy/functions.rb +15 -0
 - data/spec/totally_lazy/functions_spec.rb +10 -0
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                ZTdhZDRmMzNkZmNiODRjYjcxMTFjM2Y1NDgwN2MxZWFiMjU1YzQ2MA==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                NTllOGQ4MjEwY2UyZDNiMDI3YTAyNTgwY2UwNGU5NWRhYmFhOTY4ZA==
         
     | 
| 
       7 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                Yjc5M2JmOTBmNWMyNWRiMmU3YzE5ZWE3OGMyYzM0MzM4OTQ5ZGExYjdjMjZm
         
     | 
| 
      
 10 
     | 
    
         
            +
                NWM4YWQwNDJmZjQ1MjBlNzBjY2M2YjlmMTRhYTE1YjZiYmZjMjdhNzZjMTNj
         
     | 
| 
      
 11 
     | 
    
         
            +
                ZTZiMTM2OWMwYmI3MDQ1ODhkNGYxMzcyN2RhZjI3N2ExNTgzNTM=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 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. 
     | 
| 
      
 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
         
     |