sparklines_generator 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/USAGE +14 -0
- data/sparklines_generator.rb +9 -0
- data/templates/sparklines_controller.rb +30 -0
- data/templates/sparklines_helper.rb +30 -0
- metadata +50 -0
data/USAGE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
Generates a controller and helper for making sparklines graphs from a view.
|
3
|
+
|
4
|
+
No arguments are needed.
|
5
|
+
|
6
|
+
The generator creates a controller class in app/controllers and
|
7
|
+
a helper in app/helpers.
|
8
|
+
|
9
|
+
Example:
|
10
|
+
./script/generate sparklines
|
11
|
+
|
12
|
+
This will create:
|
13
|
+
Controller: app/controllers/sparklines_controller.rb
|
14
|
+
Helper: app/helpers/sparklines_helper.rb
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class SparklinesGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
# Model class, unit test, and fixtures.
|
5
|
+
m.template 'sparklines_controller.rb', File.join('app/controllers', "sparklines_controller.rb")
|
6
|
+
m.template 'sparklines_helper.rb', File.join('app/helpers', "sparklines_helper.rb")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
# Handles requests for sparkline graphs.
|
3
|
+
#
|
4
|
+
# You shouldn't need to edit or extend this, but you can read
|
5
|
+
# the documentation for SparklinesHelper to see how to call it from
|
6
|
+
# another view.
|
7
|
+
#
|
8
|
+
# AUTHOR
|
9
|
+
#
|
10
|
+
# Geoffrey Grosenbach[mailto:boss@topfunky.com]
|
11
|
+
#
|
12
|
+
# http://topfunky.com
|
13
|
+
#
|
14
|
+
class SparklinesController < ApplicationController
|
15
|
+
layout nil
|
16
|
+
|
17
|
+
def index
|
18
|
+
# Make array from comma-delimited list of data values
|
19
|
+
ary = []
|
20
|
+
params['results'].split(',').each do |s|
|
21
|
+
ary << s.to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
send_data( Sparklines.plot( ary, params ),
|
25
|
+
:disposition => 'inline',
|
26
|
+
:type => 'image/png',
|
27
|
+
:filename => "spark_#{params[:type]}.png" )
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
# Provides a tag for embedding sparklines graphs into your Rails app.
|
3
|
+
#
|
4
|
+
# To use, load it in your controller with
|
5
|
+
#
|
6
|
+
# helper :sparklines
|
7
|
+
#
|
8
|
+
# AUTHOR
|
9
|
+
#
|
10
|
+
# Geoffrey Grosenbach[mailto:boss@topfunky.com]
|
11
|
+
#
|
12
|
+
# http://topfunky.com
|
13
|
+
#
|
14
|
+
# License
|
15
|
+
#
|
16
|
+
# This code is licensed under the MIT license.
|
17
|
+
#
|
18
|
+
module SparklinesHelper
|
19
|
+
|
20
|
+
# Call with an array of data and a hash of params for the Sparklines module.
|
21
|
+
# You can also pass :class => 'some_css_class' ('sparkline' by default).
|
22
|
+
def sparklines_tag(results=[], options={})
|
23
|
+
url = { :controller => 'sparklines',
|
24
|
+
:results => results.join(',') }
|
25
|
+
options = url.merge(options)
|
26
|
+
|
27
|
+
"<img src=\"#{ url_for options }\" class=\"#{options[:class] || 'sparkline'}\" alt=\"Sparkline Graph\" />"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.10
|
3
|
+
specification_version: 1
|
4
|
+
name: sparklines_generator
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2005-08-01
|
8
|
+
summary: Sparklines generator makes a Rails controller and helper for making small graphs in your web pages. See examples at http://nubyonrails.topfunky.com
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: boss@topfunky.com
|
12
|
+
homepage: http://nubyonrails.topfunky.com
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: sparklines_generator
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
authors:
|
28
|
+
- Geoffrey Grosenbach
|
29
|
+
files:
|
30
|
+
- templates/sparklines_controller.rb
|
31
|
+
- templates/sparklines_helper.rb
|
32
|
+
- sparklines_generator.rb
|
33
|
+
- USAGE
|
34
|
+
test_files: []
|
35
|
+
rdoc_options: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
executables: []
|
38
|
+
extensions: []
|
39
|
+
requirements: []
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sparklines
|
43
|
+
version_requirement:
|
44
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
45
|
+
requirements:
|
46
|
+
-
|
47
|
+
- ">"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.0.0
|
50
|
+
version:
|