public
Description: Ruby Rack module for generating sparkline graphs on the fly
Homepage: http://rack-sparklines.heroku.com/
Clone URL: git://github.com/technoweenie/sparkplug.git
name age message
file .document Fri Oct 09 20:25:29 -0700 2009 Initial commit to rack-sparklines. [technoweenie]
file .gitignore Sun Nov 01 17:15:21 -0800 2009 hey i may add more sparkline demos [technoweenie]
file LICENSE Fri Oct 09 20:25:29 -0700 2009 Initial commit to rack-sparklines. [technoweenie]
file README.rdoc Sun Nov 01 17:05:09 -0800 2009 change name from rack-sparklines to sparkplug [technoweenie]
file Rakefile Sun Nov 01 17:05:09 -0800 2009 change name from rack-sparklines to sparkplug [technoweenie]
file VERSION Sun Nov 01 17:15:37 -0800 2009 Version bump to 2.0.0 [technoweenie]
directory demos/ Sun Nov 01 17:15:21 -0800 2009 hey i may add more sparkline demos [technoweenie]
directory lib/ Sun Nov 01 17:05:09 -0800 2009 change name from rack-sparklines to sparkplug [technoweenie]
file sparkplug.gemspec Sun Nov 01 17:16:23 -0800 2009 update gemspec [technoweenie]
directory test/ Sun Nov 01 17:05:09 -0800 2009 change name from rack-sparklines to sparkplug [technoweenie]
README.rdoc

sparkplug

Dynamically generates sparkline graphs from a set of numbers. This is done primarily through Handlers and Cachers. Handlers know how to fetch the data, and Cachers know how to cache the generated PNG sparkline for future requests.

    pub_dir   = File.expand_path(File.join(File.dirname(__FILE__), 'public'))
    data_dir  = File.join(pub_dir, 'temps')
    cache_dir = File.join(pub_dir, 'sparks')

    use Sparkplug, :prefix => 'sparks',
      :handler => Sparkplug::Handlers::CsvData.new(data_dir),
      :cacher  => Sparkplug::Cachers::Filesystem.new(cache_dir)
  • An incoming request hits your Rack application at "/sparks/foo/stats.csv".
  • The CSV Handler gets ‘foo/stats.csv’, and checks for this file in its data directory. It parses the first row of numbers as the set of points to plot.
  • The Filesystem Cacher checks for a more recent cache. Failing that, it generates the PNG graph and writes it to the cache directory.

Mix and match your own handlers and cachers with your friends!

Demo

See demo/sparkplug_demo.rb or rack-sparklines.heroku.com/

Codes

gem install sparkplug

github.com/technoweenie/sparkplug

Copyright

Copyright © 2009 rick. See LICENSE for details.