cube-no-apes 1.4.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/.document +5 -0
- data/.gitignore +53 -0
- data/.rspec +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +55 -0
- data/LICENSE.txt +20 -0
- data/README.md +69 -0
- data/Rakefile +38 -0
- data/cube-no-apes.gemspec +28 -0
- data/lib/cube.rb +2 -0
- data/lib/cube/cube.rb +149 -0
- data/lib/cube/olap_result.rb +13 -0
- data/lib/cube/version.rb +3 -0
- data/lib/cube/xmla.rb +9 -0
- data/lib/wsdl/xmla.xml +104 -0
- data/spec/cassettes/.yml +40 -0
- data/spec/cassettes/kvartovi_u_recima.yml +167 -0
- data/spec/cassettes/kvatovi_u_koloni.yml +169 -0
- data/spec/cassettes/mondrian_broj_intervencija.yml +269 -0
- data/spec/cassettes/mondrian_jedan_red_odgovor.yml +171 -0
- data/spec/cassettes/mondrian_nula_redaka.yml +159 -0
- data/spec/cassettes/mondrian_scalar_value.yml +166 -0
- data/spec/cassettes/mondrian_vrati_samo_jedan_broj.yml +166 -0
- data/spec/cassettes/razlog_prijave_i_kvart.yml +219 -0
- data/spec/cube_spec.rb +115 -0
- data/spec/spec_helper.rb +12 -0
- metadata +108 -0
data/spec/cube_spec.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'cube'
|
3
|
+
require 'webmock'
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.config do |c|
|
7
|
+
c.cassette_library_dir = 'spec/cassettes'
|
8
|
+
c.stub_with :webmock
|
9
|
+
end
|
10
|
+
|
11
|
+
XMLA.configure do |c|
|
12
|
+
c.endpoint = "http://localhost:8282/icCube/xmla"
|
13
|
+
c.catalog = "GOSJAR"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
describe XMLA::Cube do
|
18
|
+
it 'supports multiple items on x axis' do
|
19
|
+
VCR.use_cassette('kvatovi_u_koloni') do
|
20
|
+
result = XMLA::Cube.execute("select [Lokacija].[Kvart].children on COLUMNS, [Measures].[Broj] on ROWS from [GOSJAR]")
|
21
|
+
result.rows.count.should == 1
|
22
|
+
result.header.count.should == 18
|
23
|
+
result.rows.join('|').should == "Broj|1422|2259|2148|2733|2004|2607|2829|1611|2581|1945|3602|1356|1696|2327|1228|3186|"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'supports multiple items on y axis' do
|
28
|
+
VCR.use_cassette('kvartovi_u_recima') do
|
29
|
+
result = XMLA::Cube.execute("select [Measures].[Broj] on COLUMNS, non empty topcount( [Lokacija].[Kvart].children, 100, [Measures].[Broj]) on ROWS from [GOSJAR]")
|
30
|
+
result.rows.count.should == 16
|
31
|
+
result.header.join('|').should == '|Broj'
|
32
|
+
result.rows[5].join('|').should == 'TRESNJEVKA - JUG|2607'
|
33
|
+
result.rows[15].join('|').should == 'PODSLJEME|1228'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'support multiple items on y axis and multiple items on x axis' do
|
38
|
+
VCR.use_cassette('razlog_prijave_i_kvart') do
|
39
|
+
result = XMLA::Cube.execute("select [Measures].[Broj] on COLUMNS, non empty topcount ( [Razlog prijave].[Razlog].children * [Lokacija].[Kvart].children , 20, [Measures].[Broj] ) on ROWS from [GOSJAR]")
|
40
|
+
result.rows.count.should == 20
|
41
|
+
result.header.join('|').should == "||Broj"
|
42
|
+
result.rows[1].join('|').should == "|GORNJA DUBRAVA|1383"
|
43
|
+
result.rows[19].join('|').should == "Redovna izmjena|GORNJA DUBRAVA|575"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'check if request is correct - to fix that bug with class varables not beign visible inside the block' do
|
48
|
+
XMLA::Cube.send(:request_body, "SELECT", "GOSJAR").gsub("\n","").gsub(" ", "").should ==
|
49
|
+
"<Command><Statement><![CDATA[SELECT]]></Statement></Command><Properties><PropertyList><Catalog>GOSJAR</Catalog>
|
50
|
+
<Format>Multidimensional</Format><AxisFormat>TupleFormat</AxisFormat></PropertyList></Properties>".gsub("\n","").gsub(" ","")
|
51
|
+
end
|
52
|
+
|
53
|
+
def configure_mondrian
|
54
|
+
XMLA.configure do |c|
|
55
|
+
c.endpoint = "http://localhost:8383/mondrian/xmla"
|
56
|
+
c.catalog = "GOSJAR"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should connect to mondrian' do
|
61
|
+
configure_mondrian
|
62
|
+
|
63
|
+
VCR.use_cassette('mondrian_broj_intervencija') do
|
64
|
+
result = XMLA::Cube.execute("SELECT NON EMPTY {Hierarchize({[Measures].[Broj intervencija]})} ON COLUMNS, NON EMPTY {Hierarchize({[Gradska cetvrt].[Gradska cetvrt].Members})} ON ROWS FROM [Kvarovi]")
|
65
|
+
result.rows.count.should == 16
|
66
|
+
result.header.join('|').should == "|Broj intervencija"
|
67
|
+
result.rows[1].join('|').should == "GORNJI GRAD – MEDVEŠČAK|2259"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should handle the case with only one row in result' do
|
72
|
+
configure_mondrian
|
73
|
+
|
74
|
+
VCR.use_cassette('mondrian_jedan_red_odgovor') do
|
75
|
+
result = XMLA::Cube.execute <<-MDX
|
76
|
+
SELECT NON EMPTY {Hierarchize({[Measures].[Broj intervencija]})} ON COLUMNS,
|
77
|
+
non empty ( { Filter (Hierarchize({[Razlog prijave].children}), [Measures].[Broj intervencija] >= 7000 )}) ON ROWS
|
78
|
+
FROM [Kvarovi]
|
79
|
+
MDX
|
80
|
+
result.rows.count.should == 1
|
81
|
+
result.header.join('|').should == "|Broj intervencija"
|
82
|
+
result.rows[0].join('|').should == "Ne radi svjetiljka|14442"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
it 'should handle the case with zero rows in result' do
|
88
|
+
configure_mondrian
|
89
|
+
|
90
|
+
VCR.use_cassette('mondrian_nula_redaka') do
|
91
|
+
result = XMLA::Cube.execute <<-MDX
|
92
|
+
SELECT NON EMPTY {Hierarchize({[Measures].[Broj intervencija]})} ON COLUMNS,
|
93
|
+
non empty ( { Filter (Hierarchize({[Razlog prijave].children}), [Measures].[Broj intervencija] >= 15000 )}) ON ROWS
|
94
|
+
FROM [Kvarovi]
|
95
|
+
MDX
|
96
|
+
result.rows.count.should == 0
|
97
|
+
result.rows[0].should == nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should handle when scalar value is returned' do
|
102
|
+
configure_mondrian
|
103
|
+
|
104
|
+
VCR.use_cassette('mondrian_scalar_value') do
|
105
|
+
result = XMLA::Cube.execute_scalar <<-MDX
|
106
|
+
SELECT {Hierarchize({[Measures].[Rok otklona]})} ON COLUMNS
|
107
|
+
FROM [Kvarovi]
|
108
|
+
WHERE [Vrijeme prijave].[2011]
|
109
|
+
MDX
|
110
|
+
result.should == 7.356
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'cube'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cube-no-apes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- drKreso
|
9
|
+
- stellard
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-05-13 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: savon
|
17
|
+
requirement: &70299572458180 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70299572458180
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: webmock
|
28
|
+
requirement: &70299572457660 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70299572457660
|
37
|
+
description: Eases the pain I had to go through to get to the data out of XMLA based
|
38
|
+
OLAP provider(Mondiran, Pentaho, icCube)
|
39
|
+
email:
|
40
|
+
- kresimir.bojcic@gmail.com
|
41
|
+
- scott@kujilabs.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- .document
|
47
|
+
- .gitignore
|
48
|
+
- .rspec
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- cube-no-apes.gemspec
|
55
|
+
- lib/cube.rb
|
56
|
+
- lib/cube/cube.rb
|
57
|
+
- lib/cube/olap_result.rb
|
58
|
+
- lib/cube/version.rb
|
59
|
+
- lib/cube/xmla.rb
|
60
|
+
- lib/wsdl/xmla.xml
|
61
|
+
- spec/cassettes/.yml
|
62
|
+
- spec/cassettes/kvartovi_u_recima.yml
|
63
|
+
- spec/cassettes/kvatovi_u_koloni.yml
|
64
|
+
- spec/cassettes/mondrian_broj_intervencija.yml
|
65
|
+
- spec/cassettes/mondrian_jedan_red_odgovor.yml
|
66
|
+
- spec/cassettes/mondrian_nula_redaka.yml
|
67
|
+
- spec/cassettes/mondrian_scalar_value.yml
|
68
|
+
- spec/cassettes/mondrian_vrati_samo_jedan_broj.yml
|
69
|
+
- spec/cassettes/razlog_prijave_i_kvart.yml
|
70
|
+
- spec/cube_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
homepage: http://github.com/kujilabs/cube
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.6
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Get's the data from OLAP cube via XMLA(Mondiran, Pentaho, icCube)
|
97
|
+
test_files:
|
98
|
+
- spec/cassettes/.yml
|
99
|
+
- spec/cassettes/kvartovi_u_recima.yml
|
100
|
+
- spec/cassettes/kvatovi_u_koloni.yml
|
101
|
+
- spec/cassettes/mondrian_broj_intervencija.yml
|
102
|
+
- spec/cassettes/mondrian_jedan_red_odgovor.yml
|
103
|
+
- spec/cassettes/mondrian_nula_redaka.yml
|
104
|
+
- spec/cassettes/mondrian_scalar_value.yml
|
105
|
+
- spec/cassettes/mondrian_vrati_samo_jedan_broj.yml
|
106
|
+
- spec/cassettes/razlog_prijave_i_kvart.yml
|
107
|
+
- spec/cube_spec.rb
|
108
|
+
- spec/spec_helper.rb
|