seer 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +49 -0
- data/Rakefile +63 -0
- data/init.rb +1 -0
- data/lib/seer.rb +58 -0
- data/lib/seer/area_chart.rb +133 -0
- data/lib/seer/bar_chart.rb +124 -0
- data/lib/seer/chart.rb +58 -0
- data/lib/seer/column_chart.rb +124 -0
- data/lib/seer/gauge.rb +119 -0
- data/lib/seer/line_chart.rb +135 -0
- data/lib/seer/pie_chart.rb +116 -0
- data/spec/area_chart_spec.rb +73 -0
- data/spec/bar_chart_spec.rb +65 -0
- data/spec/chart_spec.rb +63 -0
- data/spec/column_chart_spec.rb +65 -0
- data/spec/gauge_spec.rb +57 -0
- data/spec/line_chart_spec.rb +73 -0
- data/spec/pie_chart_spec.rb +65 -0
- data/spec/seer_spec.rb +134 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- metadata +87 -0
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
|
+
:label => 'to_s',
|
72
|
+
:data => '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
|
+
:label => 'to_s',
|
85
|
+
:data => '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
|
+
:label => 'to_s',
|
98
|
+
:data => '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,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'actionpack'
|
4
|
+
require 'activesupport'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
require 'seer'
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Corey Ehmke / SEO Logic
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-17 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
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."
|
26
|
+
email: corey@seologic.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- init.rb
|
39
|
+
- lib/seer.rb
|
40
|
+
- lib/seer/area_chart.rb
|
41
|
+
- lib/seer/bar_chart.rb
|
42
|
+
- lib/seer/chart.rb
|
43
|
+
- lib/seer/column_chart.rb
|
44
|
+
- lib/seer/gauge.rb
|
45
|
+
- lib/seer/line_chart.rb
|
46
|
+
- lib/seer/pie_chart.rb
|
47
|
+
- spec/seer_spec.rb
|
48
|
+
- spec/spec.opts
|
49
|
+
- spec/spec_helper.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/Bantik/seer
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.3.5
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Seer is a lightweight, semantically rich wrapper for the Google Visualization API.
|
78
|
+
test_files:
|
79
|
+
- spec/area_chart_spec.rb
|
80
|
+
- spec/bar_chart_spec.rb
|
81
|
+
- spec/chart_spec.rb
|
82
|
+
- spec/column_chart_spec.rb
|
83
|
+
- spec/gauge_spec.rb
|
84
|
+
- spec/line_chart_spec.rb
|
85
|
+
- spec/pie_chart_spec.rb
|
86
|
+
- spec/seer_spec.rb
|
87
|
+
- spec/spec_helper.rb
|