stages 0.2.7 → 0.2.8

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.
data/README.md CHANGED
@@ -29,6 +29,12 @@ pipeline = Evens.new | Map.new{ |x| x * 3} | Select.new{ |x| x % 7 == 0}
29
29
  3.times{ pipeline.run } #[0, 42, 84]}
30
30
  ```
31
31
 
32
+ As of 0.2.7, we have a fancy new alternative syntax for this, which feels more like ruby:
33
+ ```ruby
34
+ pipeline = evens | map{|x| x*3} | select{|x| x % 7 == 0}
35
+ ```
36
+ Just include Stages::Sugar to get all the helpers.
37
+
32
38
  Writing New Stages
33
39
  ------------------
34
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -1,9 +1,13 @@
1
1
  module Stages
2
- class Count < Stage
2
+ class Count < Stage
3
3
  def input
4
4
  result = Hash.new{ |h, k| h[k] = 0 }
5
5
  while v = source.run
6
- result[v] += 1
6
+ if v.is_a? Hash
7
+ v.each_pair{ |key, value| result[key] += value }
8
+ else
9
+ result[v] += 1
10
+ end
7
11
  end
8
12
  result.empty? ? nil : result
9
13
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "stages"
8
- s.version = "0.2.7"
8
+ s.version = "0.2.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["The Justice Eight"]
12
- s.date = "2012-01-21"
12
+ s.date = "2012-01-23"
13
13
  s.description = "pipeline builder"
14
14
  s.email = "support@igodigital.com"
15
15
  s.extra_rdoc_files = [
@@ -109,6 +109,11 @@ class TestStages < MiniTest::Unit::TestCase
109
109
  assert_equal(%w(foo bar zut), pipeline.run)
110
110
  end
111
111
 
112
+ test 'count aggregates from prevous counts' do
113
+ pipeline = Each.new([{ a: 2}, { a: 3}]) | Count.new
114
+ assert_equal({ a: 5}, pipeline.run)
115
+ end
116
+
112
117
  def sing
113
118
  { :do => 'doe a deer a female deer',
114
119
  :re => 'ray a drop of golden sun',
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stages
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.7
5
+ version: 0.2.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - The Justice Eight
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-21 00:00:00 Z
13
+ date: 2012-01-23 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- hash: -4442312097613829871
76
+ hash: 534278270114761516
77
77
  segments:
78
78
  - 0
79
79
  version: "0"