reportability 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +2 -1
- data/README.md +2 -1
- data/lib/reportability/pivot.rb +4 -0
- data/lib/reportability/version.rb +1 -1
- data/spec/lib/pivot_spec.rb +17 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
# v0.2.1 2013-04-24
|
2
|
+
- support procs in Pivot#project to allow better testability
|
data/README.md
CHANGED
data/lib/reportability/pivot.rb
CHANGED
data/spec/lib/pivot_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Reportability do
|
|
5
5
|
[{"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"MUC"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>11}, "provider"=>"EUROTOURS", "tlc"=>"INN"}, "count"=>5}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"GTA", "tlc"=>"LON"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"HOTELBEDS", "tlc"=>"BER"}, "count"=>4}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"HOTELBEDS", "tlc"=>"HAM"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"MIKI", "tlc"=>"BER"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"BER"}, "count"=>25}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"GTA", "tlc"=>"MEX"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"TOURICO", "tlc"=>"BER"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>10}, "provider"=>"WOTRA", "tlc"=>"BZO"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"BUD"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"GTA", "tlc"=>"BER"}, "count"=>8}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"GTA", "tlc"=>"WRO"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>10}, "provider"=>"REZROOMZ", "tlc"=>"BER"}, "count"=>4}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"ESS"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>11}, "provider"=>"WOTRA", "tlc"=>"MUN"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"GTA", "tlc"=>"WRO"}, "count"=>3}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>11}, "provider"=>"WOTRA", "tlc"=>"BZO"}, "count"=>51}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"HOTELBEDS", "tlc"=>"MUC"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"LON"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>10}, "provider"=>"REZROOMZ", "tlc"=>"WRO"}, "count"=>6}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"MGL"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"KUONI", "tlc"=>"RSE"}, "count"=>6}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"GTA", "tlc"=>"BKK"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"VIE"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"JACTRAVEL", "tlc"=>"BER"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"KUONI", "tlc"=>"BER"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"WRO"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>11}, "provider"=>"WOTRA", "tlc"=>"LAX"}, "count"=>6}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>10}, "provider"=>"GTA", "tlc"=>"WRO"}, "count"=>6}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"MEX"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"REZROOMZ", "tlc"=>"LON"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"VIC"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"GTA", "tlc"=>"HAM"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"REZROOMZ", "tlc"=>"WRO"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"JACTRAVEL", "tlc"=>"BER"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"BKK"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"GTA", "tlc"=>"BER"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"REZROOMZ", "tlc"=>"BER"}, "count"=>20}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>10}, "provider"=>"HOTELBEDS", "tlc"=>"BER"}, "count"=>4}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>10}, "provider"=>"WOTRA", "tlc"=>"MUN"}, "count"=>71}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"KUONI", "tlc"=>"BER"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"KUONI", "tlc"=>"LON"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"HOTELBEDS", "tlc"=>"MGL"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"LON"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"HOTELBEDS", "tlc"=>"BER"}, "count"=>8}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"PRG"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"REZROOMZ", "tlc"=>"HAM"}, "count"=>3}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"REZROOMZ", "tlc"=>"WRO"}, "count"=>3}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"INN"}, "count"=>2}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"WRO"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>12}, "provider"=>"WOTRA", "tlc"=>"BZO"}, "count"=>1}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>9}, "provider"=>"GTA", "tlc"=>"BER"}, "count"=>9}, {"key"=>{"date_booked"=>{"y"=>2012, "m"=>8}, "provider"=>"GTA", "tlc"=>"WRO"}, "count"=>1}]
|
6
6
|
end
|
7
7
|
|
8
|
-
it '
|
8
|
+
it 'does something' do
|
9
9
|
r = Reportability::Pivot.new
|
10
10
|
r.project do |row|
|
11
11
|
key = row['key']
|
@@ -19,4 +19,20 @@ describe Reportability do
|
|
19
19
|
t.cols.should == ['group_by', "2012-08", "2012-09", "2012-10", "2012-11", "2012-12"]
|
20
20
|
t.rows.should == [['group_by', "2012-08", "2012-09", "2012-10", "2012-11", "2012-12"], [["REZROOMZ", "MUC"], 1, nil, nil, nil, nil], [["EUROTOURS", "INN"], nil, nil, nil, 5, nil], [["GTA", "LON"], 1, nil, nil, nil, nil], [["HOTELBEDS", "BER"], 4, 8, 4, nil, nil], [["HOTELBEDS", "HAM"], 2, nil, nil, nil, nil], [["MIKI", "BER"], 1, nil, nil, nil, nil], [["REZROOMZ", "BER"], 25, 20, 4, nil, nil], [["GTA", "MEX"], 1, nil, nil, nil, nil], [["TOURICO", "BER"], 1, nil, nil, nil, nil], [["WOTRA", "BZO"], nil, nil, 1, 51, 1], [["WOTRA", "BUD"], nil, nil, nil, nil, 1], [["GTA", "BER"], 8, 9, nil, nil, 1], [["GTA", "WRO"], 1, 3, 6, nil, 2], [["REZROOMZ", "ESS"], 1, nil, nil, nil, nil], [["WOTRA", "MUN"], nil, nil, 71, 1, nil], [["HOTELBEDS", "MUC"], 1, nil, nil, nil, nil], [["REZROOMZ", "LON"], 1, 1, nil, nil, nil], [["REZROOMZ", "WRO"], 1, 3, 6, nil, 2], [["REZROOMZ", "MGL"], 1, nil, nil, nil, nil], [["KUONI", "RSE"], 6, nil, nil, nil, nil], [["GTA", "BKK"], 2, nil, nil, nil, nil], [["WOTRA", "VIE"], nil, nil, nil, nil, 1], [["JACTRAVEL", "BER"], 2, 1, nil, nil, nil], [["KUONI", "BER"], 1, 2, nil, nil, nil], [["WOTRA", "LAX"], nil, nil, nil, 6, nil], [["REZROOMZ", "MEX"], 1, nil, nil, nil, nil], [["WOTRA", "VIC"], nil, nil, nil, nil, 1], [["GTA", "HAM"], 1, nil, nil, nil, nil], [["REZROOMZ", "BKK"], 2, nil, nil, nil, nil], [["KUONI", "LON"], nil, 1, nil, nil, nil], [["HOTELBEDS", "MGL"], 1, nil, nil, nil, nil], [["WOTRA", "LON"], nil, nil, nil, nil, 1], [["WOTRA", "PRG"], nil, nil, nil, nil, 1], [["REZROOMZ", "HAM"], 3, nil, nil, nil, nil], [["WOTRA", "INN"], nil, nil, nil, nil, 2], [["WOTRA", "WRO"], nil, nil, nil, nil, 1]]
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'supports procs in projections' do
|
24
|
+
transformer = ->row {
|
25
|
+
key = row['key']
|
26
|
+
[
|
27
|
+
"%4d-%02d" % [key['date_booked']['y'], key['date_booked']['m']],
|
28
|
+
[key['provider'], key['tlc']],
|
29
|
+
row['count']
|
30
|
+
]
|
31
|
+
}
|
32
|
+
r = Reportability::Pivot.new
|
33
|
+
r.project = transformer
|
34
|
+
t = r.call [:date_booked, :provider_tlc, :count], input
|
35
|
+
t.cols.should == ['group_by', "2012-08", "2012-09", "2012-10", "2012-11", "2012-12"]
|
36
|
+
t.rows.should == [['group_by', "2012-08", "2012-09", "2012-10", "2012-11", "2012-12"], [["REZROOMZ", "MUC"], 1, nil, nil, nil, nil], [["EUROTOURS", "INN"], nil, nil, nil, 5, nil], [["GTA", "LON"], 1, nil, nil, nil, nil], [["HOTELBEDS", "BER"], 4, 8, 4, nil, nil], [["HOTELBEDS", "HAM"], 2, nil, nil, nil, nil], [["MIKI", "BER"], 1, nil, nil, nil, nil], [["REZROOMZ", "BER"], 25, 20, 4, nil, nil], [["GTA", "MEX"], 1, nil, nil, nil, nil], [["TOURICO", "BER"], 1, nil, nil, nil, nil], [["WOTRA", "BZO"], nil, nil, 1, 51, 1], [["WOTRA", "BUD"], nil, nil, nil, nil, 1], [["GTA", "BER"], 8, 9, nil, nil, 1], [["GTA", "WRO"], 1, 3, 6, nil, 2], [["REZROOMZ", "ESS"], 1, nil, nil, nil, nil], [["WOTRA", "MUN"], nil, nil, 71, 1, nil], [["HOTELBEDS", "MUC"], 1, nil, nil, nil, nil], [["REZROOMZ", "LON"], 1, 1, nil, nil, nil], [["REZROOMZ", "WRO"], 1, 3, 6, nil, 2], [["REZROOMZ", "MGL"], 1, nil, nil, nil, nil], [["KUONI", "RSE"], 6, nil, nil, nil, nil], [["GTA", "BKK"], 2, nil, nil, nil, nil], [["WOTRA", "VIE"], nil, nil, nil, nil, 1], [["JACTRAVEL", "BER"], 2, 1, nil, nil, nil], [["KUONI", "BER"], 1, 2, nil, nil, nil], [["WOTRA", "LAX"], nil, nil, nil, 6, nil], [["REZROOMZ", "MEX"], 1, nil, nil, nil, nil], [["WOTRA", "VIC"], nil, nil, nil, nil, 1], [["GTA", "HAM"], 1, nil, nil, nil, nil], [["REZROOMZ", "BKK"], 2, nil, nil, nil, nil], [["KUONI", "LON"], nil, 1, nil, nil, nil], [["HOTELBEDS", "MGL"], 1, nil, nil, nil, nil], [["WOTRA", "LON"], nil, nil, nil, nil, 1], [["WOTRA", "PRG"], nil, nil, nil, nil, 1], [["REZROOMZ", "HAM"], 3, nil, nil, nil, nil], [["WOTRA", "INN"], nil, nil, nil, nil, 2], [["WOTRA", "WRO"], nil, nil, nil, nil, 1]]
|
37
|
+
end
|
22
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reportability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -216,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
216
|
version: '0'
|
217
217
|
segments:
|
218
218
|
- 0
|
219
|
-
hash:
|
219
|
+
hash: -1834946966648212519
|
220
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
221
|
none: false
|
222
222
|
requirements:
|
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
version: '0'
|
226
226
|
segments:
|
227
227
|
- 0
|
228
|
-
hash:
|
228
|
+
hash: -1834946966648212519
|
229
229
|
requirements: []
|
230
230
|
rubyforge_project:
|
231
231
|
rubygems_version: 1.8.23
|