derailed-ziya 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/History.txt +0 -0
  2. data/Manifest.txt +405 -0
  3. data/README.txt +232 -0
  4. data/Rakefile +44 -0
  5. data/bin/ziyafy +53 -0
  6. data/charts/AC_RunActiveContent.js +292 -0
  7. data/charts/charts.swf +0 -0
  8. data/charts/charts_library/ar3d.swf +0 -0
  9. data/charts/charts_library/arno.swf +0 -0
  10. data/charts/charts_library/ars3.swf +0 -0
  11. data/charts/charts_library/arst.swf +0 -0
  12. data/charts/charts_library/brfl.swf +0 -0
  13. data/charts/charts_library/brno.swf +0 -0
  14. data/charts/charts_library/brst.swf +0 -0
  15. data/charts/charts_library/buno.swf +0 -0
  16. data/charts/charts_library/cl3d.swf +0 -0
  17. data/charts/charts_library/clfl.swf +0 -0
  18. data/charts/charts_library/clno.swf +0 -0
  19. data/charts/charts_library/clp3.swf +0 -0
  20. data/charts/charts_library/cls3.swf +0 -0
  21. data/charts/charts_library/clst.swf +0 -0
  22. data/charts/charts_library/cnno.swf +0 -0
  23. data/charts/charts_library/dono.swf +0 -0
  24. data/charts/charts_library/lnno.swf +0 -0
  25. data/charts/charts_library/mxno.swf +0 -0
  26. data/charts/charts_library/pi3d.swf +0 -0
  27. data/charts/charts_library/pino.swf +0 -0
  28. data/charts/charts_library/pono.swf +0 -0
  29. data/charts/charts_library/scno.swf +0 -0
  30. data/charts/full_screen.swf +0 -0
  31. data/charts/scripts/output_jpg.php +23 -0
  32. data/charts/sliders/black.swf +0 -0
  33. data/charts/sliders/preview_handle_1.swf +0 -0
  34. data/charts/sliders/preview_handle_2.swf +0 -0
  35. data/gauges/designs/circle.yml +18 -0
  36. data/gauges/designs/signal.yml +14 -0
  37. data/gauges/designs/thermo.yml +119 -0
  38. data/gauges/designs/title.yml +11 -0
  39. data/gauges/gauge.swf +0 -0
  40. data/lib/ziya/charts/area.rb +18 -0
  41. data/lib/ziya/charts/area_threed.rb +16 -0
  42. data/lib/ziya/charts/bar.rb +16 -0
  43. data/lib/ziya/charts/base.rb +510 -0
  44. data/lib/ziya/charts/bubble.rb +18 -0
  45. data/lib/ziya/charts/candle_stick.rb +16 -0
  46. data/lib/ziya/charts/column.rb +16 -0
  47. data/lib/ziya/charts/column_threed.rb +16 -0
  48. data/lib/ziya/charts/donut.rb +18 -0
  49. data/lib/ziya/charts/floating_bar.rb +16 -0
  50. data/lib/ziya/charts/floating_column.rb +16 -0
  51. data/lib/ziya/charts/line.rb +16 -0
  52. data/lib/ziya/charts/mixed.rb +16 -0
  53. data/lib/ziya/charts/parallel_threed_column.rb +16 -0
  54. data/lib/ziya/charts/pie.rb +16 -0
  55. data/lib/ziya/charts/pie_threed.rb +16 -0
  56. data/lib/ziya/charts/polar.rb +16 -0
  57. data/lib/ziya/charts/scatter.rb +16 -0
  58. data/lib/ziya/charts/stacked_area.rb +16 -0
  59. data/lib/ziya/charts/stacked_bar.rb +16 -0
  60. data/lib/ziya/charts/stacked_column.rb +16 -0
  61. data/lib/ziya/charts/stacked_threed_area.rb +16 -0
  62. data/lib/ziya/charts/stacked_threed_column.rb +16 -0
  63. data/lib/ziya/components/area.rb +17 -0
  64. data/lib/ziya/components/axis_category.rb +17 -0
  65. data/lib/ziya/components/axis_ticks.rb +35 -0
  66. data/lib/ziya/components/axis_value.rb +16 -0
  67. data/lib/ziya/components/base.rb +142 -0
  68. data/lib/ziya/components/bevel.rb +15 -0
  69. data/lib/ziya/components/blur.rb +13 -0
  70. data/lib/ziya/components/chart_border.rb +14 -0
  71. data/lib/ziya/components/chart_grid_h.rb +26 -0
  72. data/lib/ziya/components/chart_grid_v.rb +27 -0
  73. data/lib/ziya/components/chart_guide.rb +16 -0
  74. data/lib/ziya/components/chart_label.rb +16 -0
  75. data/lib/ziya/components/chart_pref.rb +22 -0
  76. data/lib/ziya/components/chart_rect.rb +37 -0
  77. data/lib/ziya/components/chart_transition.rb +25 -0
  78. data/lib/ziya/components/circle.rb +16 -0
  79. data/lib/ziya/components/context_menu.rb +15 -0
  80. data/lib/ziya/components/draw.rb +47 -0
  81. data/lib/ziya/components/draw_base.rb +10 -0
  82. data/lib/ziya/components/filter.rb +26 -0
  83. data/lib/ziya/components/glow.rb +14 -0
  84. data/lib/ziya/components/image.rb +17 -0
  85. data/lib/ziya/components/legend.rb +18 -0
  86. data/lib/ziya/components/line.rb +16 -0
  87. data/lib/ziya/components/link.rb +29 -0
  88. data/lib/ziya/components/link_data.rb +18 -0
  89. data/lib/ziya/components/rect.rb +18 -0
  90. data/lib/ziya/components/scroll.rb +26 -0
  91. data/lib/ziya/components/series.rb +16 -0
  92. data/lib/ziya/components/series_color.rb +35 -0
  93. data/lib/ziya/components/series_explode.rb +38 -0
  94. data/lib/ziya/components/shadow.rb +14 -0
  95. data/lib/ziya/components/text.rb +17 -0
  96. data/lib/ziya/components/update.rb +19 -0
  97. data/lib/ziya/gauges/base.rb +172 -0
  98. data/lib/ziya/gauges/radial.rb +18 -0
  99. data/lib/ziya/gauges/signal.rb +138 -0
  100. data/lib/ziya/gauges/support/area.rb +13 -0
  101. data/lib/ziya/gauges/support/base.rb +33 -0
  102. data/lib/ziya/gauges/support/circle.rb +14 -0
  103. data/lib/ziya/gauges/support/design.rb +5 -0
  104. data/lib/ziya/gauges/support/image.rb +12 -0
  105. data/lib/ziya/gauges/support/line.rb +12 -0
  106. data/lib/ziya/gauges/support/link.rb +24 -0
  107. data/lib/ziya/gauges/support/move.rb +15 -0
  108. data/lib/ziya/gauges/support/point.rb +12 -0
  109. data/lib/ziya/gauges/support/polygon.rb +13 -0
  110. data/lib/ziya/gauges/support/radial_base.rb +21 -0
  111. data/lib/ziya/gauges/support/radial_numbers.rb +41 -0
  112. data/lib/ziya/gauges/support/radial_ticks.rb +29 -0
  113. data/lib/ziya/gauges/support/rect.rb +14 -0
  114. data/lib/ziya/gauges/support/rotate.rb +15 -0
  115. data/lib/ziya/gauges/support/scale.rb +15 -0
  116. data/lib/ziya/gauges/support/text.rb +21 -0
  117. data/lib/ziya/gauges/support/update.rb +12 -0
  118. data/lib/ziya/gauges/thermo.rb +121 -0
  119. data/lib/ziya/helpers/base_helper.rb +70 -0
  120. data/lib/ziya/utils/logger.rb +125 -0
  121. data/lib/ziya/utils/text.rb +39 -0
  122. data/lib/ziya/version.rb +15 -0
  123. data/lib/ziya/ziya_helper.rb +374 -0
  124. data/lib/ziya.rb +112 -0
  125. data/spec/charts/base_spec.rb +134 -0
  126. data/spec/charts/chart_type_spec.rb +63 -0
  127. data/spec/components/area_spec.rb +67 -0
  128. data/spec/components/draw_spec.rb +32 -0
  129. data/spec/components/filter_spec.rb +27 -0
  130. data/spec/components/link_spec.rb +22 -0
  131. data/spec/components/series.rb +18 -0
  132. data/spec/components/series_color_spec.rb +39 -0
  133. data/spec/components/series_explode.rb +39 -0
  134. data/spec/components/series_explode_spec.rb +39 -0
  135. data/spec/designs/circle.yml +7 -0
  136. data/spec/designs/crapping_out.yml +8 -0
  137. data/spec/designs/gauge_1.yml +43 -0
  138. data/spec/designs/gauge_2.yml +11 -0
  139. data/spec/designs/gauge_no_name.yml +43 -0
  140. data/spec/designs/gauge_raw.yml +5 -0
  141. data/spec/designs/thermo.yml +13 -0
  142. data/spec/gauges/base_spec.rb +90 -0
  143. data/spec/gauges/signal_spec.rb +36 -0
  144. data/spec/gauges/support/area_spec.rb +40 -0
  145. data/spec/gauges/support/circle_spec.rb +78 -0
  146. data/spec/gauges/support/image_spec.rb +35 -0
  147. data/spec/gauges/support/line_spec.rb +34 -0
  148. data/spec/gauges/support/link_spec.rb +35 -0
  149. data/spec/gauges/support/move_spec.rb +45 -0
  150. data/spec/gauges/support/polygon_spec.rb +36 -0
  151. data/spec/gauges/support/radial_numbers_spec.rb +35 -0
  152. data/spec/gauges/support/radial_ticks_spec.rb +30 -0
  153. data/spec/gauges/support/rotate_spec.rb +45 -0
  154. data/spec/gauges/support/scale_spec.rb +46 -0
  155. data/spec/gauges/support/text_spec.rb +40 -0
  156. data/spec/gauges/thermo_spec.rb +49 -0
  157. data/spec/helpers/base_helper_spec.rb +36 -0
  158. data/spec/spec_helper.rb +10 -0
  159. data/spec/test_helpers/gauge_2_helper.rb +17 -0
  160. data/spec/themes/default/fred.yml +6 -0
  161. data/spec/themes/default/line_chart.yml +6 -0
  162. data/spec/utils/logger_spec.rb +55 -0
  163. data/spec/utils/text_spec.rb +33 -0
  164. data/spec/ziya_helper_spec.rb +117 -0
  165. data/spec/ziya_spec.rb +19 -0
  166. data/tasks/ann.rake +76 -0
  167. data/tasks/annotations.rake +22 -0
  168. data/tasks/doc.rake +48 -0
  169. data/tasks/gem.rake +110 -0
  170. data/tasks/manifest.rake +49 -0
  171. data/tasks/post_load.rake +26 -0
  172. data/tasks/rubyforge.rake +57 -0
  173. data/tasks/setup.rb +227 -0
  174. data/tasks/spec.rake +61 -0
  175. data/tasks/svn.rake +44 -0
  176. data/tasks/test.rake +38 -0
  177. metadata +468 -0
