Skip to content

Latest commit

 

History

History
137 lines (95 loc) · 2.3 KB

README.md

File metadata and controls

137 lines (95 loc) · 2.3 KB

UniData ORM Build Status Coverage Status Code Climate

A simple ORM for Rocket's UniData database.

Installation

Add this line to your application's Gemfile:

gem 'unidata'

And then execute:

$ bundle

Or install it yourself as:

$ gem install unidata

Usage

Connecting to Unidata:

Unidata.prepare_connection(
  :user     => "admin",
  :password => "secret",
  :host     => "localhost",
  :data_dir => "/usr/uv/db"
)

Unidata.open_connection do
  # interact with Unidata here
end

Or, you can manually open and close the connection yourself.

Unidata.open_connection

# interact with Unidata here

Unidata.close_connection

Defining models:

class Product < Unidata::Model
  self.filename = 'PRODUCT'

  field 1, :name,         String
  field 2, :description   # type is optional (defaults to String)
  field 3, :cost,         Float
  field 4, :available_on, Date
end

Creating records:

thingamajig = Product.new(
  :id         => 12345,
  :name       =>'Thingamajig',
  :cost       => 125.99,
  :available  => Date.today
)
thingamajig.save

whatsit = Product.new
whatsit.id = 12346
whatsit.name = 'Whatsit'
whatsit.cost = 999.99 
whatsit.available = Date.today
whatsit.save

Retrieving records:

product = Product.find(12345)

Or, you can just check if a record exists:

Product.exists?(12345)

Deleting records:

product = Product.find(12345)
product.destroy

Or, you can delete without retrieving first:

Product.delete(12345)

Contributing

Pull requests are welcome. Just make sure to include tests!

To run tests, install some dependencies:

bundle install

Then, run tests with:

rake spec

Or, If you want to check coverage:

COVERAGE=on rake spec

Issues

Please use GitHub's issue tracker.

Author

Jeremy Israelsen