ziya 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +74 -28
- data/README.txt +91 -14
- data/Rakefile +1 -1
- data/bin/ziyafy +2 -0
- data/charts/AC_RunActiveContent.js +292 -0
- data/charts/charts.swf +0 -0
- data/charts/charts_library/ar3d.swf +0 -0
- data/charts/charts_library/arno.swf +0 -0
- data/charts/charts_library/ars3.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/buno.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/full_screen.swf +0 -0
- data/charts/sliders/black.swf +0 -0
- data/charts/sliders/preview_handle_1.swf +0 -0
- data/charts/sliders/preview_handle_2.swf +0 -0
- data/fred.rb +36 -0
- data/gauges/designs/circle.yml +18 -0
- data/gauges/designs/signal.yml +14 -0
- data/gauges/designs/thermo.yml +119 -0
- data/gauges/designs/title.yml +11 -0
- data/gauges/gauge.swf +0 -0
- data/lib/ziya.rb +17 -5
- data/lib/ziya/charts/area.rb +6 -1
- data/lib/ziya/charts/area_threed.rb +16 -0
- data/lib/ziya/charts/bar.rb +8 -3
- data/lib/ziya/charts/base.rb +210 -153
- data/lib/ziya/charts/bubble.rb +18 -0
- data/lib/ziya/charts/candle_stick.rb +6 -1
- data/lib/ziya/charts/column.rb +7 -2
- data/lib/ziya/charts/column_threed.rb +6 -1
- data/lib/ziya/charts/floating_bar.rb +6 -1
- data/lib/ziya/charts/floating_column.rb +7 -2
- data/lib/ziya/charts/line.rb +7 -2
- data/lib/ziya/charts/mixed.rb +5 -0
- data/lib/ziya/charts/parallel_threed_column.rb +6 -1
- data/lib/ziya/charts/pie.rb +7 -2
- data/lib/ziya/charts/pie_threed.rb +7 -2
- data/lib/ziya/charts/polar.rb +6 -1
- data/lib/ziya/charts/scatter.rb +6 -1
- data/lib/ziya/charts/stacked_area.rb +5 -0
- data/lib/ziya/charts/stacked_bar.rb +5 -0
- data/lib/ziya/charts/stacked_column.rb +7 -2
- data/lib/ziya/charts/stacked_threed_area.rb +16 -0
- data/lib/ziya/charts/stacked_threed_column.rb +6 -1
- data/lib/ziya/components/area.rb +5 -2
- data/lib/ziya/components/axis_category.rb +8 -60
- data/lib/ziya/components/axis_ticks.rb +25 -27
- data/lib/ziya/components/axis_value.rb +5 -48
- data/lib/ziya/components/base.rb +59 -17
- data/lib/ziya/components/bevel.rb +15 -0
- data/lib/ziya/components/blur.rb +13 -0
- data/lib/ziya/components/chart_border.rb +4 -23
- data/lib/ziya/components/chart_grid_h.rb +17 -19
- data/lib/ziya/components/chart_grid_v.rb +18 -19
- data/lib/ziya/components/chart_guide.rb +16 -0
- data/lib/ziya/components/chart_label.rb +16 -0
- data/lib/ziya/components/chart_pref.rb +12 -12
- data/lib/ziya/components/chart_rect.rb +27 -26
- data/lib/ziya/components/chart_transition.rb +15 -16
- data/lib/ziya/components/circle.rb +5 -2
- data/lib/ziya/components/draw.rb +12 -11
- data/lib/ziya/components/draw_base.rb +10 -0
- data/lib/ziya/components/filter.rb +26 -0
- data/lib/ziya/components/glow.rb +14 -0
- data/lib/ziya/components/image.rb +5 -1
- data/lib/ziya/components/legend.rb +18 -0
- data/lib/ziya/components/line.rb +6 -2
- data/lib/ziya/components/link.rb +9 -9
- data/lib/ziya/components/link_data.rb +9 -10
- data/lib/ziya/components/rect.rb +7 -2
- data/lib/ziya/components/scroll.rb +26 -0
- data/lib/ziya/components/shadow.rb +14 -0
- data/lib/ziya/components/text.rb +5 -1
- data/lib/ziya/components/update.rb +19 -0
- data/lib/ziya/gauges/base.rb +172 -0
- data/lib/ziya/gauges/radial.rb +18 -0
- data/lib/ziya/gauges/signal.rb +138 -0
- data/lib/ziya/gauges/support/area.rb +13 -0
- data/lib/ziya/gauges/support/base.rb +33 -0
- data/lib/ziya/gauges/support/circle.rb +14 -0
- data/lib/ziya/gauges/support/design.rb +5 -0
- data/lib/ziya/gauges/support/image.rb +12 -0
- data/lib/ziya/gauges/support/line.rb +12 -0
- data/lib/ziya/gauges/support/link.rb +24 -0
- data/lib/ziya/gauges/support/move.rb +15 -0
- data/lib/ziya/gauges/support/point.rb +12 -0
- data/lib/ziya/gauges/support/polygon.rb +13 -0
- data/lib/ziya/gauges/support/radial_base.rb +21 -0
- data/lib/ziya/gauges/support/radial_numbers.rb +41 -0
- data/lib/ziya/gauges/support/radial_ticks.rb +29 -0
- data/lib/ziya/gauges/support/rect.rb +14 -0
- data/lib/ziya/gauges/support/rotate.rb +15 -0
- data/lib/ziya/gauges/support/scale.rb +15 -0
- data/lib/ziya/gauges/support/text.rb +21 -0
- data/lib/ziya/gauges/support/update.rb +12 -0
- data/lib/ziya/gauges/thermo.rb +121 -0
- data/lib/ziya/helpers/base_helper.rb +39 -6
- data/lib/ziya/utils/text.rb +6 -0
- data/lib/ziya/version.rb +1 -1
- data/lib/ziya/ziya_helper.rb +289 -62
- data/spec/charts/base_spec.rb +35 -21
- data/spec/charts/chart_type_spec.rb +24 -3
- data/spec/components/area_spec.rb +9 -2
- data/spec/components/draw_spec.rb +1 -2
- data/spec/components/filter_spec.rb +27 -0
- data/spec/components/link_spec.rb +1 -2
- data/spec/components/series_color_spec.rb +1 -2
- data/spec/components/series_explode_spec.rb +1 -2
- data/spec/components/series_switch_spec.rb +1 -2
- data/spec/designs/circle.yml +7 -0
- data/spec/designs/crapping_out.yml +8 -0
- data/spec/designs/gauge_1.yml +43 -0
- data/spec/designs/gauge_2.yml +11 -0
- data/spec/designs/gauge_no_name.yml +43 -0
- data/spec/designs/gauge_raw.yml +5 -0
- data/spec/designs/thermo.yml +13 -0
- data/spec/gauges/base_spec.rb +90 -0
- data/spec/gauges/signal_spec.rb +36 -0
- data/spec/gauges/support/area_spec.rb +40 -0
- data/spec/gauges/support/circle_spec.rb +78 -0
- data/spec/gauges/support/image_spec.rb +35 -0
- data/spec/gauges/support/line_spec.rb +34 -0
- data/spec/gauges/support/link_spec.rb +35 -0
- data/spec/gauges/support/move_spec.rb +45 -0
- data/spec/gauges/support/polygon_spec.rb +36 -0
- data/spec/gauges/support/radial_numbers_spec.rb +35 -0
- data/spec/gauges/support/radial_ticks_spec.rb +30 -0
- data/spec/gauges/support/rotate_spec.rb +45 -0
- data/spec/gauges/support/scale_spec.rb +46 -0
- data/spec/gauges/support/text_spec.rb +40 -0
- data/spec/gauges/thermo_spec.rb +49 -0
- data/spec/helpers/base_helper_spec.rb +20 -6
- data/spec/spec_helper.rb +4 -1
- data/spec/test_helpers/gauge_2_helper.rb +17 -0
- data/spec/utils/logger_spec.rb +1 -3
- data/spec/utils/text_spec.rb +1 -2
- data/spec/ziya_helper_spec.rb +88 -11
- data/spec/ziya_spec.rb +1 -1
- data/tasks/gem.rake +1 -1
- metadata +79 -32
- data/charts/themes/commando/bar_chart.yml +0 -9
- data/charts/themes/commando/base_chart.yml +0 -65
- data/charts/themes/commando/column_chart.yml +0 -13
- data/charts/themes/commando/column_threed_chart.yml +0 -25
- data/charts/themes/commando/parallel_threed_column_chart.yml +0 -17
- data/charts/themes/commando/pie_chart.yml +0 -22
- data/charts/themes/commando/pie_threed_chart.yml +0 -28
- data/charts/themes/commando/polar_chart.yml +0 -11
- data/charts/themes/commando/stacked_bar_chart.yml +0 -9
- data/charts/themes/commando/stacked_column_chart.yml +0 -14
- data/charts/themes/commando/stacked_threed_column_chart.yml +0 -17
- data/charts/themes/default/bar_chart.yml +0 -3
- data/charts/themes/default/base_chart.yml +0 -67
- data/charts/themes/default/column_chart.yml +0 -13
- data/charts/themes/default/column_threed_chart.yml +0 -25
- data/charts/themes/default/parallel_threed_column_chart.yml +0 -17
- data/charts/themes/default/pie_chart.yml +0 -29
- data/charts/themes/default/pie_threed_chart.yml +0 -28
- data/charts/themes/default/polar_chart.yml +0 -12
- data/charts/themes/default/stacked_bar_chart.yml +0 -3
- data/charts/themes/default/stacked_column_chart.yml +0 -14
- data/charts/themes/default/stacked_threed_column_chart.yml +0 -17
- data/charts/themes/default/test.yml +0 -4
- data/lib/ziya/components/chart_value.rb +0 -71
- data/lib/ziya/components/legend_label.rb +0 -18
- data/lib/ziya/components/legend_rect.rb +0 -19
- data/lib/ziya/components/legend_transition.rb +0 -18
- data/lib/ziya/components/live_update.rb +0 -21
data/spec/charts/base_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
3
2
|
|
4
3
|
describe Ziya::Charts::Base do
|
5
4
|
before( :each ) do
|
@@ -19,12 +18,12 @@ describe Ziya::Charts::Base do
|
|
19
18
|
@chart.id.should == "test_id"
|
20
19
|
end
|
21
20
|
end
|
22
|
-
|
21
|
+
|
23
22
|
describe "it should produce the correct xml for a basic chart" do
|
24
23
|
chart = Ziya::Charts::Base.new( "aaa" )
|
25
24
|
chart.add( :axis_category_text, %w[fox dog] )
|
26
25
|
chart.add( :series, "test", [10, 20] )
|
27
|
-
chart.to_xml.should == "
|
26
|
+
chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><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
27
|
end
|
29
28
|
|
30
29
|
describe "#add" do
|
@@ -34,7 +33,7 @@ describe Ziya::Charts::Base do
|
|
34
33
|
|
35
34
|
it "should support setting an axis category" do
|
36
35
|
@chart.add( :axis_category_text, %w[fox cat dog] )
|
37
|
-
@chart.to_xml.should == "
|
36
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>fox</string><string>cat</string><string>dog</string></row></chart_data></chart>"
|
38
37
|
end
|
39
38
|
it "should error if the axis category is not an array" do
|
40
39
|
lambda { @chart.add( :axis_category_text, "") }.should raise_error( ArgumentError, /array of categories/i )
|
@@ -42,35 +41,50 @@ describe Ziya::Charts::Base do
|
|
42
41
|
|
43
42
|
it "should support setting a composite chart urls" do
|
44
43
|
@chart.add( :composites, %w[url1 url2] )
|
45
|
-
@chart.to_xml.should == "
|
44
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart></chart>"
|
46
45
|
end
|
47
46
|
it "should error if the composite url arg is not an array" do
|
48
47
|
lambda { @chart.add( :composites, "") }.should raise_error( ArgumentError, /array of urls/i )
|
49
48
|
end
|
50
49
|
|
51
|
-
it "should support setting the
|
50
|
+
it "should support setting the axis_value label" do
|
51
|
+
@chart.add( :axis_category_text, %w[dog cat] )
|
52
|
+
@chart.add( :axis_value_label, %w[blee duh] )
|
53
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>dog</string><string>cat</string></row></chart_data><axis_value_label><string>blee</string><string>duh</string></axis_value_label></chart>"
|
54
|
+
end
|
55
|
+
it "should error if the axis value label arg is not an array" do
|
56
|
+
lambda { @chart.add( :axis_value_label, "") }.should raise_error( ArgumentError, /array of values/i )
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should support setting the axis category label" do
|
52
60
|
@chart.add( :axis_category_text, %w[dog cat] )
|
53
|
-
@chart.add( :
|
54
|
-
@chart.to_xml.should == "
|
61
|
+
@chart.add( :axis_category_label, %w[blee duh] )
|
62
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>dog</string><string>cat</string></row></chart_data><axis_category_label><string>blee</string><string>duh</string></axis_category_label></chart>"
|
55
63
|
end
|
56
|
-
it "should error if the axis
|
57
|
-
lambda { @chart.add( :
|
64
|
+
it "should error if the axis category label arg is not an array" do
|
65
|
+
lambda { @chart.add( :axis_category_label, "") }.should raise_error( ArgumentError, /array of category/i )
|
58
66
|
end
|
59
67
|
|
60
68
|
it "should support adding series" do
|
61
69
|
@chart.add( :axis_category_text, %w[dog cat] )
|
62
70
|
@chart.add( :series, "test", %w[10 20] )
|
63
|
-
@chart.to_xml.should == "
|
71
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><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
72
|
end
|
65
73
|
|
66
74
|
it "should support adding labels to series" do
|
67
75
|
@chart.add( :axis_category_text, %w[dog cat] )
|
68
|
-
@chart.add( :series, "test", [10,20
|
69
|
-
@chart.to_xml.should == "
|
76
|
+
@chart.add( :series, "test", [ {:value => 10, :label => "label1" }, { :value => 20, :label => "label2" } ] )
|
77
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>dog</string><string>cat</string></row><row><string>test</string><number label=\"label1\">10</number><number label=\"label2\">20</number></row></chart_data></chart>"
|
70
78
|
end
|
71
79
|
|
80
|
+
it "should support adding filters to series" do
|
81
|
+
@chart.add( :axis_category_text, %w[dog cat] )
|
82
|
+
@chart.add( :series, "test", [ {:value => 10, :glow => "glow1" }, { :value => 20, :blur => "blur2" } ] )
|
83
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>dog</string><string>cat</string></row><row><string>test</string><number glow=\"glow1\">10</number><number blur=\"blur2\">20</number></row></chart_data></chart>"
|
84
|
+
end
|
85
|
+
|
72
86
|
it "should error if a series is defined but no axis_category is specified" do
|
73
|
-
@chart.add( :series, "test", [10,20]
|
87
|
+
@chart.add( :series, "test", [10,20] )
|
74
88
|
lambda { @chart.to_xml }.should raise_error( RuntimeError, /axis_category_text/i )
|
75
89
|
end
|
76
90
|
|
@@ -78,7 +92,7 @@ describe Ziya::Charts::Base do
|
|
78
92
|
lambda { @chart.add( :series, nil) }.should raise_error( ArgumentError, /series name/i )
|
79
93
|
end
|
80
94
|
|
81
|
-
it "should error if the series is not an
|
95
|
+
it "should error if the series is not an array" do
|
82
96
|
lambda { @chart.add( :series, "test", nil) }.should raise_error( ArgumentError, /data points/i )
|
83
97
|
end
|
84
98
|
|
@@ -91,23 +105,23 @@ describe Ziya::Charts::Base do
|
|
91
105
|
|
92
106
|
it "should support setting yaml styles directly" do
|
93
107
|
@chart.add( :styles, "--- !ruby/object:Ziya::Charts::Base\n" )
|
94
|
-
@chart.to_xml.should == "
|
108
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart></chart>"
|
95
109
|
end
|
96
110
|
it "should error if no style is specified" do
|
97
111
|
lambda { @chart.add( :styles, "") }.should raise_error( ArgumentError, /set of styles/i )
|
98
112
|
end
|
99
|
-
|
113
|
+
|
100
114
|
it "should support mixed charts" do
|
101
115
|
@chart.add( :chart_types, %w[line bar] )
|
102
|
-
@chart.to_xml.should == "
|
116
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_type><string>line</string><string>bar</string></chart_type></chart>"
|
103
117
|
end
|
104
118
|
it "should error if no chart types are specified" do
|
105
119
|
lambda { @chart.add( :chart_types, "") }.should raise_error( ArgumentError, /set of chart types/i )
|
106
120
|
end
|
107
|
-
|
121
|
+
|
108
122
|
it "should support setting a themes" do
|
109
123
|
@chart.add( :theme, "blee" )
|
110
|
-
@chart.to_xml.should == "
|
124
|
+
@chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart></chart>"
|
111
125
|
end
|
112
126
|
it "should error if no chart types are specified" do
|
113
127
|
lambda { @chart.add( :theme, "") }.should raise_error( ArgumentError, /theme name/i )
|
@@ -1,11 +1,32 @@
|
|
1
|
-
require
|
2
|
-
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
3
2
|
|
4
3
|
describe Ziya::Charts::Base do
|
5
4
|
include Ziya::Utils::Text
|
6
5
|
|
7
6
|
before( :all ) do
|
8
|
-
@types = %w[
|
7
|
+
@types = %w[
|
8
|
+
Area
|
9
|
+
Bar
|
10
|
+
Bubble
|
11
|
+
CandleStick
|
12
|
+
Column
|
13
|
+
ColumnThreed
|
14
|
+
FloatingBar
|
15
|
+
FloatingColumn
|
16
|
+
Line
|
17
|
+
Mixed
|
18
|
+
ParallelThreedColumn
|
19
|
+
Pie
|
20
|
+
PieThreed
|
21
|
+
Polar
|
22
|
+
Scatter
|
23
|
+
StackedArea
|
24
|
+
StackedBar
|
25
|
+
StackedArea
|
26
|
+
StackedBar
|
27
|
+
StackedColumn
|
28
|
+
StackedThreedColumn
|
29
|
+
]
|
9
30
|
end
|
10
31
|
|
11
32
|
describe "#initialize" do
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
# require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
3
2
|
|
4
3
|
describe Ziya::Components::Area do
|
5
4
|
before( :each ) do
|
@@ -14,6 +13,14 @@ describe Ziya::Components::Area do
|
|
14
13
|
@comp.options.should == { :height => 200, :x => 1, :width => 100, :y => 2 }
|
15
14
|
end
|
16
15
|
|
16
|
+
it "should construct an area correctly" do
|
17
|
+
area = Ziya::Components::Area.new( :height => 200, :width => 100, :x => 0, :y => 1 )
|
18
|
+
area.height.should == 200
|
19
|
+
area.width.should == 100
|
20
|
+
area.x.should == 0
|
21
|
+
area.y.should == 1
|
22
|
+
end
|
23
|
+
|
17
24
|
it "should have no options as string" do
|
18
25
|
@comp.options_as_string.should == ":height => '200',:width => '100',:x => '1',:y => '2'"
|
19
26
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
2
|
+
|
3
|
+
describe Ziya::Components::Filter do
|
4
|
+
before( :each ) do
|
5
|
+
@comp = Ziya::Components::Filter.new
|
6
|
+
blur = Ziya::Components::Blur.new
|
7
|
+
blur.blurX = 10
|
8
|
+
glow = Ziya::Components::Glow.new
|
9
|
+
glow.alpha = 50
|
10
|
+
@comp.filters = [blur, glow]
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should define the correct attribute methods" do
|
14
|
+
lambda{ Ziya::Components::Filter.attributes[@comp.class.name].each {
|
15
|
+
|m| @comp.send( m ) } }.should_not raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#flatten" do
|
19
|
+
before( :each ) do
|
20
|
+
@xml = Builder::XmlMarkup.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should flatten component correctly" do
|
24
|
+
@comp.flatten( @xml ).should == "<filter><blur blurX=\"10\"/><glow alpha=\"50\"/></filter>"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%= gauge :base %>
|
2
|
+
<%= dial :circle, :circle_2 %>
|
3
|
+
x: 200
|
4
|
+
y: 75
|
5
|
+
radius: 30
|
6
|
+
start: 0
|
7
|
+
end: 90
|
8
|
+
|
9
|
+
<%= dial :circle, :circle_1 %>
|
10
|
+
x: 200
|
11
|
+
y: 75
|
12
|
+
radius: 30
|
13
|
+
fill_alpha: 0
|
14
|
+
line_thickness: 5
|
15
|
+
|
16
|
+
<%= dial :radial_ticks, :ticks %>
|
17
|
+
x: 200
|
18
|
+
y: 75
|
19
|
+
radius: 27
|
20
|
+
length: 10
|
21
|
+
start_angle: 0
|
22
|
+
end_angle: 90
|
23
|
+
ticks: 10
|
24
|
+
thickness: 2
|
25
|
+
color: 555555
|
26
|
+
|
27
|
+
<%= dial :rotate, :rotation %>
|
28
|
+
x: 200
|
29
|
+
y: 75
|
30
|
+
start: 230
|
31
|
+
span: 160
|
32
|
+
step: 5
|
33
|
+
shadow_alpha: 20
|
34
|
+
shadow_x_offset: 3
|
35
|
+
shadow_y_offset: 3
|
36
|
+
<%= dials %>
|
37
|
+
<%= dial :line, :line %>
|
38
|
+
x1: 200
|
39
|
+
y1: 45
|
40
|
+
x2: 200
|
41
|
+
y2: 52
|
42
|
+
color: ff3300
|
43
|
+
thickness: 4
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%= gauge :base %>
|
2
|
+
<%= dial :circle %>
|
3
|
+
x: 200
|
4
|
+
y: 75
|
5
|
+
radius: 30
|
6
|
+
start: 0
|
7
|
+
end: 90
|
8
|
+
|
9
|
+
<%= dial :circle %>
|
10
|
+
x: 200
|
11
|
+
y: 75
|
12
|
+
radius: 30
|
13
|
+
fill_alpha: 0
|
14
|
+
line_thickness: 5
|
15
|
+
|
16
|
+
<%= dial :radial_ticks %>
|
17
|
+
x: 200
|
18
|
+
y: 75
|
19
|
+
radius: 27
|
20
|
+
length: 10
|
21
|
+
start_angle: 0
|
22
|
+
end_angle: 90
|
23
|
+
ticks: 10
|
24
|
+
thickness: 2
|
25
|
+
color: 555555
|
26
|
+
|
27
|
+
<%= dial :rotate %>
|
28
|
+
x: 200
|
29
|
+
y: 75
|
30
|
+
start: 230
|
31
|
+
span: 160
|
32
|
+
step: 5
|
33
|
+
shadow_alpha: 20
|
34
|
+
shadow_x_offset: 3
|
35
|
+
shadow_y_offset: 3
|
36
|
+
<%= dials %>
|
37
|
+
<%= dial :line %>
|
38
|
+
x1: 200
|
39
|
+
y1: 45
|
40
|
+
x2: 200
|
41
|
+
y2: 52
|
42
|
+
color: ff3300
|
43
|
+
thickness: 4
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Thermometer design ( Override )
|
3
|
+
# -----------------------------------------------------------------------------
|
4
|
+
<%= gauge :thermo %>
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Thermo tube
|
7
|
+
<%= dial :rect, :thermo_tube %>
|
8
|
+
x: 999
|
9
|
+
y: 999
|
10
|
+
height: 150
|
11
|
+
width: 40
|
12
|
+
fill_color: 880000
|
13
|
+
line_thickness: 8
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
|
2
|
+
|
3
|
+
describe Ziya::Gauges::Base do
|
4
|
+
describe "#initialize" do
|
5
|
+
before( :each ) do
|
6
|
+
@gauge = Ziya::Gauges::Base.new( "test_license", "test" )
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should create a gauge with the correct license" do
|
10
|
+
@gauge.license.should == "test_license"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create a gauge with the correct id" do
|
14
|
+
@gauge.design_id.should == "test"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_xml" do
|
19
|
+
it "should produce the correct xml for a basic gauge" do
|
20
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "gauge_1" )
|
21
|
+
buff = gauge.to_xml
|
22
|
+
buff.scan( /<license/ ).size.should == 1
|
23
|
+
buff.scan( /<circle/ ).size.should == 2
|
24
|
+
buff.scan( /<line/ ).size.should == 11
|
25
|
+
buff.scan( /x1=\"(.*?\d+)\"/ ).should == [["200"], ["204"], ["209"], ["213"], ["217"], ["220"], ["223"], ["225"], ["226"], ["227"], ["200"]]
|
26
|
+
buff.scan( /y1=\"(.*?\d+)\"/ ).should == [["48"], ["48"], ["49"], ["51"], ["54"], ["57"], ["61"], ["65"], ["70"], ["75"], ["45"]]
|
27
|
+
buff.scan( /x2=\"(.*?\d+)\"/ ).should == [["200"], ["206"], ["212"], ["218"], ["223"], ["228"], ["232"], ["234"], ["236"], ["237"], ["200"]]
|
28
|
+
buff.scan( /y2=\"(.*?\d+)\"/ ).should == [["38"], ["38"], ["40"], ["42"], ["46"], ["51"], ["56"], ["62"], ["68"], ["75"], ["52"]]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should produce the correct xml for a gauge with no design override" do
|
32
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "title" )
|
33
|
+
buff = gauge.to_xml
|
34
|
+
buff.scan( /<license/ ).size.should == 1
|
35
|
+
buff.scan( /<text/ ).size.should == 1
|
36
|
+
buff.scan( /x=\"(.*?\d+)\"/ ).should == [["-15"]]
|
37
|
+
buff.scan( /y=\"(.*?\d+)\"/ ).should == [["300"]]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should produce the correct xml for a gauge with design override" do
|
41
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "circle" )
|
42
|
+
buff = gauge.to_xml
|
43
|
+
buff.scan( /<license/ ).size.should == 1
|
44
|
+
buff.scan( /<text/ ).size.should == 1
|
45
|
+
buff.scan( /<circle/ ).size.should == 1
|
46
|
+
buff.scan( /x=\"(.*?\d+)\"/ ).should == [["999"],["-15"]]
|
47
|
+
buff.scan( /y=\"(.*?\d+)\"/ ).should == [["999"], ["300"]]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should throw an exception when yaml is hosed" do
|
51
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "crapping_out" )
|
52
|
+
lambda { gauge.to_xml }.should raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "helpers" do
|
57
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "gauge_2" )
|
58
|
+
buff = gauge.to_xml
|
59
|
+
buff.scan( /<license/ ).size.should == 1
|
60
|
+
buff.scan( /<circle/ ).size.should == 2
|
61
|
+
buff.scan( /x=\"(.*?\d+)\"/ ).should == [ ["200"], ["10"] ]
|
62
|
+
buff.scan( /y=\"(.*?\d+)\"/ ).should == [ ["75"], ["10"] ]
|
63
|
+
buff.scan( /start=\"(.*?\d+)\"/ ).should == [ ["0"] ]
|
64
|
+
buff.scan( /end=\"(.*?\d+)\"/ ).should == [ ["360"] ]
|
65
|
+
buff.scan( /fill_color=\"(\w{6})\"/ ).should == [ ["ff00ff"], ["ff0000"] ]
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "helpers" do
|
69
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "gauge_2" )
|
70
|
+
buff = gauge.to_xml
|
71
|
+
buff.scan( /<license/ ).size.should == 1
|
72
|
+
buff.scan( /<circle/ ).size.should == 2
|
73
|
+
buff.scan( /x=\"(.*?\d+)\"/ ).should == [ ["200"], ["10"] ]
|
74
|
+
buff.scan( /y=\"(.*?\d+)\"/ ).should == [ ["75"], ["10"] ]
|
75
|
+
buff.scan( /start=\"(.*?\d+)\"/ ).should == [ ["0"] ]
|
76
|
+
buff.scan( /end=\"(.*?\d+)\"/ ).should == [ ["360"] ]
|
77
|
+
buff.scan( /fill_color=\"(\w{6})\"/ ).should == [ ["ff00ff"], ["ff0000"] ]
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "refresh" do
|
81
|
+
gauge = Ziya::Gauges::Base.new( "aaa", "gauge_1" )
|
82
|
+
gauge.set_preferences( :url => "/blee/fred" )
|
83
|
+
buff = gauge.to_xml
|
84
|
+
buff.scan( /<license/ ).size.should == 1
|
85
|
+
buff.scan( /<update/ ).size.should == 1
|
86
|
+
buff.scan( /url=\"(\/\w+\/\w+)\"/ ).should == [ ["/blee/fred"] ]
|
87
|
+
buff.scan( /delay=\"(.*?\d+)\"/ ).should == [ ["30"] ]
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|