tresse 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/tresse.rb +22 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07e2b40e7224b8da9af9768fb077d0a9552b04ba
4
- data.tar.gz: d5e471d9d944580185fe2aa97e53fec105f87ae8
3
+ metadata.gz: 05e09726eedc898eea170f57db54ee5ae1bf6e1f
4
+ data.tar.gz: 19c6a4a5a4a291d721b79b1882d433464a8d6d1a
5
5
  SHA512:
6
- metadata.gz: e69445a655dc2d80002b087ff8355d1e344a052919be4944b52c94bef65f4065b3d8eb0cf090a0f0e8276cebc028f002399a8b638d892584b51eaefa2cc881fa
7
- data.tar.gz: e812e89f78b44ad82726bc978bd36c780957c645b4fc55278279b770f87ed219c5995ea4ed02a16d5196c78b6d0ebeb87e43ba313d847d0789cff2bb2ff63c2b
6
+ metadata.gz: 2866f086334761f86908eb0a0022c85ff4082081c261994acfab914a8df7b29f1a2693d6e775f40e21bfa3a6b8a60f6ae44f524110603ceeb0657af1928331a9
7
+ data.tar.gz: 02b4ef1b7aec9eb6897ef691db0196388c69d0768cbfb79f05473a566b03bedb327c75071ea259ab03328d3561cbceaaf584ec57a59b465f126ca4aef4788587
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## tresse 1.1.0 released 2019-09-17
6
+
7
+ * Introduce Tresse::Group#source_each(collection, &block)
8
+
9
+
5
10
  ## tresse 1.0.0 released 2019-09-16
6
11
 
7
12
  * #source / #map / #reduce
data/lib/tresse.rb CHANGED
@@ -4,7 +4,7 @@ require 'thread'
4
4
 
5
5
  module Tresse
6
6
 
7
- VERSION = '1.0.0'
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
- args = [ group ] + [ nil ] * 7
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
- args = [ @value, self ]
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tresse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux