This file provides guidance to AI coding agents working with this repository.
mondrian-olap is a JRuby gem for performing multidimensional queries of relational database data using Mondrian OLAP Java library.
lib/mondrian-olap.rb- Main gem entry point that requires all componentslib/mondrian/olap.rb- Core module and Java library initializationlib/mondrian/olap/connection.rb- Database connection managementlib/mondrian/olap/schema.rb- OLAP schema definition DSLlib/mondrian/olap/cube.rb- Cube operations and querieslib/mondrian/olap/query.rb- Query builder for MDX-like querieslib/mondrian/olap/result.rb- Query result processing
Mondrian::OLAP::Connection- Manages connections to OLAP data sourcesMondrian::OLAP::Schema- Provides DSL for defining OLAP schemas programmaticallyMondrian::OLAP::Cube- Represents OLAP cubes and provides query interfaceMondrian::OLAP::Query- Builds and executes MDX-like queriesMondrian::OLAP::Result- Handles query results with axes and cells
lib/mondrian/jars/- Contains Mondrian OLAP Java library JAR files- The gem bridges Ruby code with Java Mondrian library using JRuby's Java integration
- Java objects are wrapped in Ruby classes to provide idiomatic Ruby API
- Adding new schema features - Modify
lib/mondrian/olap/schema.rband add corresponding specs inspec/schema_definition_spec.rb - Extending query capabilities - Update
lib/mondrian/olap/query.rband test inspec/query_spec.rb - Connection enhancements - Change
lib/mondrian/olap/connection.rbwith tests inspec/connection_spec.rb - Cube operations - Modify
lib/mondrian/olap/cube.rband add specs inspec/cube_spec.rb
- Write or update RSpec tests for the changed functionality.
- Run specific test file:
rspec spec/cube_spec.rb. - Run all tests with default database:
rake spec. - Test with specific databases:
rake spec:postgresql,rake spec:mysql, etc. - Ensure tests pass with multiple database backends before finalizing changes.
- JRuby 9.4 or later (compatible with Ruby 3.1+)
- Java 8 or later LTS version
- Mondrian OLAP Java library from a fork https://github.com/rsim/mondrian/tree/9.3.0.0-rsim
- Databases: PostgreSQL, MySQL, Oracle, Microsoft SQL Server, ClickHouse or other JDBC compatible databases
- Testing: RSpec
- This gem requires JRuby and will not work with standard MRI Ruby.
- Use JRuby's Java integration features to interact with Mondrian Java library.
- Java objects can be accessed directly in JRuby code.
- JDBC drivers are used for database connections instead of native Ruby database adapters.
- Use meaningful semantic names for variables, methods, and classes.
- Use query and command method conventions.
- Query methods use nouns and do not modify state and do not have side effects. Boolean methods end with
?. - Command methods use verbs that describe the action being taken and may modify state.
- Query methods use nouns and do not modify state and do not have side effects. Boolean methods end with
- Use consistent naming, use the same terminology throughout the codebase.
- Do not use similar variable or method names for different data or objects.
- Write comments to explain why something is done, not what is done.
- Write comments only when it is not obvious from the code.
- Start full sentence comments with a capital letter.
- Prefer self-explanatory code with semantic names over detailed comments.
- Keep methods small and focused on a single task.
- Write simple readable code. Do not obfuscate simple logic.
- Validate correct spelling for variable, method, class names, as well as for comments.
- Do not modify objects (like Hash and Array) that are referenced by argument variables. This might cause unexpected side effects in the caller. It is OK to assign a new object to an argument variable.
- Return collections (arrays or other) from methods with plural names. Do not return nil from methods with plural names, return empty collections in such cases.
- Use &:method for collections:
collection.map(&:method)instead ofcollection.map { |item| item.method }. - Use safe navigation operator
&.when calling methods on objects that might be nil. - When continuing the method call on the next line, then end the first line with a dot.
- Use the new hash syntax
key: 'value'instead of the old syntax:key => 'value'. - Use the old hash syntax only for rake task dependencies, for example,
task :build => :compile. - Use simple parentheses declaring an array of strings
%w()instead of other symbols like%w[]. - Use frozen string literal comments for all Ruby files and ensure that frozen strings are not modified.
- mise might be used to manage Ruby and Java versions.
- If mise is available then prefix ruby, rspec, rake, java calls with
mise exec --to initialize the correct environment.
- Use RSpec for Ruby testing.
- Run individual RSpec test file with e.g.
rspec spec/cube_spec.rb. - Run all RSpec tests with
rake spec(with the defaultmysqldatabase). - Run all tests with a specified database:
rake spec:mysql,rake spec:postgresql,rake spec:sqlserver,rake spec:oracle - In most cases use RSpec should syntax and not expect syntax, for example,
result.should == expected. - Use RSpec expect syntax only for block expectations, for example,
expect { action }.to raise_error(SomeError). - Test data is located in
spec/support/data/directory. - Database-specific schema fixtures are in
spec/fixtures/directory.