ziya 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/Manifest.txt +74 -28
  2. data/README.txt +91 -14
  3. data/Rakefile +1 -1
  4. data/bin/ziyafy +2 -0
  5. data/charts/AC_RunActiveContent.js +292 -0
  6. data/charts/charts.swf +0 -0
  7. data/charts/charts_library/ar3d.swf +0 -0
  8. data/charts/charts_library/arno.swf +0 -0
  9. data/charts/charts_library/ars3.swf +0 -0
  10. data/charts/charts_library/arst.swf +0 -0
  11. data/charts/charts_library/brfl.swf +0 -0
  12. data/charts/charts_library/brno.swf +0 -0
  13. data/charts/charts_library/brst.swf +0 -0
  14. data/charts/charts_library/buno.swf +0 -0
  15. data/charts/charts_library/cl3d.swf +0 -0
  16. data/charts/charts_library/clfl.swf +0 -0
  17. data/charts/charts_library/clno.swf +0 -0
  18. data/charts/charts_library/clp3.swf +0 -0
  19. data/charts/charts_library/cls3.swf +0 -0
  20. data/charts/charts_library/clst.swf +0 -0
  21. data/charts/charts_library/cnno.swf +0 -0
  22. data/charts/charts_library/lnno.swf +0 -0
  23. data/charts/charts_library/mxno.swf +0 -0
  24. data/charts/charts_library/pi3d.swf +0 -0
  25. data/charts/charts_library/pino.swf +0 -0
  26. data/charts/charts_library/pono.swf +0 -0
  27. data/charts/charts_library/scno.swf +0 -0
  28. data/charts/full_screen.swf +0 -0
  29. data/charts/sliders/black.swf +0 -0
  30. data/charts/sliders/preview_handle_1.swf +0 -0
  31. data/charts/sliders/preview_handle_2.swf +0 -0
  32. data/fred.rb +36 -0
  33. data/gauges/designs/circle.yml +18 -0
  34. data/gauges/designs/signal.yml +14 -0
  35. data/gauges/designs/thermo.yml +119 -0
  36. data/gauges/designs/title.yml +11 -0
  37. data/gauges/gauge.swf +0 -0
  38. data/lib/ziya.rb +17 -5
  39. data/lib/ziya/charts/area.rb +6 -1
  40. data/lib/ziya/charts/area_threed.rb +16 -0
  41. data/lib/ziya/charts/bar.rb +8 -3
  42. data/lib/ziya/charts/base.rb +210 -153
  43. data/lib/ziya/charts/bubble.rb +18 -0
  44. data/lib/ziya/charts/candle_stick.rb +6 -1
  45. data/lib/ziya/charts/column.rb +7 -2
  46. data/lib/ziya/charts/column_threed.rb +6 -1
  47. data/lib/ziya/charts/floating_bar.rb +6 -1
  48. data/lib/ziya/charts/floating_column.rb +7 -2
  49. data/lib/ziya/charts/line.rb +7 -2
  50. data/lib/ziya/charts/mixed.rb +5 -0
  51. data/lib/ziya/charts/parallel_threed_column.rb +6 -1
  52. data/lib/ziya/charts/pie.rb +7 -2
  53. data/lib/ziya/charts/pie_threed.rb +7 -2
  54. data/lib/ziya/charts/polar.rb +6 -1
  55. data/lib/ziya/charts/scatter.rb +6 -1
  56. data/lib/ziya/charts/stacked_area.rb +5 -0
  57. data/lib/ziya/charts/stacked_bar.rb +5 -0
  58. data/lib/ziya/charts/stacked_column.rb +7 -2
  59. data/lib/ziya/charts/stacked_threed_area.rb +16 -0
  60. data/lib/ziya/charts/stacked_threed_column.rb +6 -1
  61. data/lib/ziya/components/area.rb +5 -2
  62. data/lib/ziya/components/axis_category.rb +8 -60
  63. data/lib/ziya/components/axis_ticks.rb +25 -27
  64. data/lib/ziya/components/axis_value.rb +5 -48
  65. data/lib/ziya/components/base.rb +59 -17
  66. data/lib/ziya/components/bevel.rb +15 -0
  67. data/lib/ziya/components/blur.rb +13 -0
  68. data/lib/ziya/components/chart_border.rb +4 -23
  69. data/lib/ziya/components/chart_grid_h.rb +17 -19
  70. data/lib/ziya/components/chart_grid_v.rb +18 -19
  71. data/lib/ziya/components/chart_guide.rb +16 -0
  72. data/lib/ziya/components/chart_label.rb +16 -0
  73. data/lib/ziya/components/chart_pref.rb +12 -12
  74. data/lib/ziya/components/chart_rect.rb +27 -26
  75. data/lib/ziya/components/chart_transition.rb +15 -16
  76. data/lib/ziya/components/circle.rb +5 -2
  77. data/lib/ziya/components/draw.rb +12 -11
  78. data/lib/ziya/components/draw_base.rb +10 -0
  79. data/lib/ziya/components/filter.rb +26 -0
  80. data/lib/ziya/components/glow.rb +14 -0
  81. data/lib/ziya/components/image.rb +5 -1
  82. data/lib/ziya/components/legend.rb +18 -0
  83. data/lib/ziya/components/line.rb +6 -2
  84. data/lib/ziya/components/link.rb +9 -9
  85. data/lib/ziya/components/link_data.rb +9 -10
  86. data/lib/ziya/components/rect.rb +7 -2
  87. data/lib/ziya/components/scroll.rb +26 -0
  88. data/lib/ziya/components/shadow.rb +14 -0
  89. data/lib/ziya/components/text.rb +5 -1
  90. data/lib/ziya/components/update.rb +19 -0
  91. data/lib/ziya/gauges/base.rb +172 -0
  92. data/lib/ziya/gauges/radial.rb +18 -0
  93. data/lib/ziya/gauges/signal.rb +138 -0
  94. data/lib/ziya/gauges/support/area.rb +13 -0
  95. data/lib/ziya/gauges/support/base.rb +33 -0
  96. data/lib/ziya/gauges/support/circle.rb +14 -0
  97. data/lib/ziya/gauges/support/design.rb +5 -0
  98. data/lib/ziya/gauges/support/image.rb +12 -0
  99. data/lib/ziya/gauges/support/line.rb +12 -0
  100. data/lib/ziya/gauges/support/link.rb +24 -0
  101. data/lib/ziya/gauges/support/move.rb +15 -0
  102. data/lib/ziya/gauges/support/point.rb +12 -0
  103. data/lib/ziya/gauges/support/polygon.rb +13 -0
  104. data/lib/ziya/gauges/support/radial_base.rb +21 -0
  105. data/lib/ziya/gauges/support/radial_numbers.rb +41 -0
  106. data/lib/ziya/gauges/support/radial_ticks.rb +29 -0
  107. data/lib/ziya/gauges/support/rect.rb +14 -0
  108. data/lib/ziya/gauges/support/rotate.rb +15 -0
  109. data/lib/ziya/gauges/support/scale.rb +15 -0
  110. data/lib/ziya/gauges/support/text.rb +21 -0
  111. data/lib/ziya/gauges/support/update.rb +12 -0
  112. data/lib/ziya/gauges/thermo.rb +121 -0
  113. data/lib/ziya/helpers/base_helper.rb +39 -6
  114. data/lib/ziya/utils/text.rb +6 -0
  115. data/lib/ziya/version.rb +1 -1
  116. data/lib/ziya/ziya_helper.rb +289 -62
  117. data/spec/charts/base_spec.rb +35 -21
  118. data/spec/charts/chart_type_spec.rb +24 -3
  119. data/spec/components/area_spec.rb +9 -2
  120. data/spec/components/draw_spec.rb +1 -2
  121. data/spec/components/filter_spec.rb +27 -0
  122. data/spec/components/link_spec.rb +1 -2
  123. data/spec/components/series_color_spec.rb +1 -2
  124. data/spec/components/series_explode_spec.rb +1 -2
  125. data/spec/components/series_switch_spec.rb +1 -2
  126. data/spec/designs/circle.yml +7 -0
  127. data/spec/designs/crapping_out.yml +8 -0
  128. data/spec/designs/gauge_1.yml +43 -0
  129. data/spec/designs/gauge_2.yml +11 -0
  130. data/spec/designs/gauge_no_name.yml +43 -0
  131. data/spec/designs/gauge_raw.yml +5 -0
  132. data/spec/designs/thermo.yml +13 -0
  133. data/spec/gauges/base_spec.rb +90 -0
  134. data/spec/gauges/signal_spec.rb +36 -0
  135. data/spec/gauges/support/area_spec.rb +40 -0
  136. data/spec/gauges/support/circle_spec.rb +78 -0
  137. data/spec/gauges/support/image_spec.rb +35 -0
  138. data/spec/gauges/support/line_spec.rb +34 -0
  139. data/spec/gauges/support/link_spec.rb +35 -0
  140. data/spec/gauges/support/move_spec.rb +45 -0
  141. data/spec/gauges/support/polygon_spec.rb +36 -0
  142. data/spec/gauges/support/radial_numbers_spec.rb +35 -0
  143. data/spec/gauges/support/radial_ticks_spec.rb +30 -0
  144. data/spec/gauges/support/rotate_spec.rb +45 -0
  145. data/spec/gauges/support/scale_spec.rb +46 -0
  146. data/spec/gauges/support/text_spec.rb +40 -0
  147. data/spec/gauges/thermo_spec.rb +49 -0
  148. data/spec/helpers/base_helper_spec.rb +20 -6
  149. data/spec/spec_helper.rb +4 -1
  150. data/spec/test_helpers/gauge_2_helper.rb +17 -0
  151. data/spec/utils/logger_spec.rb +1 -3
  152. data/spec/utils/text_spec.rb +1 -2
  153. data/spec/ziya_helper_spec.rb +88 -11
  154. data/spec/ziya_spec.rb +1 -1
  155. data/tasks/gem.rake +1 -1
  156. metadata +79 -32
  157. data/charts/themes/commando/bar_chart.yml +0 -9
  158. data/charts/themes/commando/base_chart.yml +0 -65
  159. data/charts/themes/commando/column_chart.yml +0 -13
  160. data/charts/themes/commando/column_threed_chart.yml +0 -25
  161. data/charts/themes/commando/parallel_threed_column_chart.yml +0 -17
  162. data/charts/themes/commando/pie_chart.yml +0 -22
  163. data/charts/themes/commando/pie_threed_chart.yml +0 -28
  164. data/charts/themes/commando/polar_chart.yml +0 -11
  165. data/charts/themes/commando/stacked_bar_chart.yml +0 -9
  166. data/charts/themes/commando/stacked_column_chart.yml +0 -14
  167. data/charts/themes/commando/stacked_threed_column_chart.yml +0 -17
  168. data/charts/themes/default/bar_chart.yml +0 -3
  169. data/charts/themes/default/base_chart.yml +0 -67
  170. data/charts/themes/default/column_chart.yml +0 -13
  171. data/charts/themes/default/column_threed_chart.yml +0 -25
  172. data/charts/themes/default/parallel_threed_column_chart.yml +0 -17
  173. data/charts/themes/default/pie_chart.yml +0 -29
  174. data/charts/themes/default/pie_threed_chart.yml +0 -28
  175. data/charts/themes/default/polar_chart.yml +0 -12
  176. data/charts/themes/default/stacked_bar_chart.yml +0 -3
  177. data/charts/themes/default/stacked_column_chart.yml +0 -14
  178. data/charts/themes/default/stacked_threed_column_chart.yml +0 -17
  179. data/charts/themes/default/test.yml +0 -4
  180. data/lib/ziya/components/chart_value.rb +0 -71
  181. data/lib/ziya/components/legend_label.rb +0 -18
  182. data/lib/ziya/components/legend_rect.rb +0 -19
  183. data/lib/ziya/components/legend_transition.rb +0 -18
  184. data/lib/ziya/components/live_update.rb +0 -21