@@ -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
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Signal do
4
+ describe "#initialize" do
5
+ before( :each ) do
6
+ @gauge = Ziya::Gauges::Signal.new( "test_license", "override" )
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 == "override"
15
+ end
16
+ end
17
+
18
+ describe "#to_xml" do
19
+ it "should produce the correct xml for the std gauge" do
20
+ buff = Ziya::Gauges::Signal.new( "test_license" ).to_xml
21
+ buff.scan( /<license/ ).size.should == 1
22
+ buff.scan( /<polygon/ ).size.should == 16
23
+ buff.scan( /<point/ ).size.should == 58
24
+ buff.scan( /x=\"(.*?\d+)\"/ ).should == [["20"], ["20.0"], ["20.0"], ["35.0"], ["30.0"], ["31.7557050458495"], ["37.6335575687742"], ["47.406363729278"], ["38.270909152852"], ["39.0211303259031"], ["48.5316954888546"], ["49.3444280220142"], ["39.5629520146761"], ["39.0211303259031"], ["48.5316954888546"], ["40.0739181907658"], ["33.3826121271772"], ["31.7557050458495"], ["37.6335575687742"], ["23.1358538980296"], ["22.0905692653531"], ["20.0"], ["20.0"], ["5.0"], ["10.0"], ["8.24429495415054"], ["2.36644243122581"], ["-7.40636372927803"], ["1.72909084714798"], ["0.978869674096931"], ["-8.53169548885461"], ["-9.34442802201417"], ["0.437047985323883"], ["0.978869674096927"], ["-8.53169548885461"], ["-0.0739181907657454"], ["6.61738787282284"], ["8.24429495415053"], ["2.3664424312258"], ["16.8641461019704"], ["17.9094307346469"], ["55"], ["58.5"], ["62.0"], ["55"], ["58.5"], ["62.0"], ["55"], ["58.5"], ["62.0"], ["55"], ["58.5"], ["62.0"], ["55"], ["58.5"], ["62.0"], ["55"], ["58.5"], ["62.0"]]
25
+ buff.scan( /y=\"(.*?\d+)\"/ ).should == [["30"], ["0.0"], ["-10.0"], ["-5.98076211353316"], ["2.67949192431123"], ["3.81966011250105"], ["-4.27050983124843"], ["7.797900707726"], ["11.865267138484"], ["13.8196601125011"], ["10.7294901687516"], ["26.2373507245328"], ["24.1582338163552"], ["26.1803398874989"], ["29.2705098312484"], ["42.2943447643218"], ["34.8628965095479"], ["36.1803398874989"], ["44.2705098312484"], ["49.8356568610482"], ["39.8904379073655"], ["40.0"], ["50.0"], ["45.9807621135332"], ["37.3205080756888"], ["36.1803398874989"], ["44.2705098312484"], ["32.202099292274"], ["28.134732861516"], ["26.180339887499"], ["29.2705098312484"], ["13.7626492754672"], ["15.8417661836448"], ["13.8196601125011"], ["10.7294901687516"], ["-2.29434476432183"], ["5.13710349045212"], ["3.81966011250105"], ["-4.27050983124842"], ["-9.8356568610482"], ["0.109562092634533"], ["-2"], ["-9.0"], ["-2"], ["8.0"], ["1.0"], ["8.0"], ["18.0"], ["11.0"], ["18.0"], ["23.0"], ["30.0"], ["23.0"], ["33.0"], ["40.0"], ["33.0"], ["43.0"], ["50.0"], ["43.0"]]
26
+ end
27
+
28
+ it "user can override signal" do
29
+ gauge = Ziya::Gauges::Signal.new( "test_license" )
30
+ gauge.set_preferences( :signal => 6.5 )
31
+ buff = gauge.to_xml
32
+ buff.scan( />(\d\.\d)<\/text>/ ).should == [["6.5"]]
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Area do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Area.new(
6
+ :x => 10,
7
+ :y => 20,
8
+ :width => 200,
9
+ :height => 100,
10
+ :url => "blee",
11
+ :target => "_self",
12
+ :text => "Hello",
13
+ :font => "arial",
14
+ :bold => "false",
15
+ :size => 10,
16
+ :color => "ff00ff",
17
+ :alpha => 10,
18
+ :stop_sound => "false" )
19
+ end
20
+
21
+ describe "#flatten" do
22
+ it "should flatten component correctly" do
23
+ xml = Builder::XmlMarkup.new
24
+ @comp.flatten( xml )
25
+ buff = xml.to_s
26
+ @comp.class.attributes[@comp.class.name].each do |attr|
27
+ buff.scan( /#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :background_color
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "YAML load" do
33
+ it "should load from yaml correctly" do
34
+ comp = YAML.load( @comp.to_yaml )
35
+ @comp.options.each_pair do |k,v|
36
+ comp.send( k ).to_s.should == v.to_s
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,78 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Circle do
4
+ before( :each ) do
5
+ @comp = Ziya::Gauges::Support::Circle.new(
6
+ :x => 1,
7
+ :y => 2,
8
+ :radius => 100 )
9
+ end
10
+
11
+ it "should have some options" do
12
+ @comp.options.should == { :radius => 100, :x => 1, :y => 2 }
13
+ end
14
+
15
+ it "should convert a gauge to yaml correctly" do
16
+ circle = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
17
+ circle.is_a?( Ziya::Gauges::Support::Circle ).should == true
18
+ circle.x.should == 1
19
+ circle.y.should == 2
20
+ circle.radius.should == 100
21
+ end
22
+
23
+ it "should have options as string" do
24
+ @comp.options_as_string.should == ":radius => '100',:x => '1',:y => '2'"
25
+ end
26
+
27
+ it "should define the correct attribute methods" do
28
+ lambda{ Ziya::Gauges::Support::Circle.attributes[@comp.class.name].each {
29
+ |m| @comp.send( m ) } }.should_not raise_error
30
+ end
31
+
32
+ it "should check that a component has been configured" do
33
+ @comp.should be_configured
34
+ end
35
+
36
+ it "should check that a component has not beem configured" do
37
+ @comp = Ziya::Gauges::Support::Circle.new
38
+ @comp.should_not be_configured
39
+ end
40
+
41
+ it "should merge attributes correctly" do
42
+ parent = Ziya::Gauges::Support::Circle.new
43
+ parent.x = 20
44
+ parent.y = 50
45
+ @comp.merge( parent, false )
46
+ parent.options_as_string.should == ":x => '20',:y => '50'"
47
+ @comp.options_as_string.should == ":radius => '100',:x => '20',:y => '50'"
48
+ end
49
+
50
+ describe "#flatten" do
51
+ it "should flatten component correctly" do
52
+ xml = Builder::XmlMarkup.new
53
+ compare( @comp.flatten( xml ), { :circle => nil, :x => 1, :y => 2, :radius => 100 } )
54
+ end
55
+
56
+ it "should flatten simple component correctly" do
57
+ xml = Builder::XmlMarkup.new
58
+ comp = Ziya::Gauges::Support::Circle.new
59
+ comp.x = 10
60
+ comp.flatten( xml ).should == "<circle x=\"10\"/>"
61
+ end
62
+ end
63
+
64
+ def compare( result, hash )
65
+ result = result.gsub( /[<|\/>]/, '' )
66
+ tokens = result.split( " " )
67
+ tokens.size.should == hash.size
68
+ tokens.each do |t|
69
+ if t.index( /=/ )
70
+ kvs = t.split( "=" )
71
+ hash.has_key?( kvs.first.to_sym ).should == true
72
+ kvs[1].gsub( /"/, '').should == hash[kvs[0].to_sym].to_s
73
+ else
74
+ hash.has_key?( t.to_sym ).should == true
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Image do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Image.new(
6
+ :x => 10,
7
+ :y => 20,
8
+ :width => 200,
9
+ :height => 100,
10
+ :url => "blee",
11
+ :rotation => 90,
12
+ :alpha => 10,
13
+ :timeout => 10 )
14
+ end
15
+
16
+ describe "#flatten" do
17
+ it "should flatten component correctly" do
18
+ xml = Builder::XmlMarkup.new
19
+ @comp.flatten( xml )
20
+ buff = xml.to_s
21
+ @comp.class.attributes[@comp.class.name].each do |attr|
22
+ buff.scan( /#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :retry
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "YAML load" do
28
+ it "should load from yaml correctly" do
29
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
30
+ @comp.options.each_pair do |k,v|
31
+ comp.send( k ).to_s.should == v.to_s
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Line do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Line.new(
6
+ :x1 => 10,
7
+ :y1 => 20,
8
+ :x2 => 100,
9
+ :y2 => 200,
10
+ :color => "ff00ff",
11
+ :thickness => 90,
12
+ :alpha => 10 )
13
+ end
14
+
15
+ describe "#flatten" do
16
+ it "should flatten component correctly" do
17
+ xml = Builder::XmlMarkup.new
18
+ @comp.flatten( xml )
19
+ buff = xml.to_s
20
+ @comp.class.attributes[@comp.class.name].each do |attr|
21
+ buff.scan( /#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :retry
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "YAML load" do
27
+ it "should load from yaml correctly" do
28
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
29
+ @comp.options.each_pair do |k,v|
30
+ comp.send( k ).to_s.should == v.to_s
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Link do
4
+ before( :all ) do
5
+ @area1 = Ziya::Gauges::Support::Area.new( :x => 10, :y => 20, :width => 100, :height => 200 )
6
+ @area2 = Ziya::Gauges::Support::Area.new( :x => 20, :y => 30, :width => 100, :height => 200 )
7
+ @comp = Ziya::Gauges::Support::Link.new(
8
+ :components => YAML::Omap[
9
+ :area_1, @area1,
10
+ :area_2, @area2
11
+ ] )
12
+ end
13
+
14
+ describe "#flatten" do
15
+ it "should flatten component correctly" do
16
+ xml = Builder::XmlMarkup.new
17
+ @comp.flatten( xml )
18
+ buff = xml.to_s
19
+ buff.scan( /<area/ ).size.should == 2
20
+ buff.scan( /x=\"(.*?\d+)\"/ ).should == [ ["10"], ["20"] ]
21
+ buff.scan( /y=\"(.*?\d+)\"/ ).should == [ ["20"], ["30"] ]
22
+ buff.scan( /width=\"(.*?\d+)\"/ ).should == [ ["100"], ["100"] ]
23
+ buff.scan( /height=\"(.*?\d+)\"/ ).should == [ ["200"], ["200"] ]
24
+ end
25
+ end
26
+
27
+ describe "YAML load" do
28
+ it "should load from yaml correctly" do
29
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
30
+ @comp.options.each_pair do |k,v|
31
+ comp.send( k ).should == v
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Move do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Move.new(
6
+ :start_x_offset => 3,
7
+ :start_y_offset => 30,
8
+ :end_x_offset => 25,
9
+ :end_y_offset => 100,
10
+ :step => 0,
11
+ :shake_span => 10,
12
+ :shake_frequency => 100,
13
+ :shake_snap => 10,
14
+ :shadow_alpha => 100,
15
+ :shadow_x_offset => 10,
16
+ :shadow_y_offset => 20,
17
+ :components => YAML::Omap[
18
+ :point_1, Ziya::Gauges::Support::Point.new( :x => 10, :y => 20 ),
19
+ :point_2, Ziya::Gauges::Support::Point.new( :x => 20, :y => 30 )
20
+ ] )
21
+ end
22
+
23
+ describe "#flatten" do
24
+ it "should flatten component correctly" do
25
+ xml = Builder::XmlMarkup.new
26
+ @comp.flatten( xml )
27
+ buff = xml.to_s
28
+ @comp.class.attributes[@comp.class.name].each do |attr|
29
+ buff.scan( /#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :components
30
+ end
31
+ buff.scan( /<point/ ).size.should == 2
32
+ buff.scan( /\sx=\"(.*?\d+)\"/ ).should == [ ["10"], ["20"] ]
33
+ buff.scan( /\sy=\"(.*?\d+)\"/ ).should == [ ["20"], ["30"] ]
34
+ end
35
+ end
36
+
37
+ describe "YAML load" do
38
+ it "should load from yaml correctly" do
39
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
40
+ @comp.options.each_pair do |k,v|
41
+ comp.send( k ).should == v
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Polygon do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Polygon.new(
6
+ :fill_color => "ffffff",
7
+ :fill_alpha => 100,
8
+ :line_color => "ff00ff",
9
+ :line_alpha => 100,
10
+ :line_thickness => 0,
11
+ :components => YAML::Omap[
12
+ :point_1, Ziya::Gauges::Support::Point.new( :x => 10, :y => 20 ),
13
+ :point_2, Ziya::Gauges::Support::Point.new( :x => 20, :y => 30 )
14
+ ] )
15
+ end
16
+
17
+ describe "#flatten" do
18
+ it "should flatten component correctly" do
19
+ xml = Builder::XmlMarkup.new
20
+ @comp.flatten( xml )
21
+ buff = xml.to_s
22
+ @comp.class.attributes[@comp.class.name].each do |attr|
23
+ buff.scan( /#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :components
24
+ end
25
+ end
26
+ end
27
+
28
+ describe "YAML load" do
29
+ it "should load from yaml correctly" do
30
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
31
+ @comp.options.each_pair do |k,v|
32
+ comp.send( k ).should == v
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::RadialNumbers do
4
+ before( :each ) do
5
+ @comp = Ziya::Gauges::Support::RadialNumbers.new(
6
+ :x => 10,
7
+ :y => 10,
8
+ :radius => 200,
9
+ :start_num => 1,
10
+ :end_num => 10,
11
+ :start_angle => 0,
12
+ :end_angle => 180,
13
+ :ticks => 10,
14
+ :font => "arial",
15
+ :bold => "false",
16
+ :align => "left",
17
+ :width => 100,
18
+ :height => 100,
19
+ :size => 10,
20
+ :color => "ffffff" )
21
+ end
22
+
23
+ describe "#flatten" do
24
+ it "should flatten component correctly" do
25
+ xml = Builder::XmlMarkup.new
26
+ @comp.flatten( xml )
27
+ buff = xml.to_s
28
+ buff.scan( /<text/ ).size.should == 10
29
+ buff.scan( /x=\"(.*?\d+)\"/ ).should == [ ["10"], ["78"], ["138"], ["183"], ["206"], ["206"], ["183"], ["138"], ["78"], ["10"] ]
30
+ buff.scan( /y=\"(.*?\d+)\"/ ).should == [ ["-190"], ["-177"], ["-143"], ["-90"], ["-24"], ["44"], ["109"], ["163"], ["197"], ["210"] ]
31
+ buff.scan( />(\d+)<\/text>/ ).should == [ ["1"], ["2"], ["3"], ["4"], ["5"], ["6"], ["7"], ["8"], ["9"], ["10"] ]
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::RadialTicks do
4
+ before( :each ) do
5
+ @comp = Ziya::Gauges::Support::RadialTicks.new
6
+ @comp.x = 1
7
+ @comp.y = 2
8
+ @comp.radius = 100
9
+ @comp.length = 100
10
+ @comp.start_angle = 0
11
+ @comp.end_angle = 90
12
+ @comp.ticks = 10
13
+ @comp.thickness = 1
14
+ @comp.color = "ffffff"
15
+ end
16
+
17
+ describe "#flatten" do
18
+ it "should flatten component correctly" do
19
+ xml = Builder::XmlMarkup.new
20
+ @comp.flatten( xml )
21
+ buff = xml.to_s
22
+ buff.scan( /<line/ ).size.should == 10
23
+ buff.scan( /x1=\"(.*?\d+)\"/ ).should == [ ["1"], ["18"], ["35"], ["50"], ["65"], ["77"], ["87"], ["94"], ["99"], ["101"] ]
24
+ buff.scan( /y1=\"(.*?\d+)\"/ ).should == [ ["-98"], ["-96"], ["-91"], ["-84"], ["-74"], ["-62"], ["-48"], ["-32"], ["-15"], ["1"] ]
25
+ buff.scan( /x2=\"(.*?\d+)\"/ ).should == [ ["1"], ["35"], ["69"], ["100"], ["129"], ["154"], ["174"], ["188"], ["197"], ["201"] ]
26
+ buff.scan( /y2=\"(.*?\d+)\"/ ).should == [ ["-198"], ["-194"], ["-185"], ["-171"], ["-151"], ["-126"], ["-98"], ["-66"], ["-32"], ["1"] ]
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Rotate do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Rotate.new(
6
+ :x => 3,
7
+ :y => 30,
8
+ :start => 25,
9
+ :step => 0,
10
+ :span => 45,
11
+ :shake_span => 100,
12
+ :shake_frequency => 10,
13
+ :shake_snap => 20,
14
+ :shadow_alpha => 100,
15
+ :shadow_x_offset => 10,
16
+ :shadow_y_offset => 20,
17
+ :components => YAML::Omap[
18
+ :line_1, Ziya::Gauges::Support::Line.new( :x1 => 10, :y1 => 20 ),
19
+ :line_2, Ziya::Gauges::Support::Line.new( :x1 => 20, :y1 => 30 )
20
+ ] )
21
+ end
22
+
23
+ describe "#flatten" do
24
+ it "should flatten component correctly" do
25
+ xml = Builder::XmlMarkup.new
26
+ @comp.flatten( xml )
27
+ buff = xml.to_s
28
+ @comp.class.attributes[@comp.class.name].each do |attr|
29
+ buff.scan( /\s#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :components
30
+ end
31
+ buff.scan( /<line/ ).size.should == 2
32
+ buff.scan( /\sx1=\"(.*?\d+)\"/ ).should == [ ["10"], ["20"] ]
33
+ buff.scan( /\sy1=\"(.*?\d+)\"/ ).should == [ ["20"], ["30"] ]
34
+ end
35
+ end
36
+
37
+ describe "YAML load" do
38
+ it "should load from yaml correctly" do
39
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
40
+ @comp.options.each_pair do |k,v|
41
+ comp.send( k ).should == v
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Scale do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Scale.new(
6
+ :x => 3,
7
+ :y => 30,
8
+ :start_scale => 25,
9
+ :end_scale => 100,
10
+ :step => 0,
11
+ :direction => 10,
12
+ :shake_span => 100,
13
+ :shake_frequency => 10,
14
+ :shake_snap => 20,
15
+ :shadow_alpha => 100,
16
+ :shadow_x_offset => 10,
17
+ :shadow_y_offset => 20,
18
+ :components => YAML::Omap[
19
+ :line1, Ziya::Gauges::Support::Line.new( :x1 => 10, :y1 => 20 ),
20
+ :line2, Ziya::Gauges::Support::Line.new( :x1 => 20, :y1 => 30 )
21
+ ] )
22
+ end
23
+
24
+ describe "#flatten" do
25
+ it "should flatten component correctly" do
26
+ xml = Builder::XmlMarkup.new
27
+ @comp.flatten( xml )
28
+ buff = xml.to_s
29
+ @comp.class.attributes[@comp.class.name].each do |attr|
30
+ buff.scan( /\s#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :components
31
+ end
32
+ buff.scan( /<line/ ).size.should == 2
33
+ buff.scan( /\sx1=\"(.*?\d+)\"/ ).should == [ ["10"], ["20"] ]
34
+ buff.scan( /\sy1=\"(.*?\d+)\"/ ).should == [ ["20"], ["30"] ]
35
+ end
36
+ end
37
+
38
+ describe "YAML load" do
39
+ it "should load from yaml correctly" do
40
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
41
+ @comp.options.each_pair do |k,v|
42
+ comp.send( k ).should == v
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
2
+
3
+ describe Ziya::Gauges::Support::Text do
4
+ before( :all ) do
5
+ @comp = Ziya::Gauges::Support::Text.new(
6
+ :x => 1,
7
+ :y => 2,
8
+ :width => 100,
9
+ :height => 100,
10
+ :rotation => 0,
11
+ :font => "arial",
12
+ :bold => true,
13
+ :size => 1,
14
+ :align => "left",
15
+ :color => "ffffff",
16
+ :alpha => 100,
17
+ :text => "Hello Bubba !!" )
18
+ end
19
+
20
+ describe "#flatten" do
21
+ it "should flatten component correctly" do
22
+ xml = Builder::XmlMarkup.new
23
+ @comp.flatten( xml )
24
+ buff = xml.to_s
25
+ @comp.class.attributes[@comp.class.name].each do |attr|
26
+ buff.scan( /#{attr}=\"(\w+)\"/ ).should == [ [@comp.send( attr ).to_s] ] unless attr == :text
27
+ end
28
+ buff.scan( />(#{@comp.text})<\/text>/ ).should == [ [@comp.text] ]
29
+ end
30
+ end
31
+
32
+ describe "YAML load" do
33
+ it "should load from yaml correctly" do
34
+ comp = YAML.load( @comp.to_comp_yaml( :test, 1 ) ).first[:test]
35
+ @comp.options.each_pair do |k,v|
36
+ comp.send( k ).should == v
37
+ end
38
+ end
39
+ end
40
+ end