scruffy 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. data/CHANGES +8 -0
  2. data/History.txt +104 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +105 -0
  5. data/PostInstall.txt +6 -0
  6. data/README.txt +66 -0
  7. data/Rakefile +108 -104
  8. data/config/hoe.rb +78 -0
  9. data/config/requirements.rb +15 -0
  10. data/lib/scruffy.rb +8 -6
  11. data/lib/scruffy/components/base.rb +4 -0
  12. data/lib/scruffy/components/legend.rb +65 -30
  13. data/lib/scruffy/components/viewport.rb +14 -17
  14. data/lib/scruffy/formatters.rb +1 -1
  15. data/lib/scruffy/graph.rb +18 -7
  16. data/lib/scruffy/graph_state.rb +24 -0
  17. data/lib/scruffy/helpers.rb +2 -1
  18. data/lib/scruffy/helpers/canvas.rb +19 -17
  19. data/lib/scruffy/helpers/layer_container.rb +8 -3
  20. data/lib/scruffy/helpers/meta.rb +5 -5
  21. data/lib/scruffy/helpers/point_container.rb +70 -0
  22. data/lib/scruffy/layers.rb +2 -0
  23. data/lib/scruffy/layers/average.rb +6 -1
  24. data/lib/scruffy/layers/bar.rb +1 -0
  25. data/lib/scruffy/layers/base.rb +38 -14
  26. data/lib/scruffy/layers/pie.rb +123 -0
  27. data/lib/scruffy/layers/pie_slice.rb +114 -0
  28. data/lib/scruffy/layers/scatter.rb +21 -0
  29. data/lib/scruffy/layers/sparkline_bar.rb +1 -0
  30. data/lib/scruffy/layers/stacked.rb +2 -5
  31. data/lib/scruffy/rasterizers/rmagick_rasterizer.rb +1 -2
  32. data/lib/scruffy/renderers.rb +2 -1
  33. data/lib/scruffy/renderers/base.rb +6 -4
  34. data/lib/scruffy/renderers/pie.rb +20 -0
  35. data/lib/scruffy/themes.rb +54 -4
  36. data/lib/scruffy/version.rb +8 -2
  37. data/script/console +10 -0
  38. data/script/destroy +14 -0
  39. data/script/generate +14 -0
  40. data/script/txt2html +82 -0
  41. data/setup.rb +1585 -0
  42. data/spec/scruffy/graph_spec.rb +175 -0
  43. data/spec/scruffy/layers/base_spec.rb +30 -0
  44. data/spec/{layers → scruffy/layers}/line_spec.rb +2 -1
  45. data/spec/spec_helper.rb +8 -0
  46. data/tasks/deployment.rake +34 -0
  47. data/tasks/environment.rake +7 -0
  48. data/tasks/website.rake +17 -0
  49. data/test/graph_creation_test.rb +101 -0
  50. data/test/test_helper.rb +2 -0
  51. data/test/test_scruffy.rb +11 -0
  52. data/website/images/blank.gif.html +7 -0
  53. data/website/images/graphs/all_smiles.png +0 -0
  54. data/website/images/graphs/bar_test.png +0 -0
  55. data/website/images/graphs/bar_test.svg +71 -0
  56. data/website/images/graphs/line_test.png +0 -0
  57. data/website/images/graphs/line_test.svg +60 -0
  58. data/website/images/graphs/multi_test.png +0 -0
  59. data/website/images/graphs/multi_test.svg +296 -0
  60. data/website/images/graphs/pie_test.png +0 -0
  61. data/website/images/graphs/pie_test.svg +40 -0
  62. data/website/images/graphs/split_test.png +0 -0
  63. data/website/images/graphs/split_test.svg +295 -0
  64. data/website/images/graphs/stacking_test.png +0 -0
  65. data/website/images/graphs/stacking_test.svg +146 -0
  66. data/website/images/header.png +0 -0
  67. data/website/images/header_gradient.png +0 -0
  68. data/website/images/overlay.png +0 -0
  69. data/website/images/scruffy.png +0 -0
  70. data/website/index.html +294 -0
  71. data/website/index.txt +199 -0
  72. data/website/javascripts/application.js +2 -0
  73. data/website/javascripts/controls.js +815 -0
  74. data/website/javascripts/dragdrop.js +913 -0
  75. data/website/javascripts/effects.js +958 -0
  76. data/website/javascripts/lightbox.js +437 -0
  77. data/website/javascripts/prototype.js +2006 -0
  78. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  79. data/website/stylesheets/lightbox.css +27 -0
  80. data/website/stylesheets/screen.css +147 -0
  81. data/website/stylesheets/scruffy.css +227 -0
  82. data/website/template.html.erb +47 -0
  83. metadata +135 -55
  84. data/spec/graph_spec.rb +0 -162
