Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails engine to let you easily build Geckoboard widgets.
Ruby JavaScript
branch: master

This branch is 3 commits ahead, 12 commits behind ejdraper:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config Fix for Rails 4.
lib
test
.gitignore
Gemfile
Gemfile.lock
MIT-LICENSE
README.rdoc
Rakefile
chameleon.gemspec

README.rdoc

Chameleon

DESCRIPTION:

This is a Rails engine designed to make it super easy to expose data from your application as widgets for use with Geckoboard (geckoboard.com).

This only works for Rails 3 apps.

FEATURES:

This provides a generator to build widgets using a basic DSL syntax to describe the data to be exposed, and the settings for it to be exposed under, and also includes the controller/routing necessary to provide an endpoint for Geckoboard to retrieve the data to display on your dashboard.

Currently it supports the “number and optional secondary stat” (with optional display text), “line”, “pie”, “geckometer”, “rag” and “text” widget types.

SYNOPSIS:

Simply add to your Gemfile as follows:

gem 'chameleon'

Then run “bundle install” and once installed, you can run:

rails g chameleon:widget NAME TYPE

to generate a widget within “app/widgets”. For example, if you want to generate a widget that exposes the amount of users you have in your app currently:

rails g chameleon:widget users number_and_secondary

This will generate something similar to the following in “app/widgets/users_widget.rb”:

widget :users do
  key "3638c90ec12d5a59061ad7b78afcbd050e50b621"
  type "number_and_secondary"
  data do
  end
end

To implement your widget, you simply need to alter it to return the required data - for a “number_and_secondary” type of widget, it requires a hash containing a :value, and optionally, a :previous value to compare it to (such as user count as of yesterday, for example):

widget :users do
  key "3618c90ec02d5a57061ad7b78afcbb050e50b608"
  type "number_and_secondary"
  data do
    {
      :value => User.count,
      :previous => User.count(:conditions => "created_at < '#{1.day.ago.to_s(:db)}'")
    }
  end
end

You can then point Geckoboard at your widget, myapp/widgets/users?key=3618c90ec02d5a57061ad7b78afcbb050e50b608, and Geckoboard will then show the current user count, as well as the percentage difference compared to a day ago.

More documentation on the settings available for the widgets, as well as the different types of widgets, is available on the wiki (github.com/ejdraper/chameleon/wiki).

REQUIREMENTS:

A Rails 3 application.

INSTALL:

It's best to add it to the Gemfile for your Rails 3 app, but if needed you can install the gem manually:

gem install chameleon

CONTRIBUTORS:

Elliott Draper Tim Blair

LICENSE:

Copyright 2011 Elliott Draper <el@ejdraper.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.