@@ -1,5 +1,4 @@
1
- require 'spec/spec_helper'
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 == "<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>"
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 == "<chart><chart_data><row><null/><string>fox</string><string>cat</string><string>dog</string></row></chart_data></chart>"
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 == "<chart></chart>"
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 axis value text" do
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( :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>"
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 value text arg is not an array" do
57
- lambda { @chart.add( :axis_value_text, "") }.should raise_error( ArgumentError, /array of values/i )
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 == "<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>"
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], %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>"
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], %w[label1 label2] )
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 arry" do
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 == "<chart></chart>"
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 == "<chart><chart_type><string>line</string><string>bar</string></chart_type></chart>"
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 == "<chart></chart>"
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 "spec/spec_helper"
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[Area Bar CandleStick Column ColumnThreed FloatingBar FloatingColumn Line Mixed ParallelThreedColumn Pie PieThreed Polar Scatter StackedArea StackedBar StackedArea StackedBar StackedColumn StackedThreedColumn]
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 'spec/spec_helper'
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
@@ -1,5 +1,4 @@
1
- require 'spec/spec_helper'
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::Draw do
5
4
  before( :each ) do
@@ -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
@@ -1,5 +1,4 @@
1
- require 'spec/spec_helper'
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::Link do
5
4
  before( :each ) do
