tresse 1.0.0 → 1.1.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/tresse.rb +22 -9
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 05e09726eedc898eea170f57db54ee5ae1bf6e1f
         | 
| 4 | 
            +
              data.tar.gz: 19c6a4a5a4a291d721b79b1882d433464a8d6d1a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2866f086334761f86908eb0a0022c85ff4082081c261994acfab914a8df7b29f1a2693d6e775f40e21bfa3a6b8a60f6ae44f524110603ceeb0657af1928331a9
         | 
| 7 | 
            +
              data.tar.gz: 02b4ef1b7aec9eb6897ef691db0196388c69d0768cbfb79f05473a566b03bedb327c75071ea259ab03328d3561cbceaaf584ec57a59b465f126ca4aef4788587
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/lib/tresse.rb
    CHANGED
    
    | @@ -4,7 +4,7 @@ require 'thread' | |
| 4 4 |  | 
| 5 5 | 
             
            module Tresse
         | 
| 6 6 |  | 
| 7 | 
            -
              VERSION = '1. | 
| 7 | 
            +
              VERSION = '1.1.0'
         | 
| 8 8 |  | 
| 9 9 | 
             
              class << self
         | 
| 10 10 |  | 
| @@ -83,6 +83,12 @@ module Tresse | |
| 83 83 | 
             
              self.init
         | 
| 84 84 |  | 
| 85 85 |  | 
| 86 | 
            +
              def self.call_block(block, args)
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                block.call(*args[0, block.method(:call).arity.abs])
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
             | 
| 86 92 | 
             
              class Batch
         | 
| 87 93 |  | 
| 88 94 | 
             
                attr_reader :group
         | 
| @@ -106,18 +112,12 @@ module Tresse | |
| 106 112 |  | 
| 107 113 | 
             
                def source
         | 
| 108 114 |  | 
| 109 | 
            -
                   | 
| 110 | 
            -
                  args = args[0, @bog.method(:call).arity]
         | 
| 111 | 
            -
             | 
| 112 | 
            -
                  @value = @bog.call(*args)
         | 
| 115 | 
            +
                  @value = Tresse.call_block(@bog, [ group ] + [ nil ] * 7)
         | 
| 113 116 | 
             
                end
         | 
| 114 117 |  | 
| 115 118 | 
             
                def map(type, block)
         | 
| 116 119 |  | 
| 117 | 
            -
                   | 
| 118 | 
            -
                  args = args[0, block.method(:call).arity.abs]
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                  r = block.call(*args)
         | 
| 120 | 
            +
                  r = Tresse.call_block(block, [ @value, self ])
         | 
| 121 121 |  | 
| 122 122 | 
             
                  @value = r if type == :map
         | 
| 123 123 | 
             
                end
         | 
| @@ -153,6 +153,19 @@ module Tresse | |
| 153 153 | 
             
                  self
         | 
| 154 154 | 
             
                end
         | 
| 155 155 |  | 
| 156 | 
            +
                def source_each(collection, &block)
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                  if collection.is_a?(Array)
         | 
| 159 | 
            +
                    collection.each_with_index { |e, i|
         | 
| 160 | 
            +
                      source { Tresse.call_block(block, [ e, i ]) } }
         | 
| 161 | 
            +
                  else
         | 
| 162 | 
            +
                    collection.each { |k, v|
         | 
| 163 | 
            +
                      source { Tresse.call_block(block, [ k, v ]) } }
         | 
| 164 | 
            +
                  end
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                  self
         | 
| 167 | 
            +
                end
         | 
| 168 | 
            +
             | 
| 156 169 | 
             
                #
         | 
| 157 170 | 
             
                # mapping
         | 
| 158 171 |  |