metamolecular / chemcaster-ruby

Ruby Interface for the Chemcaster Web Service Platform

This URL has Read+Write access

rapodaca (author)
Sat Oct 17 16:44:24 -0700 2009
commit  720a94bb51f7578da3bcf693a1435c6daf54bb46
tree    9aaf03b478f8471e49b1d9f3006a3c5a92a27494
parent  a2a41e8e364e92307cc75f6bdfb192b68c29780c
name age message
file .gitignore Sat Oct 03 16:53:33 -0700 2009 streamlined build [rapodaca]
file LICENSE Fri Aug 07 07:14:22 -0700 2009 rdoc [rapodaca]
file README.rdoc Mon Aug 31 13:37:49 -0700 2009 link to rdoc.info [rapodaca]
file Rakefile Loading commit data...
directory lib/
directory spec/
README.rdoc

Chemcaster Ruby API

This is the Ruby interface for the Chemcaster RESTful Web API. It consists of basic functionality needed to create applications using chemical structure registration, storage, imaging, and search.

Installation

Installation through the Ruby Gem hosted on GitHub is recommended:

  # add GitHub to your local list of gem sources:
  gem sources -a http://gems.github.com/

  # install the gem:
  gem install metamolecular-chemcaster

Example Use

Connecting to the Service

   require 'rubygems'
   require 'chemcaster'

   service = Chemcaster::Service.connect 'username', 'password'

Because Chemcaster authenticates using SSL, you’ll need to make sure the Ruby HTTP library can find the root SSL certificates on your system. On Debian Linux systems, these files are found in /etc/ssl/certs. This is also the default location used by the Chemcaster Ruby Client.

To override the default SSL certificates path, pass the root_ca option to the connect method:

   service = Chemcaster::Service.connect 'username', 'password',
     :root_ca => 'path/to/root_ssl_certs'

More information can be found here:

Loading a Registry from a Listing

   require 'rubygems'
   require 'chemcaster'

   service = Chemcaster::Service.connect 'username', 'password'
   registries = service.registries
   registries.size # => 3
   registry = registries[0]

Loading a Registry from a URI

   require 'rubygems'
   require 'chemcaster'

   Chemcaster::Service.connect 'username', 'password'

   link = Chemcaster::Link.new 'name'=> 'foo',
     'uri' => 'https://chemcaster.com/registries/123456',
     'media_type' => 'application/vnd.com.chemcaster.Registry+json'
   registry = link.get

Note: No assumptions should be made about Chemcaster URI layout. Once you receive a resource URI, you can expect it to work at any point in the future for random-access. But URI templates are unnecessary when accessing resources.

Creating a Registry

   require 'rubygems'
   require 'chemcaster'

   service = Chemcaster::Service.connect 'username', 'password'
   registries = service.registries

   registries.create :name => 'CarboBlocks, Inc.'

Changing a Registry Name

   require 'rubygems'
   require 'chemcaster'

   service = Chemcaster::Service.connect 'username', 'password'
   registry = service.registries[0]
   registry.update :name => 'CarboBlocks International, Inc.'

API Documentation

RDoc documentation is available at rdoc.info.