Project

rubiks

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A gem to allow defining an OLAP schema from a hash and generate an XML schema for Mondrian
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Rubiks

Gem Version Build Status Dependency Status Code Climate Coverage Status

Rubiks is a Online Analytical Processing ( OLAP ) library written in JRuby. It runs on top of Mondrian (an Open-source OLAP server written in Java) and provides the ability to:

Assumptions

Installation

Run gem install rubiks to install the gem on its own.

Or you can add the following to your Gemfile and run the bundle command to install it.

gem 'rubiks'

Schema Example

After installing the gem, fire up an IRB session with irb or bundle exec irb if you are using Bundler, and follow this (or even paste it into your session):

require 'rubiks'

schema = ::Rubiks::Schema.define :banking do
  cube :transactions do
    dimension :date, :type => 'TimeDimension' do
      hierarchy :yqmwd, :caption => 'YQMWD' do
        level :year,    :level_type => 'TimeYears', :type => :numeric, :contiguous => true
        level :quarter, :level_type => 'TimeQuarters', :type => :numeric, :contiguous => true, :cardinality => :low
        level :month,   :level_type => 'TimeMonths', :type => :numeric, :contiguous => true
        level :week,    :level_type => 'TimeWeeks', :type => :numeric, :column => :week_of_month, :contiguous => true, :cardinality => :low
        level :day,     :level_type => 'TimeDays', :type => :numeric, :contiguous => true
      end
    end

    dimension :account do
      hierarchy :account_type do
        level :asset_liability, :cardinality => :low
        level :account_type
      end
    end

    measure :count, :column => :quantity
    measure :amount, :aggregator => :sum, :format_string => '$#,###'
  end
end

puts schema.to_xml

You should see this XML:

<?xml version="1.0" encoding="UTF-8"?>
<schema name="Banking">
  <cube name="Transactions">
    <table name="view_transactions"/>
    <dimension name="Date" foreignKey="date_id" type="TimeDimension">
      <hierarchy name="YQMWD" hasAll="true" primaryKey="id">
        <table name="view_dates"/>
        <level name="Year" column="year" levelType="TimeYears" type="Numeric"/>
        <level name="Quarter" column="quarter" levelType="TimeQuarters" type="Numeric"/>
        <level name="Month" column="month" levelType="TimeMonths" type="Numeric"/>
        <level name="Week" column="week_of_month" levelType="TimeWeeks" type="Numeric"/>
        <level name="Day" column="day" levelType="TimeDays" type="Numeric"/>
      </hierarchy>
    </dimension>
    <dimension name="Account" foreignKey="account_id">
      <hierarchy name="Account Type" hasAll="true" primaryKey="id">
        <table name="view_accounts"/>
        <level name="Asset Liability" column="asset_liability"/>
        <level name="Account Type" column="account_type"/>
      </hierarchy>
    </dimension>
    <measure name="Count" column="quantity" aggregator="count"/>
    <measure name="Amount" column="amount" aggregator="sum" formatString="$#,###"/>
  </cube>
</schema>

Similar projects

Check out these projects (which have been super helpful in working on Rubiks):

  • Mondrian (git) - source code for Mondrian on GitHub
  • mondrian-olap - a RubyGem wrapping Mondrian
  • Saiku (Saiku on GitHub) - a modular open-source analysis suite offering lightweight OLAP which remains easily embeddable, extendable and configurable.

Contributing

If you'd like to contribute to Rubiks, that's awesome, and we <3 you. There's a guide to contributing (both code and general help) over in CONTRIBUTING.md

Development

To see what has changed in recent versions, see the CHANGELOG.md.