ziya 1.0.0
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/History.txt +4 -0
- data/Manifest.txt +127 -0
- data/README.txt +137 -0
- data/Rakefile +45 -0
- data/bin/ziyafy +51 -0
- data/charts/charts.swf +0 -0
- data/charts/charts_library/arno.swf +0 -0
- data/charts/charts_library/arst.swf +0 -0
- data/charts/charts_library/brfl.swf +0 -0
- data/charts/charts_library/brno.swf +0 -0
- data/charts/charts_library/brst.swf +0 -0
- data/charts/charts_library/cl3d.swf +0 -0
- data/charts/charts_library/clfl.swf +0 -0
- data/charts/charts_library/clno.swf +0 -0
- data/charts/charts_library/clp3.swf +0 -0
- data/charts/charts_library/cls3.swf +0 -0
- data/charts/charts_library/clst.swf +0 -0
- data/charts/charts_library/cnno.swf +0 -0
- data/charts/charts_library/lnno.swf +0 -0
- data/charts/charts_library/mxno.swf +0 -0
- data/charts/charts_library/pi3d.swf +0 -0
- data/charts/charts_library/pino.swf +0 -0
- data/charts/charts_library/pono.swf +0 -0
- data/charts/charts_library/scno.swf +0 -0
- data/charts/themes/commando/bar_chart.yml +9 -0
- data/charts/themes/commando/base_chart.yml +65 -0
- data/charts/themes/commando/column_chart.yml +13 -0
- data/charts/themes/commando/column_threed_chart.yml +25 -0
- data/charts/themes/commando/parallel_threed_column_chart.yml +17 -0
- data/charts/themes/commando/pie_chart.yml +22 -0
- data/charts/themes/commando/pie_threed_chart.yml +28 -0
- data/charts/themes/commando/polar_chart.yml +11 -0
- data/charts/themes/commando/stacked_bar_chart.yml +9 -0
- data/charts/themes/commando/stacked_column_chart.yml +14 -0
- data/charts/themes/commando/stacked_threed_column_chart.yml +17 -0
- data/charts/themes/default/bar_chart.yml +3 -0
- data/charts/themes/default/base_chart.yml +67 -0
- data/charts/themes/default/column_chart.yml +13 -0
- data/charts/themes/default/column_threed_chart.yml +25 -0
- data/charts/themes/default/parallel_threed_column_chart.yml +17 -0
- data/charts/themes/default/pie_chart.yml +29 -0
- data/charts/themes/default/pie_threed_chart.yml +28 -0
- data/charts/themes/default/polar_chart.yml +12 -0
- data/charts/themes/default/stacked_bar_chart.yml +3 -0
- data/charts/themes/default/stacked_column_chart.yml +14 -0
- data/charts/themes/default/stacked_threed_column_chart.yml +17 -0
- data/charts/themes/default/test.yml +4 -0
- data/lib/ziya.rb +100 -0
- data/lib/ziya/charts/area.rb +13 -0
- data/lib/ziya/charts/bar.rb +11 -0
- data/lib/ziya/charts/base.rb +435 -0
- data/lib/ziya/charts/candle_stick.rb +11 -0
- data/lib/ziya/charts/column.rb +11 -0
- data/lib/ziya/charts/column_threed.rb +11 -0
- data/lib/ziya/charts/floating_bar.rb +11 -0
- data/lib/ziya/charts/floating_column.rb +11 -0
- data/lib/ziya/charts/line.rb +11 -0
- data/lib/ziya/charts/mixed.rb +11 -0
- data/lib/ziya/charts/parallel_threed_column.rb +11 -0
- data/lib/ziya/charts/pie.rb +11 -0
- data/lib/ziya/charts/pie_threed.rb +11 -0
- data/lib/ziya/charts/polar.rb +11 -0
- data/lib/ziya/charts/scatter.rb +11 -0
- data/lib/ziya/charts/stacked_area.rb +11 -0
- data/lib/ziya/charts/stacked_bar.rb +11 -0
- data/lib/ziya/charts/stacked_column.rb +11 -0
- data/lib/ziya/charts/stacked_threed_column.rb +11 -0
- data/lib/ziya/components/area.rb +14 -0
- data/lib/ziya/components/axis_category.rb +69 -0
- data/lib/ziya/components/axis_ticks.rb +37 -0
- data/lib/ziya/components/axis_value.rb +59 -0
- data/lib/ziya/components/base.rb +100 -0
- data/lib/ziya/components/chart_border.rb +33 -0
- data/lib/ziya/components/chart_grid_h.rb +28 -0
- data/lib/ziya/components/chart_grid_v.rb +28 -0
- data/lib/ziya/components/chart_pref.rb +22 -0
- data/lib/ziya/components/chart_rect.rb +36 -0
- data/lib/ziya/components/chart_transition.rb +26 -0
- data/lib/ziya/components/chart_value.rb +71 -0
- data/lib/ziya/components/circle.rb +13 -0
- data/lib/ziya/components/draw.rb +45 -0
- data/lib/ziya/components/image.rb +13 -0
- data/lib/ziya/components/legend_label.rb +18 -0
- data/lib/ziya/components/legend_rect.rb +19 -0
- data/lib/ziya/components/legend_transition.rb +18 -0
- data/lib/ziya/components/line.rb +12 -0
- data/lib/ziya/components/link.rb +29 -0
- data/lib/ziya/components/link_data.rb +19 -0
- data/lib/ziya/components/live_update.rb +21 -0
- data/lib/ziya/components/rect.rb +13 -0
- data/lib/ziya/components/series_color.rb +35 -0
- data/lib/ziya/components/series_explode.rb +38 -0
- data/lib/ziya/components/series_gap.rb +18 -0
- data/lib/ziya/components/series_switch.rb +25 -0
- data/lib/ziya/components/text.rb +13 -0
- data/lib/ziya/helpers/base_helper.rb +37 -0
- data/lib/ziya/utils/logger.rb +125 -0
- data/lib/ziya/utils/text.rb +33 -0
- data/lib/ziya/version.rb +15 -0
- data/lib/ziya/ziya_helper.rb +147 -0
- data/spec/charts/base_spec.rb +120 -0
- data/spec/charts/chart_type_spec.rb +42 -0
- data/spec/components/area_spec.rb +60 -0
- data/spec/components/draw_spec.rb +33 -0
- data/spec/components/link_spec.rb +23 -0
- data/spec/components/series_color_spec.rb +40 -0
- data/spec/components/series_explode_spec.rb +40 -0
- data/spec/components/series_switch_spec.rb +19 -0
- data/spec/helpers/base_helper_spec.rb +22 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/themes/default/fred.yml +6 -0
- data/spec/themes/default/line_chart.yml +6 -0
- data/spec/utils/logger_spec.rb +57 -0
- data/spec/utils/text_spec.rb +34 -0
- data/spec/ziya_helper_spec.rb +40 -0
- data/spec/ziya_spec.rb +19 -0
- data/tasks/ann.rake +76 -0
- data/tasks/annotations.rake +22 -0
- data/tasks/doc.rake +48 -0
- data/tasks/gem.rake +110 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/post_load.rake +26 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +227 -0
- data/tasks/spec.rake +61 -0
- data/tasks/svn.rake +44 -0
- data/tasks/test.rake +38 -0
- metadata +190 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Charts::Base do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@chart = Ziya::Charts::Base.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#initialize" do
|
|
10
|
+
before( :each ) do
|
|
11
|
+
@chart = Ziya::Charts::Base.new( "test_license", "test_id" )
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should create a chart with the correct license" do
|
|
15
|
+
@chart.license.should == "test_license"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should create a chart with the correct id" do
|
|
19
|
+
@chart.id.should == "test_id"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "it should produce the correct xml for a basic chart" do
|
|
24
|
+
chart = Ziya::Charts::Base.new( "aaa" )
|
|
25
|
+
chart.add( :axis_category_text, %w[fox dog] )
|
|
26
|
+
chart.add( :series, "test", [10, 20] )
|
|
27
|
+
chart.to_xml.should == "<chart><license>aaa</license><chart_data><row><null/><string>fox</string><string>dog</string></row><row><string>test</string><number>10</number><number>20</number></row></chart_data></chart>"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#add" do
|
|
31
|
+
before( :each ) do
|
|
32
|
+
@chart = Ziya::Charts::Base.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should support setting an axis category" do
|
|
36
|
+
@chart.add( :axis_category_text, %w[fox cat dog] )
|
|
37
|
+
@chart.to_xml.should == "<chart><chart_data><row><null/><string>fox</string><string>cat</string><string>dog</string></row></chart_data></chart>"
|
|
38
|
+
end
|
|
39
|
+
it "should error if the axis category is not an array" do
|
|
40
|
+
lambda { @chart.add( :axis_category_text, "") }.should raise_error( ArgumentError, /array of categories/i )
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should support setting a composite chart urls" do
|
|
44
|
+
@chart.add( :composites, %w[url1 url2] )
|
|
45
|
+
@chart.to_xml.should == "<chart></chart>"
|
|
46
|
+
end
|
|
47
|
+
it "should error if the composite url arg is not an array" do
|
|
48
|
+
lambda { @chart.add( :composites, "") }.should raise_error( ArgumentError, /array of urls/i )
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should support setting the axis value text" do
|
|
52
|
+
@chart.add( :axis_category_text, %w[dog cat] )
|
|
53
|
+
@chart.add( :axis_value_text, %w[blee duh] )
|
|
54
|
+
@chart.to_xml.should == "<chart><axis_value_text><string>blee</string><string>duh</string></axis_value_text><chart_data><row><null/><string>dog</string><string>cat</string></row></chart_data></chart>"
|
|
55
|
+
end
|
|
56
|
+
it "should error if the axis value text arg is not an array" do
|
|
57
|
+
lambda { @chart.add( :axis_value_text, "") }.should raise_error( ArgumentError, /array of values/i )
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should support adding series" do
|
|
61
|
+
@chart.add( :axis_category_text, %w[dog cat] )
|
|
62
|
+
@chart.add( :series, "test", %w[10 20] )
|
|
63
|
+
@chart.to_xml.should == "<chart><chart_data><row><null/><string>dog</string><string>cat</string></row><row><string>test</string><string>10</string><string>20</string></row></chart_data></chart>"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should support adding labels to series" do
|
|
67
|
+
@chart.add( :axis_category_text, %w[dog cat] )
|
|
68
|
+
@chart.add( :series, "test", [10,20], %w[label1 label2] )
|
|
69
|
+
@chart.to_xml.should == "<chart><chart_data><row><null/><string>dog</string><string>cat</string></row><row><string>test</string><number>10</number><number>20</number></row></chart_data><chart_value_text><row><null/></row><row><null/><string>label1</string><string>label2</string></row></chart_value_text></chart>"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should error if a series is defined but no axis_category is specified" do
|
|
73
|
+
@chart.add( :series, "test", [10,20], %w[label1 label2] )
|
|
74
|
+
lambda { @chart.to_xml }.should raise_error( RuntimeError, /axis_category_text/i )
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should error if the series has no name" do
|
|
78
|
+
lambda { @chart.add( :series, nil) }.should raise_error( ArgumentError, /series name/i )
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should error if the series is not an arry" do
|
|
82
|
+
lambda { @chart.add( :series, "test", nil) }.should raise_error( ArgumentError, /data points/i )
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should error if the user data has no key" do
|
|
86
|
+
lambda { @chart.add( :user_data, nil) }.should raise_error( ArgumentError, /specify a key/i )
|
|
87
|
+
end
|
|
88
|
+
it "should error if the user data has no key" do
|
|
89
|
+
lambda { @chart.add( :user_data, :fred, "blee") }.should_not raise_error( ArgumentError, /specify a key/i )
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should support setting yaml styles directly" do
|
|
93
|
+
@chart.add( :styles, "--- !ruby/object:Ziya::Charts::Base\n" )
|
|
94
|
+
@chart.to_xml.should == "<chart></chart>"
|
|
95
|
+
end
|
|
96
|
+
it "should error if no style is specified" do
|
|
97
|
+
lambda { @chart.add( :styles, "") }.should raise_error( ArgumentError, /set of styles/i )
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should support mixed charts" do
|
|
101
|
+
@chart.add( :chart_types, %w[line bar] )
|
|
102
|
+
@chart.to_xml.should == "<chart><chart_type><string>line</string><string>bar</string></chart_type></chart>"
|
|
103
|
+
end
|
|
104
|
+
it "should error if no chart types are specified" do
|
|
105
|
+
lambda { @chart.add( :chart_types, "") }.should raise_error( ArgumentError, /set of chart types/i )
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should support setting a themes" do
|
|
109
|
+
@chart.add( :theme, "blee" )
|
|
110
|
+
@chart.to_xml.should == "<chart></chart>"
|
|
111
|
+
end
|
|
112
|
+
it "should error if no chart types are specified" do
|
|
113
|
+
lambda { @chart.add( :theme, "") }.should raise_error( ArgumentError, /theme name/i )
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "should error if an invalid option is specified" do
|
|
117
|
+
lambda { @chart.add( :fred, "") }.should raise_error( ArgumentError, /invalid directive/i )
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "spec/spec_helper"
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Charts::Base do
|
|
5
|
+
include Ziya::Utils::Text
|
|
6
|
+
|
|
7
|
+
before( :all ) do
|
|
8
|
+
@types = %w[Area Bar CandleStick Column ColumnThreed FloatingBar FloatingColumn Line Mixed ParallelThreedColumn Pie PieThreed Polar Scatter StackedArea StackedBar StackedArea StackedBar StackedColumn StackedThreedColumn]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "#initialize" do
|
|
12
|
+
it "should create a set of charts correctly" do
|
|
13
|
+
@types.each do |type|
|
|
14
|
+
chart = Ziya::Charts.const_get( classify(type) ).new
|
|
15
|
+
if type.index( /Threed/ )
|
|
16
|
+
match = type.match( /(.*)Threed(.*)/ )
|
|
17
|
+
if match[2] and !match[2].empty?
|
|
18
|
+
chart.type.gsub(/ /, '' ).should == match[1].downcase + "3d" + match[2].downcase
|
|
19
|
+
else
|
|
20
|
+
chart.type.gsub(/ /, '' ).should == "3d" + match[1].downcase
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
chart.type.gsub(/ /, '' ).should == type.downcase unless type == "Mixed"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should produce the correct xml for a line chart with styles" do
|
|
29
|
+
chart = Ziya::Charts::Line.new( "aaa" )
|
|
30
|
+
chart.add( :axis_category_text, %w[fox dog] )
|
|
31
|
+
chart.add( :series, "test", [10, 20], %w[label1 label2] )
|
|
32
|
+
chart.to_xml.index( "color=\"0\"" ).should_not be_nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should overide styles for a line chart with an id defined" do
|
|
36
|
+
chart = Ziya::Charts::Line.new( "aaa", "fred" )
|
|
37
|
+
chart.add( :axis_category_text, %w[fox dog] )
|
|
38
|
+
chart.add( :series, "test", [10, 20], %w[label1 label2] )
|
|
39
|
+
chart.to_xml.index( "color=\"ffffff\"" ).should_not be_nil
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Components::Area do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@comp = Ziya::Components::Area.new
|
|
7
|
+
@comp.x = 1
|
|
8
|
+
@comp.y = 2
|
|
9
|
+
@comp.width = 100
|
|
10
|
+
@comp.height = 200
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should have some options" do
|
|
14
|
+
@comp.options.should == { :height => 200, :x => 1, :width => 100, :y => 2 }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should have no options as string" do
|
|
18
|
+
@comp.options_as_string.should == ":height => '200',:width => '100',:x => '1',:y => '2'"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should define the correct attribute methods" do
|
|
22
|
+
lambda{ Ziya::Components::Area.attributes[@comp.class.name].each {
|
|
23
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should check that a component is not empty correctly" do
|
|
27
|
+
@comp.should be_configured
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should check that no properties are set correctly" do
|
|
31
|
+
@comp = Ziya::Components::Area.new
|
|
32
|
+
@comp.should_not be_configured
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should merge attributes correctly" do
|
|
36
|
+
parent = Ziya::Components::Area.new
|
|
37
|
+
parent.x = 20
|
|
38
|
+
parent.y = 50
|
|
39
|
+
@comp.merge( parent, false )
|
|
40
|
+
parent.options_as_string.should == ":x => '20',:y => '50'"
|
|
41
|
+
@comp.options_as_string.should == ":height => '200',:width => '100',:x => '20',:y => '50'"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "#flatten" do
|
|
45
|
+
it "should flatten component correctly" do
|
|
46
|
+
xml = Builder::XmlMarkup.new
|
|
47
|
+
# BOZO !! Doh !! that would have been nice but the attrs order is unspecified in builder...
|
|
48
|
+
# @comp.flatten( xml ).should == "<area width=\"100\" x=\"1\" y=\"2\" height=\"200\"/>"
|
|
49
|
+
@comp.flatten( xml ).size.should == 44
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should flatten simple component correctly" do
|
|
53
|
+
xml = Builder::XmlMarkup.new
|
|
54
|
+
comp = Ziya::Components::Area.new
|
|
55
|
+
comp.x = 10
|
|
56
|
+
comp.flatten( xml ).should == "<area x=\"10\"/>"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Components::Draw do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@comp = Ziya::Components::Draw.new
|
|
7
|
+
circle = Ziya::Components::Circle.new
|
|
8
|
+
circle.radius = 10
|
|
9
|
+
image = Ziya::Components::Image.new
|
|
10
|
+
image.x = 10
|
|
11
|
+
@comp.components = [circle, image]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should define the correct attribute methods" do
|
|
15
|
+
lambda{ Ziya::Components::Draw.attributes[@comp.class.name].each {
|
|
16
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#flatten" do
|
|
20
|
+
before( :each ) do
|
|
21
|
+
@xml = Builder::XmlMarkup.new
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should flatten component correctly" do
|
|
25
|
+
@comp.flatten( @xml ).should == "<draw><circle radius=\"10\"/><image x=\"10\"/></draw>"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should support composite charts" do
|
|
29
|
+
urls = [ "/fred", "/blee" ]
|
|
30
|
+
@comp.flatten( @xml, urls ).should == "<draw><circle radius=\"10\"/><image x=\"10\"/><image url=\"/charts/charts.swf?library_path=/charts/charts_library&xml_source=/fred\"/><image url=\"/charts/charts.swf?library_path=/charts/charts_library&xml_source=/blee\"/></draw>"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Components::Link do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@comp = Ziya::Components::Link.new
|
|
7
|
+
area1 = Ziya::Components::Area.new
|
|
8
|
+
area1.x = 10
|
|
9
|
+
area2 = Ziya::Components::Area.new
|
|
10
|
+
area2.x = 20
|
|
11
|
+
@comp.areas = [area1, area2]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should define the correct attribute methods" do
|
|
15
|
+
lambda{ Ziya::Components::Link.attributes[@comp.class.name].each {
|
|
16
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should flatten component correctly" do
|
|
20
|
+
xml = Builder::XmlMarkup.new
|
|
21
|
+
@comp.flatten( xml ).should == "<link><area x=\"10\"/><area x=\"20\"/></link>"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Components::SeriesColor do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@comp = Ziya::Components::SeriesColor.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should define the correct attribute methods" do
|
|
10
|
+
lambda{ Ziya::Components::SeriesColor.attributes[@comp.class.name].each {
|
|
11
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#flatten" do
|
|
15
|
+
before( :each ) do
|
|
16
|
+
@xml = Builder::XmlMarkup.new
|
|
17
|
+
@results = "<series_color><color>10</color><color>20</color><color>30</color></series_color>"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should flatten string explode version correctly" do
|
|
21
|
+
@comp.colors = "10,20,30"
|
|
22
|
+
@comp.flatten( @xml ).should == @results
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should flatten string numbers with spaces explode version correctly" do
|
|
26
|
+
@comp.colors = "10 , 20 , 30"
|
|
27
|
+
@comp.flatten( @xml ).should == @results
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should flatten single string explode version correctly" do
|
|
31
|
+
@comp.colors = 10
|
|
32
|
+
@comp.flatten( @xml ).should == "<series_color><color>10</color></series_color>"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should flatten array explode version correctly" do
|
|
36
|
+
@comp.colors = %w[10 20 30]
|
|
37
|
+
@comp.flatten( @xml ).should == @results
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Components::SeriesExplode do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@comp = Ziya::Components::SeriesExplode.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should define the correct attribute methods" do
|
|
10
|
+
lambda{ Ziya::Components::SeriesExplode.attributes[@comp.class.name].each {
|
|
11
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#flatten" do
|
|
15
|
+
before( :each ) do
|
|
16
|
+
@xml = Builder::XmlMarkup.new
|
|
17
|
+
@results = "<series_explode><number>10</number><number>20</number><number>30</number></series_explode>"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should flatten string explode version correctly" do
|
|
21
|
+
@comp.numbers = "10,20,30"
|
|
22
|
+
@comp.flatten( @xml ).should == @results
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should flatten string numbers with spaces explode version correctly" do
|
|
26
|
+
@comp.numbers = "10 , 20 , 30"
|
|
27
|
+
@comp.flatten( @xml ).should == @results
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should flatten single string explode version correctly" do
|
|
31
|
+
@comp.numbers = 10
|
|
32
|
+
@comp.flatten( @xml ).should == "<series_explode><number>10</number></series_explode>"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should flatten array explode version correctly" do
|
|
36
|
+
@comp.numbers = %w[10 20 30]
|
|
37
|
+
@comp.flatten( @xml ).should == @results
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Components::SeriesSwitch do
|
|
5
|
+
before( :each ) do
|
|
6
|
+
@comp = Ziya::Components::SeriesSwitch.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should define the correct attribute methods" do
|
|
10
|
+
lambda{ Ziya::Components::SeriesSwitch.attributes[@comp.class.name].each {
|
|
11
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should flatten component correctly" do
|
|
15
|
+
xml = Builder::XmlMarkup.new
|
|
16
|
+
@comp.switch = false
|
|
17
|
+
@comp.flatten( xml ).should == "<series_switch>false</series_switch>"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
3
|
+
|
|
4
|
+
describe Ziya::Helpers::BaseHelper do
|
|
5
|
+
|
|
6
|
+
it "should generate the correct yaml class name" do
|
|
7
|
+
component( "fred" ).should == "fred: !ruby/object:Ziya::Components::Fred\n"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should generate the correct yaml clqss name for alias" do
|
|
11
|
+
comp( "fred" ).should == "fred: !ruby/object:Ziya::Components::Fred\n"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should generate the correct yaml drawing class name" do
|
|
15
|
+
drawing( "fred" ).should == "!ruby/object:Ziya::Components::Fred\n"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should generate the correct yaml chart class name" do
|
|
19
|
+
chart( "fred" ).should == "--- !ruby/object:Ziya::Charts::Fred\n"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
# require File.join(File.dirname(__FILE__), %w[.. spec_helper] )
|
|
3
|
+
|
|
4
|
+
require 'stringio'
|
|
5
|
+
require "ziya/utils/logger"
|
|
6
|
+
|
|
7
|
+
describe Ziya::Logger do
|
|
8
|
+
it "raises an error if the email addresses passed in is empty" do
|
|
9
|
+
lambda { Ziya::Logger.new( { :email_alerts_to => [] } ) }.should raise_error( Ziya::Logger::ConfigurationError )
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "configures an email appender if :email_alerts is set" do
|
|
13
|
+
l = Ziya::Logger.new( { :logger_name => "Test2", :email_alerts_to => "fernand@invalid.address", :email_alert_level => :off })
|
|
14
|
+
l.email_appender.should_not == nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "does not configure an email appender if :email_alerts is not set" do
|
|
18
|
+
l = Ziya::Logger.new( { :logger_name => "Test3" })
|
|
19
|
+
lambda { l.email_appender }.should raise_error( Ziya::Logger::ConfigurationError )
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "raises an error if an invalid object is passed in for the :log_file" do
|
|
23
|
+
lambda { l = Ziya::Logger.new( { :log_file => Object.new } ) }.should raise_error( Ziya::Logger::ConfigurationError )
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "logs to an IO stream if given" do
|
|
27
|
+
io = StringIO.new
|
|
28
|
+
l = Ziya::Logger.new( { :log_file => io, :logger_name => "Test4" })
|
|
29
|
+
l.info "This is a test io message"
|
|
30
|
+
io.string.split("\n").should have(1).item
|
|
31
|
+
io.string.should =~ /This is a test io message/
|
|
32
|
+
io.string.should =~ /INFO/
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "logs to a file if given a file name to log to" do
|
|
36
|
+
log_file = "/tmp/Ziya_logger_test.log"
|
|
37
|
+
FileUtils.rm( log_file ) if File.exists?( log_file )
|
|
38
|
+
l = Ziya::Logger.new({ :log_file => log_file, :logger_name => "Test5" })
|
|
39
|
+
l.info "This is a test log file message"
|
|
40
|
+
|
|
41
|
+
log_lines = IO.readlines(log_file)
|
|
42
|
+
|
|
43
|
+
log_lines.should have(1).items
|
|
44
|
+
log_lines.first.should =~ /This is a test log file message/
|
|
45
|
+
log_lines.first.should =~ /INFO/
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "creates a logger from another logger" do
|
|
49
|
+
io = StringIO.new
|
|
50
|
+
l = Ziya::Logger.new( { :log_file => io, :logger_name => ::Ziya})
|
|
51
|
+
child_l = l.for(Ziya)
|
|
52
|
+
|
|
53
|
+
child_l.info "This is a child log message"
|
|
54
|
+
io.string.should =~ /This is a child log message/
|
|
55
|
+
io.string.should =~ /INFO/
|
|
56
|
+
end
|
|
57
|
+
end
|