Sha256: eb04a10adaa8954b64b4c200a7f29516cec3e82282cc69325079e2c2290f93e6

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

require 'java'
require 'rubiks/mondrian/connection'
require 'rubiks/mondrian/errors'

Dir[File.expand_path('../mondrian/jars/*.jar', __FILE__)].each{ |jar| require jar }

# register Mondrian olap4j driver
Java::mondrian.olap4j.MondrianOlap4jDriver

module ::Rubiks
  def self.connection
    @connection ||= ::Rubiks::Mondrian.connection
  end

  module Mondrian
    def self.connection
      @connection ||= ::Rubiks::Mondrian::Connection.create(
        config.merge(:catalog_content => ::Rubiks.schema.to_xml)
      )
    end

    def self.config=(new_config)
      @config = new_config
    end

    def self.config
      @config ||= begin
        if defined?(ActiveRecord)
          ar_config = ActiveRecord::Base.connection.config

          {
            :driver           => ar_config[:adapter],
            :host             => ar_config[:host],
            :database         => ar_config[:database],
            :username         => ar_config[:username],
            :password         => ar_config[:password]
          }
        else
          {}
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubiks-0.1.5 lib/rubiks/mondrian.rb
rubiks-0.1.4 lib/rubiks/mondrian.rb
rubiks-0.1.3 lib/rubiks/mondrian.rb
rubiks-0.1.2 lib/rubiks/mondrian.rb
rubiks-0.1.1 lib/rubiks/mondrian.rb
rubiks-0.1.0 lib/rubiks/mondrian.rb