public
Fork of Floppy/amee-ruby
Description: A ruby gem for accessing the AMEE carbon calculator
Homepage:
Clone URL: git://github.com/hookercookerman/amee-ruby.git
Floppy (author)
Fri Jan 09 05:36:47 -0800 2009
commit  210b136100769f7adfa27c175f331aa8b7c88ac1
tree    71c0e99add1b90ebf367a7c0d11759d23f0de3b5
parent  79ae4424829bcb5eb6f3840ace4f507ae9a79e6e
name age message
file .gitignore Wed Aug 20 12:52:50 -0700 2008 added gem build task to Rakefile [Floppy]
file COPYING Thu Jul 10 06:21:27 -0700 2008 add license and author details [Floppy]
file README Loading commit data...
file Rakefile
file amee-ruby.gemspec
directory bin/ Fri Aug 29 04:17:01 -0700 2008 make ameesh executable [Floppy]
directory examples/
file init.rb Fri Aug 22 06:00:00 -0700 2008 Add Rails plugin functionality and bump to vers... [Floppy]
directory lib/
directory rails/
directory spec/
README
== AMEE-Ruby

A gem to provide a Ruby interface to the AMEE carbon calculator (http://amee.cc)

Licensed under the MIT license (See COPYING file for details)

Author: James Smith (james@floppy.org.uk / http://www.floppy.org.uk)

Homepage: http://github.com/Floppy/amee-ruby

== INSTALLATION

1) Enable gems from github, if you haven't already done so (rubygems >= 1.2): 
    > sudo gem sources -a http://gems.github.com

2) Install gem
    > sudo gem install Floppy-amee

== USAGE

Currently, you can read DataCategories, DataItems and DataItemValues. See 
examples/view_data_*.rb for simple usage examples. You can also get the list
of available Profiles, and create and delete them. See examples/list_profiles.rb
and examples/create_profile.rb for details. You can also load ProfileCategories,
and load, create and update ProfileItems.

The gem will use the AMEE JSON API if the JSON gem is installed on the local
system. Otherwise the XML API will be used.

== SUPPORT
                    Create    Read     Update    Delete
DataCategories         N        Y         N         N
DataItems              N        Y         N         N
DataItemValues         N        Y         N         Y
Profile List           -        Y         -         -
Profiles               Y        -         -         Y
ProfileCategories      -        Y         -         -
 - drilldown           -        Y         -         -
ProfileItems           Y        Y         Y         Y

== INTERACTIVE SHELL

You can use the 'ameesh' app to interactively explore the AMEE data area. Run
'ameesh -u USERNAME -p PASSWORD -s SERVER' to try it out. Source code for this 
tool is in bin/ameesh and lib/amee/shell.rb. Profiles are not accessible through
this interface yet.

== RAILS

This gem can also be used as a Rails plugin. You can either extract it into
vendor/plugins, or use the new-style config.gem command in environment.rb. For
example:

    config.gem "Floppy-amee", :lib => "amee", :source => "http://gems.github.com", :version => '>= 0.3.0'

The first time you run your app after installing the gem, a config/amee.yml file
will be created. You should edit this file and add your AMEE username and
password to it, as well as the server you want to connect to.

Once that is all set up, you can use AMEE objects within Rails anywhere you like.
There is a persistent AMEE connection available called $amee, which you can pass
into the other objects to fetch data. For instance:

    data = AMEE::Data::Category.root($amee)

There is a helper for ActiveRecord models which should be linked to an AMEE profile.
By adding:

    has_amee_profile

to your model, and by adding an amee_profile:string field to the model in the
database, an AMEE profile will be automatically created and destroyed with your
model. By overriding the function amee_save in your model, you can store data in
AMEE when your model is saved.

== CACHING

The AMEE::Connection object implements an optional cache for GET requests. This is
currently a versy simple implementation which caches the result of all GET requests
until a POST, PUT, or DELETE is executed, at which point the cache is cleared. To
enable caching, set the enable_caching parameter of AMEE::Connection.new to true.
Caching is disabled by default.