@@ -1,5 +1,4 @@
1
- require 'spec/spec_helper'
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::SeriesColor do
5
4
  before( :each ) do
@@ -1,5 +1,4 @@
1
- require 'spec/spec_helper'
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::SeriesExplode do
5
4
  before( :each ) do
@@ -1,5 +1,4 @@
1
- require 'spec/spec_helper'
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::SeriesSwitch do
5
4
  before( :each ) do
@@ -0,0 +1,7 @@
1
+ <%= gauge :base %>
2
+ <%= dial :circle, :circle_1 %>
3
+ x: 999
4
+ y: 999
5
+ radius: 30
6
+ fill_alpha: 0
7
+ line_thickness: 5
@@ -0,0 +1,8 @@
1
+ <%= gauge :base %>
2
+
3
+ <%= dial :circle, :circle_1 %>
4
+ x: 999
5
+ y: 999
6
+ radius: 30
7
+ fill_alpha: 0
8
+ line_thickness: 5
@@ -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,11 @@
1
+ <%= gauge :base %>
2
+ <%= dial :circle, :circle %>
3
+ x: 200
4
+ y: 75
5
+ radius: 30
6
+ fill_alpha: 0
7
+ fill_color: <%= colorize %>
8
+ line_thickness: 5
9
+
10
+ # call up to helper to draw another circle
11
+ <%= make_circle( 10, 10, 200 ) %>
@@ -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,5 @@
1
+ --- !ruby/object:Ziya::Gauges::Base
2
+ components: !omap
3
+ - :circle_1: !ruby/object:Ziya::Gauges::Support::Circle
4
+ x: 200
5
+ y: 100
@@ -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