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
@@ -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
|