rubiks 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ ## 0.1.6
2
+ * Added controls to flush the schema cache and reset the mondrian connection
3
+
1
4
  ## 0.1.5
2
5
  * Better error messages
3
6
 
@@ -20,11 +20,16 @@ module ::Rubiks
20
20
  autoload :CalculatedMeasure, 'rubiks/calculated_measure'
21
21
 
22
22
  def self.connection
23
- raise 'No connection has been specified - try requiring rubiks/mondrian'
23
+ Rubiks::Mondrian.connection
24
+ end
25
+
26
+ def self.clear_cache
27
+ ::Rubiks::Mondrian.flush_schema_cache
28
+ ::Rubiks::Mondrian.reset_connection
24
29
  end
25
30
 
26
31
  def self.execute(query)
27
- connection.execute(query)
32
+ ::Rubiks::Mondrian.connection.execute(query)
28
33
  end
29
34
 
30
35
  def self.schema
@@ -8,10 +8,6 @@ Dir[File.expand_path('../mondrian/jars/*.jar', __FILE__)].each{ |jar| require ja
8
8
  Java::mondrian.olap4j.MondrianOlap4jDriver
9
9
 
10
10
  module ::Rubiks
11
- def self.connection
12
- @connection ||= ::Rubiks::Mondrian.connection
13
- end
14
-
15
11
  module Mondrian
16
12
  def self.connection
17
13
  @connection ||= ::Rubiks::Mondrian::Connection.create(
@@ -40,5 +36,21 @@ module ::Rubiks
40
36
  end
41
37
  end
42
38
  end
39
+
40
+ def self.execute(query)
41
+ connection.execute(query)
42
+ end
43
+
44
+ # After the cache is flushed we must reset the connection
45
+ def self.flush_schema_cache
46
+ connection.flush_schema_cache
47
+ end
48
+
49
+ def self.reset_connection
50
+ connection.close
51
+ @connection = ::Rubiks::Mondrian::Connection.create(
52
+ config.merge(:catalog_content => ::Rubiks.schema.to_xml)
53
+ )
54
+ end
43
55
  end
44
56
  end
@@ -83,6 +83,14 @@ module ::Rubiks
83
83
  end
84
84
  end
85
85
 
86
+ # Will affect only the next created connection. If it is necessary to clear all schema cache then
87
+ # flush_schema_cache should be called, then close and then new connection should be created.
88
+ def flush_schema_cache
89
+ unwrapped_connection = @raw_connection.unwrap(Java::MondrianOlap::Connection.java_class)
90
+ raw_cache_control = unwrapped_connection.getCacheControl(nil)
91
+ raw_cache_control.flushSchemaCache
92
+ end
93
+
86
94
  private
87
95
 
88
96
  def connection_string
@@ -1,3 +1,3 @@
1
1
  module ::Rubiks
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubiks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
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-05-01 00:00:00.000000000 Z
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -85,7 +85,6 @@ extra_rdoc_files: []
85
85
  files:
86
86
  - .gitignore
87
87
  - .rspec
88
- - .rvmrc
89
88
  - .travis.yml
90
89
  - .yardopts
91
90
  - CHANGELOG.md
@@ -165,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
164
  version: '0'
166
165
  segments:
167
166
  - 0
168
- hash: -1745448191205175885
167
+ hash: -2941452672752005346
169
168
  required_rubygems_version: !ruby/object:Gem::Requirement
170
169
  none: false
171
170
  requirements:
@@ -174,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
173
  version: '0'
175
174
  segments:
176
175
  - 0
177
- hash: -1745448191205175885
176
+ hash: -2941452672752005346
178
177
  requirements: []
179
178
  rubyforge_project:
180
179
  rubygems_version: 1.8.25
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3