sylvaing-seer 0.7.1
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.
- data/CONTRIBUTORS +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +51 -0
- data/Rakefile +64 -0
- data/init.rb +1 -0
- data/lib/seer.rb +63 -0
- data/lib/seer/area_chart.rb +139 -0
- data/lib/seer/bar_chart.rb +124 -0
- data/lib/seer/chart.rb +60 -0
- data/lib/seer/column_chart.rb +124 -0
- data/lib/seer/gauge.rb +119 -0
- data/lib/seer/line_chart.rb +143 -0
- data/lib/seer/pie_chart.rb +116 -0
- data/spec/area_chart_spec.rb +108 -0
- data/spec/bar_chart_spec.rb +51 -0
- data/spec/chart_spec.rb +62 -0
- data/spec/column_chart_spec.rb +51 -0
- data/spec/custom_matchers.rb +23 -0
- data/spec/gauge_spec.rb +59 -0
- data/spec/helpers.rb +37 -0
- data/spec/line_chart_spec.rb +86 -0
- data/spec/pie_chart_spec.rb +51 -0
- data/spec/seer_spec.rb +134 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +13 -0
- metadata +117 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Seer::PieChart" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@chart = Seer::PieChart.new(
|
7
|
+
:data => [0,1,2,3],
|
8
|
+
:label_method => 'to_s',
|
9
|
+
:data_method => 'size',
|
10
|
+
:chart_options => {},
|
11
|
+
:chart_element => 'chart'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'defaults' do
|
16
|
+
it_should_behave_like 'it sets default values'
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'graph options' do
|
20
|
+
|
21
|
+
[:background_color, :border_color, :enable_tooltip, :focus_border_color, :height, :is_3_d, :legend, :legend_background_color, :legend_font_size, :legend_text_color, :pie_join_angle, :pie_minimal_angle, :title, :title_x, :title_y, :title_color, :title_font_size, :tooltip_font_size, :tooltip_height, :tooltip_width, :width].each do |accessor|
|
22
|
+
it "sets its #{accessor} value" do
|
23
|
+
@chart.send("#{accessor}=", 'foo')
|
24
|
+
@chart.send(accessor).should == 'foo'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it_should_behave_like 'it has colors attribute'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'renders as JavaScript' do
|
32
|
+
(@chart.to_js =~ /javascript/).should be_true
|
33
|
+
(@chart.to_js =~ /piechart/).should be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'sets its data columns' do
|
37
|
+
@chart.data_columns.should =~ /addRows\(4\)/
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'sets its data table' do
|
41
|
+
@chart.data_table.to_s.should set_value(0, 0,'0')
|
42
|
+
@chart.data_table.to_s.should set_value(0, 1, 8)
|
43
|
+
@chart.data_table.to_s.should set_value(1, 0,'1')
|
44
|
+
@chart.data_table.to_s.should set_value(1, 1, 8)
|
45
|
+
@chart.data_table.to_s.should set_value(2, 0,'2')
|
46
|
+
@chart.data_table.to_s.should set_value(2, 1, 8)
|
47
|
+
@chart.data_table.to_s.should set_value(3, 0,'3')
|
48
|
+
@chart.data_table.to_s.should set_value(3, 1, 8)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec/seer_spec.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Seer" do
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
it 'validates hexadecimal numbers' do
|
8
|
+
invalid = [nil, '', 'food', 'bdadce', 123456]
|
9
|
+
valid = ['#000000','#ffffff']
|
10
|
+
invalid.each{ |e| Seer.valid_hex_number?(e).should be_false }
|
11
|
+
valid.each { |e| Seer.valid_hex_number?(e).should be_true }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'visualize' do
|
15
|
+
|
16
|
+
it 'raises an error for invalid visualizaters' do
|
17
|
+
invalid = [:random, 'something']
|
18
|
+
invalid.each do |e|
|
19
|
+
lambda do
|
20
|
+
Seer.visualize([1,2,3], :as => e)
|
21
|
+
end.should raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'raises an error for missing data' do
|
26
|
+
_data = []
|
27
|
+
lambda do
|
28
|
+
Seer.visualize(_data, :as => :bar_chart)
|
29
|
+
end.should raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'accepts valid visualizers' do
|
33
|
+
Seer::VISUALIZERS.each do |v|
|
34
|
+
lambda do
|
35
|
+
Seer::visualize(
|
36
|
+
[0,1,2,3],
|
37
|
+
:as => v,
|
38
|
+
:in_element => 'chart',
|
39
|
+
:series => {:label => 'to_s', :data => 'size'},
|
40
|
+
:chart_options => {}
|
41
|
+
)
|
42
|
+
end.should_not raise_error(ArgumentError)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'private chart methods' do
|
49
|
+
|
50
|
+
it 'renders an area chart' do
|
51
|
+
(Seer.send(:area_chart,
|
52
|
+
[0,1,2,3],
|
53
|
+
:as => :area_chart,
|
54
|
+
:in_element => 'chart',
|
55
|
+
:series => {
|
56
|
+
:series_label => 'to_s',
|
57
|
+
:data_label => 'to_s',
|
58
|
+
:data_method => 'size',
|
59
|
+
:data_series => [[1,2,3],[3,4,5]]
|
60
|
+
},
|
61
|
+
:chart_options => {}
|
62
|
+
) =~ /areachart/).should be_true
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'renders a bar chart' do
|
66
|
+
(Seer.send(:bar_chart,
|
67
|
+
[0,1,2,3],
|
68
|
+
:as => :bar_chart,
|
69
|
+
:in_element => 'chart',
|
70
|
+
:series => {
|
71
|
+
:series_label => 'to_s',
|
72
|
+
:data_method => 'size'
|
73
|
+
},
|
74
|
+
:chart_options => {}
|
75
|
+
) =~ /barchart/).should be_true
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'renders a column chart' do
|
79
|
+
(Seer.send(:column_chart,
|
80
|
+
[0,1,2,3],
|
81
|
+
:as => :column_chart,
|
82
|
+
:in_element => 'chart',
|
83
|
+
:series => {
|
84
|
+
:series_label => 'to_s',
|
85
|
+
:data_method => 'size'
|
86
|
+
},
|
87
|
+
:chart_options => {}
|
88
|
+
) =~ /columnchart/).should be_true
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'renders a gauge' do
|
92
|
+
(Seer.send(:gauge,
|
93
|
+
[0,1,2,3],
|
94
|
+
:as => :gauge,
|
95
|
+
:in_element => 'chart',
|
96
|
+
:series => {
|
97
|
+
:series_label => 'to_s',
|
98
|
+
:data_method => 'size'
|
99
|
+
},
|
100
|
+
:chart_options => {}
|
101
|
+
) =~ /gauge/).should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'renders a line chart' do
|
105
|
+
(Seer.send(:line_chart,
|
106
|
+
[0,1,2,3],
|
107
|
+
:as => :line_chart,
|
108
|
+
:in_element => 'chart',
|
109
|
+
:series => {
|
110
|
+
:series_label => 'to_s',
|
111
|
+
:data_label => 'to_s',
|
112
|
+
:data_method => 'size',
|
113
|
+
:data_series => [[1,2,3],[3,4,5]]
|
114
|
+
},
|
115
|
+
:chart_options => {}
|
116
|
+
) =~ /linechart/).inspect #should be_true
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'renders a pie chart' do
|
120
|
+
(Seer.send(:pie_chart,
|
121
|
+
[0,1,2,3],
|
122
|
+
:as => :pie_chart,
|
123
|
+
:in_element => 'chart',
|
124
|
+
:series => {
|
125
|
+
:series_label => 'to_s',
|
126
|
+
:data_method => 'size'
|
127
|
+
},
|
128
|
+
:chart_options => {}
|
129
|
+
) =~ /piechart/).should be_true
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
require 'active_support'
|
5
|
+
require 'action_pack'
|
6
|
+
require 'spec'
|
7
|
+
require 'spec/autorun'
|
8
|
+
require 'seer'
|
9
|
+
require File.dirname(__FILE__) + "/custom_matchers"
|
10
|
+
require File.dirname(__FILE__) + '/helpers'
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
config.include(CustomMatcher)
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sylvaing-seer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 1
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Corey Ehmke / SEO Logic
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-05-11 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: " Seer is a lightweight, semantically rich wrapper for the Google Visualization API. It allows you to easily create a visualization of data in a variety of formats, including area charts, bar charts, column charts, gauges, line charts, and pie charts."
|
38
|
+
email: corey@seologic.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- LICENSE
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- CONTRIBUTORS
|
48
|
+
- LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- init.rb
|
52
|
+
- lib/seer.rb
|
53
|
+
- lib/seer/area_chart.rb
|
54
|
+
- lib/seer/bar_chart.rb
|
55
|
+
- lib/seer/chart.rb
|
56
|
+
- lib/seer/column_chart.rb
|
57
|
+
- lib/seer/gauge.rb
|
58
|
+
- lib/seer/line_chart.rb
|
59
|
+
- lib/seer/pie_chart.rb
|
60
|
+
- spec/seer_spec.rb
|
61
|
+
- spec/spec.opts
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- spec/area_chart_spec.rb
|
64
|
+
- spec/bar_chart_spec.rb
|
65
|
+
- spec/chart_spec.rb
|
66
|
+
- spec/column_chart_spec.rb
|
67
|
+
- spec/custom_matchers.rb
|
68
|
+
- spec/gauge_spec.rb
|
69
|
+
- spec/helpers.rb
|
70
|
+
- spec/line_chart_spec.rb
|
71
|
+
- spec/pie_chart_spec.rb
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: http://github.com/Bantik/seer
|
74
|
+
licenses: []
|
75
|
+
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options:
|
78
|
+
- --charset=UTF-8
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.3.7
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Seer is a lightweight, semantically rich wrapper for the Google Visualization API.
|
106
|
+
test_files:
|
107
|
+
- spec/area_chart_spec.rb
|
108
|
+
- spec/bar_chart_spec.rb
|
109
|
+
- spec/chart_spec.rb
|
110
|
+
- spec/column_chart_spec.rb
|
111
|
+
- spec/custom_matchers.rb
|
112
|
+
- spec/gauge_spec.rb
|
113
|
+
- spec/helpers.rb
|
114
|
+
- spec/line_chart_spec.rb
|
115
|
+
- spec/pie_chart_spec.rb
|
116
|
+
- spec/seer_spec.rb
|
117
|
+
- spec/spec_helper.rb
|