public
Rubygem
Description: Gruff graphing library for Ruby
Homepage: http://gruff.rubyforge.org
Clone URL: git://github.com/topfunky/gruff.git
Search Repo:
Added generator from plugin
topfunky (author)
Thu Mar 13 09:03:49 -0700 2008
commit  75c59127f7ed8b7d20b8cc8c930347e7ecfe092a
tree    62394d73f7649b791e554b05f4d1c1281fbfe766
parent  454623165c3321268facd9461d33d4b5940c6328
...
52
53
54
 
 
 
55
56
57
...
52
53
54
55
56
57
58
59
60
0
@@ -52,6 +52,9 @@
0
 lib/gruff/stacked_area.rb
0
 lib/gruff/stacked_bar.rb
0
 lib/gruff/stacked_mixin.rb
0
+rails_generators/gruff/gruff_generator.rb
0
+rails_generators/gruff/templates/controller.rb
0
+rails_generators/gruff/templates/functional_test.rb
0
 test/gruff_test_case.rb
0
 test/test_accumulator_bar.rb
0
 test/test_area.rb
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
0
@@ -1 +1,64 @@
0
+class GruffGenerator < Rails::Generator::NamedBase
0
+
0
+ attr_reader :controller_name,
0
+ :controller_class_path,
0
+ :controller_file_path,
0
+ :controller_class_nesting,
0
+ :controller_class_nesting_depth,
0
+ :controller_class_name,
0
+ :controller_singular_name,
0
+ :controller_plural_name,
0
+ :parent_folder_for_require
0
+ alias_method :controller_file_name, :controller_singular_name
0
+ alias_method :controller_table_name, :controller_plural_name
0
+
0
+ def initialize(runtime_args, runtime_options = {})
0
+ super
0
+
0
+ # Take controller name from the next argument.
0
+ @controller_name = runtime_args.shift
0
+
0
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
0
+ @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
0
+
0
+ if @controller_class_nesting.empty?
0
+ @controller_class_name = @controller_class_name_without_nesting
0
+ else
0
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
0
+ end
0
+ end
0
+
0
+ def manifest
0
+ record do |m|
0
+ # Check for class naming collisions.
0
+ m.class_collisions controller_class_path, "#{controller_class_name}Controller",
0
+ "#{controller_class_name}ControllerTest"
0
+
0
+ # Controller, helper, views, and test directories.
0
+ m.directory File.join('app/controllers', controller_class_path)
0
+ m.directory File.join('test/functional', controller_class_path)
0
+
0
+ m.template 'controller.rb',
0
+ File.join('app/controllers',
0
+ controller_class_path,
0
+ "#{controller_file_name}_controller.rb")
0
+
0
+ # For some reason this doesn't take effect if done in initialize()
0
+ @parent_folder_for_require = @controller_class_path.join('/').gsub(%r%app/controllers/?%, '')
0
+ @parent_folder_for_require += @parent_folder_for_require.blank? ? '' : '/'
0
+
0
+ m.template 'functional_test.rb',
0
+ File.join('test/functional',
0
+ controller_class_path,
0
+ "#{controller_file_name}_controller_test.rb")
0
+
0
+ end
0
+ end
0
+
0
+ protected
0
+ # Override with your own usage banner.
0
+ def banner
0
+ "Usage: #{$0} gruff ControllerName"
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -1 +1,33 @@
0
+class <%= controller_class_name %>Controller < ApplicationController
0
+
0
+ # To make caching easier, add a line like this to config/routes.rb:
0
+ # map.graph "graph/:action/:id/image.png", :controller => "graph"
0
+ #
0
+ # Then reference it with the named route:
0
+ # image_tag graph_url(:action => 'show', :id => 42)
0
+
0
+ def show
0
+ g = Gruff::Line.new
0
+ # Uncomment to use your own theme or font
0
+ # See http://colourlovers.com or http://www.firewheeldesign.com/widgets/ for color ideas
0
+# g.theme = {
0
+# :colors => ['#663366', '#cccc99', '#cc6633', '#cc9966', '#99cc99'],
0
+# :marker_color => 'white',
0
+# :background_colors => ['black', '#333333']
0
+# }
0
+# g.font = File.expand_path('artwork/fonts/VeraBd.ttf', RAILS_ROOT)
0
+
0
+ g.title = "Gruff-o-Rama"
0
+
0
+ g.data("Apples", [1, 2, 3, 4, 4, 3])
0
+ g.data("Oranges", [4, 8, 7, 9, 8, 9])
0
+ g.data("Watermelon", [2, 3, 1, 5, 6, 8])
0
+ g.data("Peaches", [9, 9, 10, 8, 7, 9])
0
+
0
+ g.labels = {0 => '2004', 2 => '2005', 4 => '2006'}
0
+
0
+ send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -1 +1,25 @@
0
+require File.dirname(__FILE__) + '<%= '/..' * controller_class_name.split("::").length %>/test_helper'
0
+require '<%= parent_folder_for_require %><%= controller_file_name %>_controller'
0
+
0
+# Re-raise errors caught by the controller.
0
+class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
0
+
0
+class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
0
+
0
+ #fixtures :data
0
+
0
+ def setup
0
+ @controller = <%= controller_class_name %>Controller.new
0
+ @request = ActionController::TestRequest.new
0
+ @response = ActionController::TestResponse.new
0
+ end
0
+
0
+ # TODO Replace this with your actual tests
0
+ def test_show
0
+ get :show
0
+ assert_response :success
0
+ assert_equal 'image/png', @response.headers['Content-Type']
0
+ end
0
+
0
+end

Comments

    No one has commented yet.