metamolecular / chemcaster-ruby

Ruby Interface for the Chemcaster Web Service Platform

This URL has Read+Write access

rapodaca (author)
Sat Oct 03 16:53:33 -0700 2009
commit  22ecd709f8c5871829cc4f52c858703e6abd0e89
tree    79d0ab7d546443611283790e778c4e532c7086cc
parent  896325525ca8160ab4015dc851ec336274e2867a
name age message
file .gitignore Loading commit data...
file LICENSE
file README.rdoc
file Rakefile
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.