dossier-segmenter 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45113573893155e4c2040fb46129934b97e1b5bc
4
- data.tar.gz: 214531ad0c64053ea2c46cd3a7433f83781be7d6
3
+ metadata.gz: f9038325ef5323032aeed167c1b26867db6ad0b3
4
+ data.tar.gz: 10f41b238d481e5e02436c81e9282589c5408e19
5
5
  SHA512:
6
- metadata.gz: 8173eaee1367eede8c914c8d441d8f120972d9b8a98deceee9cff8d1bc89faa4f28ecf587fd1dc1107b1880d4ffe5fa1a42a0f779bb3e303444aa4f965db0b76
7
- data.tar.gz: 8ac2143c9c31e4bf0b94f693a534e936baa8d2cbf400d7e55da38805767367527e2265ecede018ee4c38faf3c929d03046d0c64d0a30ba1f0d2a27b9efe11544
6
+ metadata.gz: 48aa31724a9c0dbf7a7559c31054d628c44f9fa97430ca5b5dad12b150c6962418434fee81bf57ec30b86318c1243010991f74246e8e1b90f0e9a4d9a0eb48d2
7
+ data.tar.gz: 8d2df7e272d0f3a8406f56f9de45185809a2f935b231e501875ff5b711de15bd42c5de016f76cbf79931518808c80c46e57ae53fb134dc00ba434c796903b978
@@ -1,5 +1,7 @@
1
1
  module Dossier
2
2
  class Segment
3
+ include Segmenter::Summable
4
+
3
5
  attr_accessor :segmenter, :report, :definition, :parent, :options
4
6
 
5
7
  def initialize(segmenter, definition, options = {})
@@ -34,14 +36,6 @@ module Dossier
34
36
  "#<#{self.class.name}:#{key_path}>"
35
37
  end
36
38
 
37
- def summarize(row)
38
- row.tap { summary << row }
39
- end
40
-
41
- def summary
42
- @summary ||= Summary.new(headers)
43
- end
44
-
45
39
  delegate :headers, to: :segmenter
46
40
 
47
41
  private
@@ -35,7 +35,7 @@ module Dossier
35
35
  end
36
36
 
37
37
  def summarize(row)
38
- row.tap { |r| segment.chain.each { |s| s.summarize row } }
38
+ row.tap { |r| [segmenter, segment.chain].flatten.each { |s| s.summarize row } }
39
39
  end
40
40
  end
41
41
  end
@@ -2,8 +2,12 @@ require 'dossier'
2
2
  require 'dossier/segmenter/engine'
3
3
  require 'dossier/segmenter/version'
4
4
 
5
+ require "dossier/segmenter/summable"
6
+
5
7
  module Dossier
6
8
  class Segmenter
9
+ include Summable
10
+
7
11
  attr_accessor :report
8
12
 
9
13
  class << self
@@ -0,0 +1,15 @@
1
+ module Dossier
2
+ class Segmenter
3
+ module Summable
4
+
5
+ def summarize(row)
6
+ row.tap { summary << row }
7
+ end
8
+
9
+ def summary
10
+ @summary ||= Dossier::Segment::Summary.new(headers)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Dossier
2
2
  class Segmenter
3
- VERSION = "0.11.0"
3
+ VERSION = "0.12.0"
4
4
  end
5
5
  end
@@ -39,7 +39,6 @@ describe Dossier::Segment do
39
39
  let(:families) { segmenter.families }
40
40
  let(:domestics) { families.map(&:domestics).flatten }
41
41
  let(:groups) { domestics.map(&:groups).flatten }
42
- let(:rows) { groups.map(&:rows).map(&:to_a) }
43
42
  let(:rows) { groups.inject([]) { |a,g| a += g.rows.to_a } }
44
43
 
45
44
  describe "select the correct amount of segments" do
@@ -162,4 +162,16 @@ describe Dossier::Segmenter do
162
162
  end
163
163
  end
164
164
  end
165
+
166
+
167
+ describe "summarizing" do
168
+ before(:each) {
169
+ # run through all of the rows, triggering each, which calls summarize
170
+ segmenter.families.map(&:domestics).flatten.map(&:groups).flatten.map(&:rows).flatten.map(&:to_a)
171
+ }
172
+
173
+ it "properly sums all rows for the entire report" do
174
+ expect(segmenter.summary.sum(:gifs).to_s).to eq '9006.0'
175
+ end
176
+ end
165
177
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dossier-segmenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hunter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dossier
@@ -145,6 +145,7 @@ files:
145
145
  - lib/dossier/segmenter.rb
146
146
  - lib/dossier/segmenter/engine.rb
147
147
  - lib/dossier/segmenter/report.rb
148
+ - lib/dossier/segmenter/summable.rb
148
149
  - lib/dossier/segmenter/version.rb
149
150
  - script/rails
150
151
  - spec/dossier/segment/chain_spec.rb