cell_set 0.1.0 → 0.1.1
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/lib/cell_set/cell_set.rb +3 -1
- data/lib/cell_set/cell_set_axis.rb +2 -2
- data/lib/cell_set/position.rb +1 -1
- data/lib/cell_set/version.rb +1 -1
- data/lib/cell_set.rb +4 -4
- data/spec/models/cell_set_spec.rb +49 -0
- metadata +2 -2
data/lib/cell_set/cell_set.rb
CHANGED
@@ -27,7 +27,8 @@ module CellSet
|
|
27
27
|
axis.cell_set = self
|
28
28
|
axis
|
29
29
|
elsif axis.is_a?(Hash)
|
30
|
-
|
30
|
+
axis['cell_set'] = self
|
31
|
+
CellSetAxis.new(axis)
|
31
32
|
else
|
32
33
|
throw ArgumentError
|
33
34
|
end
|
@@ -87,6 +88,7 @@ module CellSet
|
|
87
88
|
k = 0
|
88
89
|
@axes.each do |axis|
|
89
90
|
coordinate = coordinates[k]
|
91
|
+
k += 1
|
90
92
|
if coordinate < 0 || coordinate >= axis.positionCount
|
91
93
|
throw IndexError, "Coordinate #{coordinate} of axis #{k} is out of range (#{bounds.join(", ")})"
|
92
94
|
end
|
@@ -36,7 +36,7 @@ module CellSet
|
|
36
36
|
@cell_set = if cell_set.is_a?(CellSet)
|
37
37
|
cell_set
|
38
38
|
elsif cell_set.is_a?(Hash)
|
39
|
-
CellSet.new
|
39
|
+
CellSet.new(cell_set)
|
40
40
|
else
|
41
41
|
throw ArgumentError
|
42
42
|
end
|
@@ -56,7 +56,7 @@ module CellSet
|
|
56
56
|
if position.is_a?(Position)
|
57
57
|
position
|
58
58
|
elsif position.is_a?(Hash)
|
59
|
-
Position.new
|
59
|
+
Position.new(position)
|
60
60
|
else
|
61
61
|
throw ArgumentError
|
62
62
|
end
|
data/lib/cell_set/position.rb
CHANGED
data/lib/cell_set/version.rb
CHANGED
data/lib/cell_set.rb
CHANGED
@@ -13,11 +13,11 @@ end
|
|
13
13
|
require "cell_set/#{file}"
|
14
14
|
end
|
15
15
|
|
16
|
-
%w(ruby).each do |file|
|
17
|
-
require "mondrian/olap/cell_set/#{file}"
|
18
|
-
end
|
19
|
-
|
20
16
|
if RUBY_PLATFORM == "java"
|
17
|
+
%w(ruby).each do |file|
|
18
|
+
require "mondrian/olap/cell_set/#{file}"
|
19
|
+
end
|
20
|
+
|
21
21
|
ActiveSupport.on_load(:cell_set_model) do
|
22
22
|
Java::Mondrian::olap4j::MondrianOlap4jCellSet.send(:include, Mondrian::OLAP::CellSet::Ruby)
|
23
23
|
Mondrian::OLAP::Result.send(:include, ::CellSet::Result)
|
@@ -79,6 +79,55 @@ describe CellSet::CellSet do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
context "cells" do
|
83
|
+
let(:cellHash) do
|
84
|
+
{
|
85
|
+
"0" => {
|
86
|
+
"formatted_value" => "10.0",
|
87
|
+
"value" => 10.0
|
88
|
+
},
|
89
|
+
"4" => {
|
90
|
+
"formatted_value" => "11.0",
|
91
|
+
"value" => 11.0
|
92
|
+
},
|
93
|
+
"6" => {
|
94
|
+
"formatted_value" => "12.0",
|
95
|
+
"value" => 12.0
|
96
|
+
}
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
let(:cell_set) do
|
101
|
+
cell_set = Factory.build(:cell_set)
|
102
|
+
|
103
|
+
cell_set.axes = [0, 1].map do |ordinal|
|
104
|
+
axis = Factory.build(:cell_set_axis, :axis_ordinal => ordinal)
|
105
|
+
axis.should_receive(:positionCount).at_least(:once).and_return(5)
|
106
|
+
axis
|
107
|
+
end
|
108
|
+
|
109
|
+
cell_set.instance_variable_set(:@cellHash, cellHash)
|
110
|
+
|
111
|
+
cell_set
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should have maxOrdinal" do
|
115
|
+
cell_set.maxOrdinal.should == 25
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should have cells" do
|
119
|
+
cell_set.maxOrdinal.times do |num|
|
120
|
+
if cellHash.keys.include?(num.to_s)
|
121
|
+
cell_set.cell(num).value.should == cellHash[num.to_s]["value"]
|
122
|
+
cell_set.cell(cell_set.ordinalToCoordinates(num)).value == cellHash[num.to_s]["value"]
|
123
|
+
else
|
124
|
+
cell_set.cell(num).value.should be_nil
|
125
|
+
cell_set.cell(cell_set.ordinalToCoordinates(num)).value.should be_nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
82
131
|
context "Serialization" do
|
83
132
|
let(:column_position) do
|
84
133
|
Factory.build(:position, :ordinal => 0)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cell_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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: 2012-03-
|
12
|
+
date: 2012-03-26 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|