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 +4 -4
- data/lib/dossier/segment.rb +2 -8
- data/lib/dossier/segment/rows.rb +1 -1
- data/lib/dossier/segmenter.rb +4 -0
- data/lib/dossier/segmenter/summable.rb +15 -0
- data/lib/dossier/segmenter/version.rb +1 -1
- data/spec/dossier/segment_spec.rb +0 -1
- data/spec/dossier/segmenter_spec.rb +12 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9038325ef5323032aeed167c1b26867db6ad0b3
|
4
|
+
data.tar.gz: 10f41b238d481e5e02436c81e9282589c5408e19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48aa31724a9c0dbf7a7559c31054d628c44f9fa97430ca5b5dad12b150c6962418434fee81bf57ec30b86318c1243010991f74246e8e1b90f0e9a4d9a0eb48d2
|
7
|
+
data.tar.gz: 8d2df7e272d0f3a8406f56f9de45185809a2f935b231e501875ff5b711de15bd42c5de016f76cbf79931518808c80c46e57ae53fb134dc00ba434c796903b978
|
data/lib/dossier/segment.rb
CHANGED
@@ -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
|
data/lib/dossier/segment/rows.rb
CHANGED
data/lib/dossier/segmenter.rb
CHANGED
@@ -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.
|
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-
|
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
|