rubiks 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -12
- data/Gemfile +2 -0
- data/README.md +90 -72
- data/lib/rubiks/calculated_measure.rb +26 -0
- data/lib/rubiks/cube.rb +80 -0
- data/lib/rubiks/dimension.rb +48 -0
- data/lib/rubiks/hierarchy.rb +46 -0
- data/lib/rubiks/jars/commons-collections.jar +0 -0
- data/lib/rubiks/jars/commons-dbcp.jar +0 -0
- data/lib/rubiks/jars/commons-logging.jar +0 -0
- data/lib/rubiks/jars/commons-math.jar +0 -0
- data/lib/rubiks/jars/commons-pool.jar +0 -0
- data/lib/rubiks/jars/commons-vfs.jar +0 -0
- data/lib/rubiks/jars/eigenbase-properties.jar +0 -0
- data/lib/rubiks/jars/eigenbase-resgen.jar +0 -0
- data/lib/rubiks/jars/eigenbase-xom.jar +0 -0
- data/lib/rubiks/jars/log4j.jar +0 -0
- data/lib/rubiks/jars/mondrian.jar +0 -0
- data/lib/rubiks/jars/olap4j-1.2.0-SNAPSHOT.jar +0 -0
- data/lib/rubiks/jars/olap4j-xmla-1.2.0-SNAPSHOT.jar +0 -0
- data/lib/rubiks/jars/olap4j-xmla.jar.orig +0 -0
- data/lib/rubiks/jars/olap4j-xmlaserver-0.0.1-SNAPSHOT.jar +0 -0
- data/lib/rubiks/jars/olap4j.jar.orig +0 -0
- data/lib/rubiks/jars/postgresql-9.2-1002.jdbc3.jar +0 -0
- data/lib/rubiks/jars/postgresql-9.2-1002.jdbc4.jar +0 -0
- data/lib/rubiks/level.rb +57 -0
- data/lib/rubiks/measure.rb +28 -0
- data/lib/rubiks/mondrian/cell_set.rb +148 -0
- data/lib/rubiks/mondrian/connection.rb +131 -0
- data/lib/rubiks/mondrian/errors.rb +56 -0
- data/lib/rubiks/mondrian/jars/commons-collections-3.2.jar +0 -0
- data/lib/rubiks/mondrian/jars/commons-dbcp-1.2.2.jar +0 -0
- data/lib/rubiks/mondrian/jars/commons-logging-1.1.1.jar +0 -0
- data/lib/rubiks/mondrian/jars/commons-math-1.2.jar +0 -0
- data/lib/rubiks/mondrian/jars/commons-pool-1.4.jar +0 -0
- data/lib/rubiks/mondrian/jars/eigenbase-properties-1.1.2.jar +0 -0
- data/lib/rubiks/mondrian/jars/eigenbase-resgen-1.3.1.jar +0 -0
- data/lib/rubiks/mondrian/jars/eigenbase-xom-1.3.1.jar +0 -0
- data/lib/rubiks/mondrian/jars/log4j-1.2.17.jar +0 -0
- data/lib/rubiks/mondrian/jars/mondrian-4.0.0-SNAPSHOT.jar +0 -0
- data/lib/rubiks/mondrian/jars/olap4j-1.2.0-SNAPSHOT.jar +0 -0
- data/lib/rubiks/mondrian/jars/olap4j-xmla-1.2.0-SNAPSHOT.jar +0 -0
- data/lib/rubiks/mondrian/jars/olap4j-xmlaserver-0.0.1-SNAPSHOT.jar +0 -0
- data/lib/rubiks/mondrian/member.rb +107 -0
- data/lib/rubiks/mondrian.rb +44 -0
- data/lib/rubiks/named_object.rb +121 -0
- data/lib/rubiks/schema.rb +28 -0
- data/lib/rubiks/version.rb +1 -1
- data/lib/rubiks.rb +28 -4
- data/rubiks.gemspec +2 -1
- data/spec/examples/simple_mondrian_schema_spec.rb +56 -0
- data/spec/rubiks/calculated_measure_spec.rb +12 -0
- data/spec/rubiks/cube_spec.rb +29 -0
- data/spec/rubiks/dimension_spec.rb +12 -0
- data/spec/rubiks/hierarchy_spec.rb +15 -0
- data/spec/rubiks/level_spec.rb +20 -0
- data/spec/rubiks/measure_spec.rb +11 -0
- data/spec/rubiks/schema_spec.rb +32 -0
- data/spec/spec_helper.rb +10 -3
- data/spec/support/shared_examples.rb +12 -0
- metadata +85 -47
- data/lib/rubiks/examples.rb +0 -61
- data/lib/rubiks/nodes/annotated_node.rb +0 -26
- data/lib/rubiks/nodes/calculated_member.rb +0 -81
- data/lib/rubiks/nodes/cube.rb +0 -149
- data/lib/rubiks/nodes/dimension.rb +0 -72
- data/lib/rubiks/nodes/hierarchy.rb +0 -100
- data/lib/rubiks/nodes/level.rb +0 -133
- data/lib/rubiks/nodes/measure.rb +0 -75
- data/lib/rubiks/nodes/schema.rb +0 -72
- data/lib/rubiks/nodes/validated_node.rb +0 -79
- data/spec/examples/mondrian_docs_example_spec.rb +0 -108
- data/spec/examples/simple_mondrian_example_spec.rb +0 -84
- data/spec/rubiks/nodes/annotated_node_spec.rb +0 -24
- data/spec/rubiks/nodes/calculated_member_spec.rb +0 -50
- data/spec/rubiks/nodes/cube_spec.rb +0 -63
- data/spec/rubiks/nodes/dimension_spec.rb +0 -41
- data/spec/rubiks/nodes/hierarchy_spec.rb +0 -48
- data/spec/rubiks/nodes/level_spec.rb +0 -93
- data/spec/rubiks/nodes/measure_spec.rb +0 -55
- data/spec/rubiks/nodes/schema_spec.rb +0 -38
- data/spec/rubiks/nodes/validated_node_spec.rb +0 -49
- data/spec/support/examples/mondrian_docs.yml +0 -36
- data/spec/support/examples/shared_dimensions.yml +0 -45
- data/spec/support/matchers/be_like.rb +0 -24
- data/spec/support/schema_context.rb +0 -59
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# This example is taken from the Mondrian documentation:
|
4
|
-
# http://mondrian.pentaho.com/documentation/schema.php#Cubes_and_dimensions
|
5
|
-
# then modified to use Rails/Rubiks conventions
|
6
|
-
#
|
7
|
-
# We want the output to be:
|
8
|
-
#
|
9
|
-
# <schema name="default">
|
10
|
-
# <cube name="Sales">
|
11
|
-
# <table name="view_sales"/>
|
12
|
-
#
|
13
|
-
# <dimension name="Date" foreignKey="date_id">
|
14
|
-
# <hierarchy name="Year Quarter Month" primaryKey="id" hasAll="true">
|
15
|
-
# <table name="view_dates"/>
|
16
|
-
# <level name="Year" column="year"/>
|
17
|
-
# <level name="Quarter" column="quarter"/>
|
18
|
-
# <level name="Month" column="month"/>
|
19
|
-
# </hierarchy>
|
20
|
-
# </dimension>
|
21
|
-
#
|
22
|
-
# <measure name="Unit Sales" column="unit_sales" aggregator="sum" formatString="#,###"/>
|
23
|
-
#
|
24
|
-
# <calculatedMember name="Profit" dimension="Measures" formula="[Measures].[Store Sales] - [Measures].[Store Cost]">
|
25
|
-
# <calculatedMemberProperty name="FORMAT_STRING" value="$#,##0.00"/>
|
26
|
-
# </calculatedMember>
|
27
|
-
# </cube>
|
28
|
-
# </schema>
|
29
|
-
|
30
|
-
describe 'A Mondrian XML Schema' do
|
31
|
-
let(:described_class) { ::Rubiks::Schema }
|
32
|
-
let(:schema_hash) {
|
33
|
-
{
|
34
|
-
'cubes' => [{
|
35
|
-
'name' => 'sales',
|
36
|
-
'measures' => [
|
37
|
-
{
|
38
|
-
'name' => 'unit_sales',
|
39
|
-
'aggregator' => 'sum',
|
40
|
-
'format_string' => '#,###'
|
41
|
-
}
|
42
|
-
],
|
43
|
-
'dimensions' => [
|
44
|
-
{
|
45
|
-
'name' => 'date',
|
46
|
-
'hierarchies' => [{
|
47
|
-
'name' => 'year_quarter_month',
|
48
|
-
'levels' => [
|
49
|
-
{
|
50
|
-
'name' => 'year',
|
51
|
-
'type' => 'numeric'
|
52
|
-
},
|
53
|
-
{
|
54
|
-
'name' => 'quarter',
|
55
|
-
'type' => 'string'
|
56
|
-
},
|
57
|
-
{
|
58
|
-
'name' => 'month',
|
59
|
-
'type' => 'numeric'
|
60
|
-
}
|
61
|
-
]
|
62
|
-
}]
|
63
|
-
}
|
64
|
-
],
|
65
|
-
'calculated_members' => [
|
66
|
-
{
|
67
|
-
'name' => 'Profit',
|
68
|
-
'dimension' => 'Measures',
|
69
|
-
'formula' => '[Measures].[Store Sales] - [Measures].[Store Cost]',
|
70
|
-
'format_string' => '$#,##0.00'
|
71
|
-
}
|
72
|
-
]
|
73
|
-
}]
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
subject { described_class.new_from_hash(schema_hash) }
|
78
|
-
|
79
|
-
describe '#to_xml' do
|
80
|
-
it 'renders XML' do
|
81
|
-
subject.to_xml.should be_like <<-XML
|
82
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
83
|
-
|
84
|
-
<schema name="default">
|
85
|
-
<cube name="Sales">
|
86
|
-
<table name="view_sales"/>
|
87
|
-
|
88
|
-
<dimension name="Date" foreignKey="date_id">
|
89
|
-
<hierarchy name="Year Quarter Month" primaryKey="id" hasAll="true">
|
90
|
-
<table name="view_dates"/>
|
91
|
-
<level name="Year" column="year"/>
|
92
|
-
<level name="Quarter" column="quarter"/>
|
93
|
-
<level name="Month" column="month"/>
|
94
|
-
</hierarchy>
|
95
|
-
</dimension>
|
96
|
-
|
97
|
-
<measure name="Unit Sales" aggregator="sum" formatString="#,###" column="unit_sales"/>
|
98
|
-
|
99
|
-
<calculatedMember name="Profit" dimension="Measures" formula="[Measures].[Store Sales] - [Measures].[Store Cost]">
|
100
|
-
<calculatedMemberProperty name="FORMAT_STRING" value="$#,##0.00"/>
|
101
|
-
</calculatedMember>
|
102
|
-
</cube>
|
103
|
-
</schema>
|
104
|
-
XML
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# This schema is a valid XML schema for Mondrian
|
4
|
-
#
|
5
|
-
# <?xml version="1.0" encoding="UTF-8"?>
|
6
|
-
# <schema name="default">
|
7
|
-
# <cube name="Transactions">
|
8
|
-
# <table name="view_transactions"/>
|
9
|
-
# <dimension name="Date" foreignKey="date_id">
|
10
|
-
# <hierarchy name="Year Quarter Month" primaryKey="id" hasAll="true">
|
11
|
-
# <table name="view_dates"/>
|
12
|
-
# <level name="Year" column="year"/>
|
13
|
-
# <level name="Quarter" column="quarter"/>
|
14
|
-
# <level name="Month" column="month"/>
|
15
|
-
# </hierarchy>
|
16
|
-
# </dimension>
|
17
|
-
# <measure name="Amount" column="amount" aggregator="sum" formatString="$#,###"/>
|
18
|
-
# </cube>
|
19
|
-
# </schema>
|
20
|
-
|
21
|
-
describe 'A simple Mondrian XML Schema' do
|
22
|
-
let(:described_class) { ::Rubiks::Schema }
|
23
|
-
let(:schema_hash) {
|
24
|
-
{
|
25
|
-
'cubes' => [{
|
26
|
-
'name' => 'transactions',
|
27
|
-
'measures' => [
|
28
|
-
{
|
29
|
-
'name' => 'amount',
|
30
|
-
'aggregator' => 'sum',
|
31
|
-
'format_string' => '$#,###'
|
32
|
-
}
|
33
|
-
],
|
34
|
-
'dimensions' => [
|
35
|
-
{
|
36
|
-
'name' => 'date',
|
37
|
-
'hierarchies' => [{
|
38
|
-
'name' => 'year_quarter_month',
|
39
|
-
'levels' => [
|
40
|
-
{
|
41
|
-
'name' => 'year',
|
42
|
-
'type' => 'numeric'
|
43
|
-
},
|
44
|
-
{
|
45
|
-
'name' => 'quarter',
|
46
|
-
'type' => 'numeric'
|
47
|
-
},
|
48
|
-
{
|
49
|
-
'name' => 'month',
|
50
|
-
'type' => 'numeric'
|
51
|
-
}
|
52
|
-
]
|
53
|
-
}]
|
54
|
-
}
|
55
|
-
]
|
56
|
-
}]
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
subject { described_class.new_from_hash(schema_hash) }
|
61
|
-
|
62
|
-
describe '#to_xml' do
|
63
|
-
it 'renders XML' do
|
64
|
-
subject.to_xml.should be_like <<-XML
|
65
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
66
|
-
<schema name="default">
|
67
|
-
<cube name="Transactions">
|
68
|
-
<table name="view_transactions"/>
|
69
|
-
<dimension name="Date" foreignKey="date_id">
|
70
|
-
<hierarchy name="Year Quarter Month" primaryKey="id" hasAll="true">
|
71
|
-
<table name="view_dates"/>
|
72
|
-
<level name="Year" column="year"/>
|
73
|
-
<level name="Quarter" column="quarter"/>
|
74
|
-
<level name="Month" column="month"/>
|
75
|
-
</hierarchy>
|
76
|
-
</dimension>
|
77
|
-
<measure name="Amount" aggregator="sum" formatString="$#,###" column="amount"/>
|
78
|
-
</cube>
|
79
|
-
</schema>
|
80
|
-
XML
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# describe ::Rubiks::AnnotatedNode do
|
4
|
-
# # API
|
5
|
-
# specify { subject.respond_to?(:from_hash) }
|
6
|
-
# specify { subject.respond_to?(:to_hash) }
|
7
|
-
#
|
8
|
-
# context 'when parsed from a valid hash' do
|
9
|
-
# subject { described_class.new.from_hash('name' => 'some_name') }
|
10
|
-
#
|
11
|
-
# its(:name) { should eq('some_name') }
|
12
|
-
#
|
13
|
-
# its(:to_hash) { should have_key('name') }
|
14
|
-
#
|
15
|
-
# it { should be_valid }
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# context 'when parsed from an invalid (empty) hash' do
|
19
|
-
# subject { described_class.new.from_hash({}) }
|
20
|
-
#
|
21
|
-
# it { should_not be_valid }
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::CalculatedMember do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
specify { subject.respond_to?(:dimension) }
|
11
|
-
specify { subject.respond_to?(:formula) }
|
12
|
-
specify { subject.respond_to?(:format_string) }
|
13
|
-
|
14
|
-
context 'when parsed from a valid hash' do
|
15
|
-
subject { described_class.new_from_hash(calculated_member_hash) }
|
16
|
-
|
17
|
-
it { should be_valid }
|
18
|
-
|
19
|
-
its(:to_hash) { should have_key('name') }
|
20
|
-
its(:to_hash) { should have_key('dimension') }
|
21
|
-
its(:to_hash) { should have_key('formula') }
|
22
|
-
its(:to_hash) { should have_key('format_string') }
|
23
|
-
|
24
|
-
|
25
|
-
describe '#to_xml' do
|
26
|
-
it 'renders a calculatedMember tag with attributes' do
|
27
|
-
subject.to_xml.should be_like <<-XML
|
28
|
-
<calculatedMember name="Fake Calculated Member" dimension="Fake Dimension" formula="fake_formula">
|
29
|
-
<calculatedMemberProperty name="FORMAT_STRING" value="$#,##0.00"/>
|
30
|
-
</calculatedMember>
|
31
|
-
XML
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when parsed from an invalid (empty) hash' do
|
37
|
-
subject { described_class.new_from_hash({}) }
|
38
|
-
|
39
|
-
it { should_not be_valid }
|
40
|
-
|
41
|
-
describe '#to_xml' do
|
42
|
-
it 'renders a calculatedMember tag' do
|
43
|
-
subject.to_xml.should be_like <<-XML
|
44
|
-
<calculatedMember>
|
45
|
-
</calculatedMember>
|
46
|
-
XML
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::Cube do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
specify { subject.respond_to?(:dimensions) }
|
11
|
-
specify { subject.respond_to?(:measures) }
|
12
|
-
specify { subject.respond_to?(:calculated_members) }
|
13
|
-
|
14
|
-
context 'when parsed from a valid hash' do
|
15
|
-
subject { described_class.new_from_hash(cube_hash) }
|
16
|
-
|
17
|
-
it { should be_valid }
|
18
|
-
|
19
|
-
its(:to_hash) { should have_key('name') }
|
20
|
-
|
21
|
-
describe '#to_xml' do
|
22
|
-
it 'renders a cube tag with attributes' do
|
23
|
-
subject.to_xml.should include(%Q!<cube name="Fake Cube">!)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when parsed with date_dimension' do
|
29
|
-
subject { described_class.new_from_hash({'date_dimension' => 'Date'}) }
|
30
|
-
its(:to_hash) { should have_key('date_dimension') }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when parsed with person_dimension' do
|
34
|
-
subject { described_class.new_from_hash({'person_dimension' => 'Date'}) }
|
35
|
-
its(:to_hash) { should have_key('person_dimension') }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when parsed with count_measure' do
|
39
|
-
subject { described_class.new_from_hash({'count_measure' => 'Count'}) }
|
40
|
-
its(:to_hash) { should have_key('count_measure') }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when parsed with person_count_measure' do
|
44
|
-
subject { described_class.new_from_hash({'person_count_measure' => 'Count'}) }
|
45
|
-
its(:to_hash) { should have_key('person_count_measure') }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when parsed from an invalid (empty) hash' do
|
49
|
-
subject { described_class.new_from_hash({}) }
|
50
|
-
|
51
|
-
it { should_not be_valid }
|
52
|
-
|
53
|
-
describe '#to_xml' do
|
54
|
-
it 'renders a dimension tag' do
|
55
|
-
subject.to_xml.should be_like <<-XML
|
56
|
-
<cube>
|
57
|
-
</cube>
|
58
|
-
XML
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::Dimension do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
specify { subject.respond_to?(:hierarchies) }
|
11
|
-
|
12
|
-
context 'when parsed from a valid hash' do
|
13
|
-
subject { described_class.new_from_hash(dimension_hash) }
|
14
|
-
|
15
|
-
its(:to_hash) { should have_key('hierarchies') }
|
16
|
-
|
17
|
-
it { should be_valid }
|
18
|
-
|
19
|
-
describe '#to_xml' do
|
20
|
-
it 'renders a dimension tag with attributes' do
|
21
|
-
subject.to_xml.should include(%Q!<dimension name="Fake Dimension" foreignKey="fake_dimension_id">!)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when parsed from an invalid (empty) hash' do
|
27
|
-
subject { described_class.new_from_hash({}) }
|
28
|
-
|
29
|
-
it { should_not be_valid }
|
30
|
-
|
31
|
-
describe '#to_xml' do
|
32
|
-
it 'renders a dimension tag' do
|
33
|
-
subject.to_xml.should be_like <<-XML
|
34
|
-
<dimension>
|
35
|
-
</dimension>
|
36
|
-
XML
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::Hierarchy do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
specify { subject.respond_to?(:levels) }
|
11
|
-
|
12
|
-
context 'when parsed from a valid hash' do
|
13
|
-
subject { described_class.new_from_hash(hierarchy_hash) }
|
14
|
-
|
15
|
-
its(:to_hash) { should have_key('levels') }
|
16
|
-
its(:to_hash) { should have_key('name') }
|
17
|
-
its(:to_hash) { should have_key('dimension') }
|
18
|
-
|
19
|
-
it { should be_valid }
|
20
|
-
|
21
|
-
describe '#to_xml' do
|
22
|
-
it 'renders a hierarchy tag with attributes' do
|
23
|
-
subject.to_xml.should include(%Q!<hierarchy name="Fake Hierarchy" primaryKey="id" hasAll="true">!)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'renders a table tag with attributes' do
|
27
|
-
subject.to_xml.should include(%Q!<table name="view_fake_dimensions"/>!)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when parsed from an invalid (empty) hash' do
|
33
|
-
subject { described_class.new_from_hash({}) }
|
34
|
-
|
35
|
-
it { should_not be_valid }
|
36
|
-
|
37
|
-
describe '#to_xml' do
|
38
|
-
it 'renders a hierarchy and table tag' do
|
39
|
-
subject.to_xml.should be_like <<-XML
|
40
|
-
<hierarchy primaryKey="id" hasAll="true">
|
41
|
-
<table/>
|
42
|
-
</hierarchy>
|
43
|
-
XML
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::Level do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
|
11
|
-
context 'when parsed from a valid hash' do
|
12
|
-
subject { described_class.new_from_hash(level_hash) }
|
13
|
-
|
14
|
-
its(:to_hash) { should have_key('name') }
|
15
|
-
its(:to_hash) { should have_key('data_type') }
|
16
|
-
its(:to_hash) { should have_key('cardinality') }
|
17
|
-
its(:to_hash) { should have_key('contiguous') }
|
18
|
-
|
19
|
-
it { should be_valid }
|
20
|
-
|
21
|
-
describe '#to_json' do
|
22
|
-
it 'includes the cardinality' do
|
23
|
-
subject.to_json.should include('cardinality')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#to_xml' do
|
28
|
-
it 'does not include the cardinality' do
|
29
|
-
subject.to_xml.should_not include('cardinality')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'includes the type' do
|
33
|
-
subject.to_xml.should include('type="Numeric"')
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'renders a level tag with attributes' do
|
37
|
-
subject.to_xml.should be_like <<-XML
|
38
|
-
<level name="Fake Level" column="fake_level" type="Numeric"/>
|
39
|
-
XML
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when parsed with true sort value' do
|
45
|
-
subject { described_class.new_from_hash({'sort' => true}) }
|
46
|
-
|
47
|
-
describe '#to_xml' do
|
48
|
-
it 'has a ordinalColumn' do
|
49
|
-
subject.to_xml.should include('ordinalColumn')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when parsed with sort column' do
|
55
|
-
subject { described_class.new_from_hash({'sort' => 'fake_level_sort'}) }
|
56
|
-
|
57
|
-
describe '#to_xml' do
|
58
|
-
it 'has a ordinalColumn' do
|
59
|
-
subject.to_xml.should include('ordinalColumn')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when parsed from an invalid (empty) hash' do
|
65
|
-
subject { described_class.new_from_hash({}) }
|
66
|
-
|
67
|
-
it { should_not be_valid }
|
68
|
-
|
69
|
-
describe '#to_xml' do
|
70
|
-
it 'renders a level tag' do
|
71
|
-
subject.to_xml.should be_like <<-XML
|
72
|
-
<level/>
|
73
|
-
XML
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when parsed with an invalid cardinality' do
|
79
|
-
subject { described_class.new_from_hash({'cardinality' => 'foo'}) }
|
80
|
-
it { should_not be_valid }
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when parsed with an invalid contiguous value' do
|
84
|
-
subject { described_class.new_from_hash({'contiguous' => 'foo'}) }
|
85
|
-
it { should_not be_valid }
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'when parsed with an invalid data_type' do
|
89
|
-
subject { described_class.new_from_hash({'data_type' => 'foo'}) }
|
90
|
-
it { should_not be_valid }
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::Measure do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
|
11
|
-
context 'when parsed from a valid hash' do
|
12
|
-
subject { described_class.new_from_hash(measure_hash) }
|
13
|
-
|
14
|
-
it { should be_valid }
|
15
|
-
|
16
|
-
its(:to_hash) { should have_key('name') }
|
17
|
-
its(:to_hash) { should have_key('aggregator') }
|
18
|
-
its(:to_hash) { should have_key('format_string') }
|
19
|
-
|
20
|
-
describe '#to_xml' do
|
21
|
-
it 'renders a measure tag with attributes' do
|
22
|
-
subject.to_xml.should be_like <<-XML
|
23
|
-
<measure name="Fake Measure" aggregator="sum" formatString="#{subject.format_string}" column="fake_measure"/>
|
24
|
-
XML
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when parsed with a specific column' do
|
30
|
-
#subject { described_class.new_from_hash(measure_hash.merge('column' => 'foo')) }
|
31
|
-
subject { described_class.new_from_hash('column' => 'foo') }
|
32
|
-
|
33
|
-
describe '#to_xml' do
|
34
|
-
it 'includes the specific column' do
|
35
|
-
subject.to_xml.should be_like <<-XML
|
36
|
-
<measure column="foo"/>
|
37
|
-
XML
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when parsed from an invalid (empty) hash' do
|
43
|
-
subject { described_class.new_from_hash({}) }
|
44
|
-
|
45
|
-
it { should_not be_valid }
|
46
|
-
|
47
|
-
describe '#to_xml' do
|
48
|
-
it 'renders a measure tag' do
|
49
|
-
subject.to_xml.should be_like <<-XML
|
50
|
-
<measure/>
|
51
|
-
XML
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ::Rubiks::Schema do
|
4
|
-
include_context 'schema_context'
|
5
|
-
|
6
|
-
subject { described_class.new_from_hash }
|
7
|
-
|
8
|
-
specify { subject.respond_to?(:from_hash) }
|
9
|
-
specify { subject.respond_to?(:to_hash) }
|
10
|
-
specify { subject.respond_to?(:to_json) }
|
11
|
-
specify { subject.respond_to?(:to_xml) }
|
12
|
-
specify { subject.respond_to?(:cubes) }
|
13
|
-
|
14
|
-
context 'when parsed from a valid hash' do
|
15
|
-
subject { described_class.new_from_hash(schema_hash) }
|
16
|
-
|
17
|
-
it { should be_valid }
|
18
|
-
|
19
|
-
its(:to_hash) { should have_key('cubes') }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when parsed from an invalid (empty) hash' do
|
23
|
-
subject { described_class.new_from_hash({}) }
|
24
|
-
|
25
|
-
it { should_not be_valid }
|
26
|
-
|
27
|
-
describe '#to_xml' do
|
28
|
-
it 'renders XML' do
|
29
|
-
subject.to_xml.should be_like <<-XML
|
30
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
31
|
-
<schema name="default">
|
32
|
-
</schema>
|
33
|
-
XML
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class NodeWithValidation < ::Rubiks::ValidatedNode
|
4
|
-
validates :something
|
5
|
-
|
6
|
-
def something
|
7
|
-
errors << 'Something is required'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class SubNodeWithValidation < NodeWithValidation
|
12
|
-
end
|
13
|
-
|
14
|
-
class NodeWithAdditionalValidation < NodeWithValidation
|
15
|
-
validates :something_else
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
describe NodeWithValidation do
|
22
|
-
subject { described_class }
|
23
|
-
|
24
|
-
it 'has a validator' do
|
25
|
-
subject.validators.length.should eq 1
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when parsed from an invalid (empty) hash' do
|
29
|
-
subject { described_class.new }
|
30
|
-
|
31
|
-
it { should_not be_valid }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe SubNodeWithValidation do
|
36
|
-
subject { described_class }
|
37
|
-
|
38
|
-
it 'inherits the validator of the super class' do
|
39
|
-
subject.validators.length.should eq 1
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe NodeWithAdditionalValidation do
|
44
|
-
subject { described_class }
|
45
|
-
|
46
|
-
it 'has 2 validators' do
|
47
|
-
subject.validators.length.should eq 2
|
48
|
-
end
|
49
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
cubes:
|
2
|
-
- name: sales
|
3
|
-
dimensions:
|
4
|
-
- name: date
|
5
|
-
hierarchies:
|
6
|
-
- name: year_quarter_month
|
7
|
-
levels:
|
8
|
-
- name: year
|
9
|
-
column: the_year
|
10
|
-
data_type: numeric
|
11
|
-
|
12
|
-
- name: quarter
|
13
|
-
data_type: string
|
14
|
-
|
15
|
-
- name: month
|
16
|
-
column: month_of_year
|
17
|
-
data_type: Numeric
|
18
|
-
|
19
|
-
measures:
|
20
|
-
- name: unit_sales
|
21
|
-
aggregator: sum
|
22
|
-
format_string: '#,###'
|
23
|
-
|
24
|
-
- name: store_sales
|
25
|
-
aggregator: sum
|
26
|
-
format_string: '#,###'
|
27
|
-
|
28
|
-
- name: store_cost
|
29
|
-
aggregator: sum
|
30
|
-
format_string: '#,###'
|
31
|
-
|
32
|
-
calculated_members:
|
33
|
-
- name: profit
|
34
|
-
dimension: measures
|
35
|
-
formula: '[Measures].[Store Sales] / [Measures].[Store Cost]'
|
36
|
-
format_string: '$#,##0.00'
|