@@ -1,162 +0,0 @@
1
- require 'lib/scruffy'
2
- require 'fileutils'
3
-
4
- module CustomRenderers
5
- def blank_renderer
6
- object = Object.new
7
- object.instance_eval { class << self;self;end }.instance_eval { define_method :render do |options|
8
- puts "Rendering"
9
- end
10
- }
11
- object
12
- end
13
- end
14
-
15
- context "A new Scruffy::Graph" do
16
- include CustomRenderers
17
-
18
- setup do
19
- @graph = Scruffy::Graph.new
20
- end
21
-
22
- specify "should have a blank title" do
23
- @graph.title.should_be.nil
24
- end
25
-
26
- specify "should be set to the keynote theme" do
27
- @graph.theme.should_equal Scruffy::Themes::KEYNOTE
28
- end
29
-
30
- specify "should have zero layers" do
31
- @graph.should_have(0).layers
32
- end
33
-
34
- specify "should not have a default layer type" do
35
- @graph.default_type.should_be.nil
36
- end
37
-
38
- specify "should not have any point markers (x-axis values)" do
39
- @graph.point_markers.should_be.nil
40
- end
41
-
42
- specify "should not have a marker transformer" do
43
- @graph.marker_transformer.should_be.nil
44
- end
45
-
46
- specify "should use a StandardRenderer" do
47
- @graph.renderer.should_be_instance_of Scruffy::StandardRenderer
48
- end
49
-
50
- specify "should accept a new title" do
51
- @graph.title = "New Title"
52
- @graph.title.should_equal "New Title"
53
- end
54
-
55
- specify "should accept a new theme" do
56
- @graph.theme = Scruffy::Themes::MEPHISTO
57
- @graph.theme.should_equal Scruffy::Themes::MEPHISTO
58
- end
59
-
60
- specify "should accept a new default type" do
61
- @graph.default_type = :line
62
- @graph.default_type.should_equal :line
63
- end
64
-
65
- specify "should accept new point markers" do
66
- markers = ['Jan', 'Feb', 'Mar']
67
- @graph.point_markers = markers
68
- @graph.point_markers.should_equal markers
69
- end
70
-
71
- specify "should accept a new renderer" do
72
- renderer = blank_renderer
73
- @graph.renderer = renderer
74
- @graph.renderer.should_equal renderer
75
- end
76
-
77
- specify "should not accept renderers with missing #render methods" do
78
- lambda { @graph.renderer = 1 }.should_raise ArgumentError
79
- end
80
- end
81
-
82
- context "A Scruffy::Graph's initialization block" do
83
- include CustomRenderers
84
-
85
- specify "should accept just a default_type Symbol" do
86
- lambda { Scruffy::Graph.new(:line) }.should_not_raise
87
- end
88
-
89
- specify "should accept just an options hash" do
90
- lambda { Scruffy::Graph.new({:title => "My Title"}) }.should_not_raise
91
- lambda { Scruffy::Graph.new(:title => "My Title", :theme => Scruffy::Themes::KEYNOTE) }.should_not_raise
92
- end
93
-
94
- specify "should accept both a default_type and options hash" do
95
- lambda {
96
- Scruffy::Graph.new(:line, {:title => "My Title"})
97
- Scruffy::Graph.new(:line, :title => "My Title")
98
- }.should_not_raise
99
- end
100
-
101
- specify "should reject any invalid argument combination" do
102
- lambda { Scruffy::Graph.new({:title => "My Title"}, :line) }.should_raise ArgumentError
103
- lambda { Scruffy::Graph.new(:line, {:title => "My Title"}, "Any additional arguments.") }.should_raise ArgumentError
104
- lambda { Scruffy::Graph.new(:line, "Any additional arguments.") }.should_raise ArgumentError
105
- end
106
-
107
- specify "should reject any options that are not supported" do
108
- lambda { Scruffy::Graph.new(:title => "My Title", :some_key => "Some Value") }.should_raise ArgumentError
109
- end
110
-
111
- specify "should successfully save all valid options" do
112
- options = {:title => "My Title",
113
- :theme => {:background => [:black],
114
- :colors => [:red => 'red', :yellow => 'yellow']},
115
- :layers => [ Scruffy::Layers::Line.new(:points => [100, 200, 300]) ],
116
- :default_type => :average,
117
- :renderer => blank_renderer,
118
- :marker_transformer => Scruffy::Transformer::Currency.new,
119
- :point_markers => ['One Hundred', 'Two Hundred', 'Three Hundred']}
120
-
121
- @graph = Scruffy::Graph.new(options)
122
-
123
- @graph.title.should_equal options[:title]
124
- @graph.theme.should_equal options[:theme]
125
- @graph.layers.should_equal options[:layers]
126
- @graph.default_type.should_equal options[:default_type]
127
- @graph.renderer.should_equal options[:renderer]
128
- @graph.marker_transformer.should_equal options[:marker_transformer]
129
- @graph.point_markers.should_equal options[:point_markers]
130
- end
131
- end
132
-
133
- context "A fully populated Graph" do
134
- setup do
135
- FileUtils.rm_f File.dirname(__FILE__) + '/*.png'
136
- FileUtils.rm_f File.dirname(__FILE__) + '/*.jpg'
137
-
138
- @graph = Scruffy::Graph.new :title => 'Test Graph'
139
- @graph << Scruffy::Layers::AllSmiles.new(:title => 'Smiles', :points => [100, 200, 300])
140
- @graph << Scruffy::Layers::Area.new(:title => 'Area', :points => [100, 200, 300])
141
- @graph << Scruffy::Layers::Bar.new(:title => 'Bar', :points => [100, 200, 300])
142
- @graph << Scruffy::Layers::Line.new(:title => 'Line', :points => [100, 200, 300])
143
- @graph << Scruffy::Layers::Average.new(:title => 'Average', :points => @graph.layers)
144
- end
145
-
146
- specify "should render to SVG" do
147
- @graph.render(:width => 800).should_be_instance_of?(String)
148
- end
149
-
150
- specify "should rasterize to PNG" do
151
- lambda {
152
- @graph.render(:width => 800, :as => 'PNG', :to => File.dirname(__FILE__) + '/test_graph.png')
153
- }.should_not_raise
154
- end
155
-
156
- specify "should rasterize to JPG" do
157
- lambda {
158
- @graph.render(:width => 800, :as => 'JPG', :to => File.dirname(__FILE__) + '/test_graph.jpg')
159
- }.should_not_raise
160
- end
161
- end
162
-