pulse-meter 0.4.9 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -48
- data/lib/pulse-meter.rb +1 -68
- data/lib/pulse-meter/visualizer.rb +1 -40
- data/pulse-meter.gemspec +4 -26
- metadata +10 -558
- data/Procfile +0 -3
- data/bin/pulse +0 -6
- data/examples/basic.ru +0 -145
- data/examples/basic_sensor_data.rb +0 -96
- data/examples/udp_benchmark.rb +0 -29
- data/lib/cmd.rb +0 -171
- data/lib/pulse-meter/command_aggregator/async.rb +0 -83
- data/lib/pulse-meter/command_aggregator/sync.rb +0 -18
- data/lib/pulse-meter/command_aggregator/udp.rb +0 -48
- data/lib/pulse-meter/extensions/enumerable.rb +0 -24
- data/lib/pulse-meter/mixins/cmd.rb +0 -46
- data/lib/pulse-meter/mixins/dumper.rb +0 -87
- data/lib/pulse-meter/mixins/utils.rb +0 -155
- data/lib/pulse-meter/observer.rb +0 -120
- data/lib/pulse-meter/observer/extended.rb +0 -34
- data/lib/pulse-meter/sensor.rb +0 -61
- data/lib/pulse-meter/sensor/base.rb +0 -88
- data/lib/pulse-meter/sensor/configuration.rb +0 -106
- data/lib/pulse-meter/sensor/counter.rb +0 -39
- data/lib/pulse-meter/sensor/hashed_counter.rb +0 -36
- data/lib/pulse-meter/sensor/hashed_indicator.rb +0 -24
- data/lib/pulse-meter/sensor/indicator.rb +0 -35
- data/lib/pulse-meter/sensor/multi.rb +0 -97
- data/lib/pulse-meter/sensor/timeline.rb +0 -236
- data/lib/pulse-meter/sensor/timeline_reduce.rb +0 -68
- data/lib/pulse-meter/sensor/timelined/average.rb +0 -32
- data/lib/pulse-meter/sensor/timelined/counter.rb +0 -23
- data/lib/pulse-meter/sensor/timelined/hashed_counter.rb +0 -31
- data/lib/pulse-meter/sensor/timelined/hashed_indicator.rb +0 -30
- data/lib/pulse-meter/sensor/timelined/indicator.rb +0 -23
- data/lib/pulse-meter/sensor/timelined/max.rb +0 -19
- data/lib/pulse-meter/sensor/timelined/median.rb +0 -14
- data/lib/pulse-meter/sensor/timelined/min.rb +0 -19
- data/lib/pulse-meter/sensor/timelined/multi_percentile.rb +0 -34
- data/lib/pulse-meter/sensor/timelined/percentile.rb +0 -22
- data/lib/pulse-meter/sensor/timelined/uniq_counter.rb +0 -22
- data/lib/pulse-meter/sensor/timelined/zset_based.rb +0 -38
- data/lib/pulse-meter/sensor/uniq_counter.rb +0 -24
- data/lib/pulse-meter/server.rb +0 -0
- data/lib/pulse-meter/server/command_line_options.rb +0 -0
- data/lib/pulse-meter/server/config_options.rb +0 -0
- data/lib/pulse-meter/server/sensors.rb +0 -0
- data/lib/pulse-meter/udp_server.rb +0 -45
- data/lib/pulse-meter/version.rb +0 -3
- data/lib/pulse-meter/visualize/app.rb +0 -78
- data/lib/pulse-meter/visualize/base.rb +0 -15
- data/lib/pulse-meter/visualize/coffee/application.coffee +0 -40
- data/lib/pulse-meter/visualize/coffee/collections/page_info_list.coffee +0 -17
- data/lib/pulse-meter/visualize/coffee/collections/sensor_info_list.coffee +0 -4
- data/lib/pulse-meter/visualize/coffee/collections/widget_list.coffee +0 -14
- data/lib/pulse-meter/visualize/coffee/extensions.coffee +0 -26
- data/lib/pulse-meter/visualize/coffee/models/dinamic_widget.coffee +0 -34
- data/lib/pulse-meter/visualize/coffee/models/page_info.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/models/sensor_info.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/models/widget.coffee +0 -54
- data/lib/pulse-meter/visualize/coffee/presenters/area.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/presenters/gauge.coffee +0 -11
- data/lib/pulse-meter/visualize/coffee/presenters/line.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/presenters/pie.coffee +0 -20
- data/lib/pulse-meter/visualize/coffee/presenters/series.coffee +0 -44
- data/lib/pulse-meter/visualize/coffee/presenters/table.coffee +0 -10
- data/lib/pulse-meter/visualize/coffee/presenters/timeline.coffee +0 -13
- data/lib/pulse-meter/visualize/coffee/presenters/widget.coffee +0 -65
- data/lib/pulse-meter/visualize/coffee/router.coffee +0 -21
- data/lib/pulse-meter/visualize/coffee/views/dynamic_chart.coffee +0 -91
- data/lib/pulse-meter/visualize/coffee/views/dynamic_widget.coffee +0 -58
- data/lib/pulse-meter/visualize/coffee/views/page_title.coffee +0 -17
- data/lib/pulse-meter/visualize/coffee/views/page_titles.coffee +0 -15
- data/lib/pulse-meter/visualize/coffee/views/sensor_info_list.coffee +0 -19
- data/lib/pulse-meter/visualize/coffee/views/widget.coffee +0 -99
- data/lib/pulse-meter/visualize/coffee/views/widget_chart.coffee +0 -13
- data/lib/pulse-meter/visualize/coffee/views/widget_list.coffee +0 -15
- data/lib/pulse-meter/visualize/dsl/base.rb +0 -131
- data/lib/pulse-meter/visualize/dsl/errors.rb +0 -40
- data/lib/pulse-meter/visualize/dsl/layout.rb +0 -27
- data/lib/pulse-meter/visualize/dsl/page.rb +0 -33
- data/lib/pulse-meter/visualize/dsl/sensor.rb +0 -20
- data/lib/pulse-meter/visualize/dsl/widget.rb +0 -37
- data/lib/pulse-meter/visualize/dsl/widgets/area.rb +0 -20
- data/lib/pulse-meter/visualize/dsl/widgets/gauge.rb +0 -12
- data/lib/pulse-meter/visualize/dsl/widgets/line.rb +0 -21
- data/lib/pulse-meter/visualize/dsl/widgets/pie.rb +0 -16
- data/lib/pulse-meter/visualize/dsl/widgets/table.rb +0 -19
- data/lib/pulse-meter/visualize/layout.rb +0 -79
- data/lib/pulse-meter/visualize/page.rb +0 -25
- data/lib/pulse-meter/visualize/public/css/application.css +0 -56
- data/lib/pulse-meter/visualize/public/css/bootstrap.css +0 -4883
- data/lib/pulse-meter/visualize/public/css/bootstrap.min.css +0 -729
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_222222_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_454545_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_888888_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_f6cf3b_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/jquery-ui-1.8.16.bootstrap.css +0 -1320
- data/lib/pulse-meter/visualize/public/favicon.ico +0 -208
- data/lib/pulse-meter/visualize/public/img/glyphicons-halflings-white.png +0 -0
- data/lib/pulse-meter/visualize/public/img/glyphicons-halflings.png +0 -0
- data/lib/pulse-meter/visualize/public/js/application.js +0 -973
- data/lib/pulse-meter/visualize/public/js/backbone-min.js +0 -38
- data/lib/pulse-meter/visualize/public/js/bootstrap.js +0 -1835
- data/lib/pulse-meter/visualize/public/js/jquery-1.7.2.min.js +0 -4
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.16.bootstrap.min.js +0 -791
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.23.custom.min.js +0 -21
- data/lib/pulse-meter/visualize/public/js/jquery-ui-timepicker-addon.js +0 -1687
- data/lib/pulse-meter/visualize/public/js/json2.js +0 -487
- data/lib/pulse-meter/visualize/public/js/underscore-min.js +0 -32
- data/lib/pulse-meter/visualize/sensor.rb +0 -63
- data/lib/pulse-meter/visualize/series_extractor.rb +0 -107
- data/lib/pulse-meter/visualize/views/main.haml +0 -30
- data/lib/pulse-meter/visualize/views/sensors.haml +0 -76
- data/lib/pulse-meter/visualize/views/widgets/area.haml +0 -53
- data/lib/pulse-meter/visualize/views/widgets/extend_options.haml +0 -11
- data/lib/pulse-meter/visualize/views/widgets/gauge.haml +0 -13
- data/lib/pulse-meter/visualize/views/widgets/line.haml +0 -54
- data/lib/pulse-meter/visualize/views/widgets/pie.haml +0 -13
- data/lib/pulse-meter/visualize/views/widgets/table.haml +0 -45
- data/lib/pulse-meter/visualize/widget.rb +0 -38
- data/lib/pulse-meter/visualize/widgets/gauge.rb +0 -47
- data/lib/pulse-meter/visualize/widgets/pie.rb +0 -36
- data/lib/pulse-meter/visualize/widgets/timeline.rb +0 -114
- data/spec/pulse_meter/command_aggregator/async_spec.rb +0 -53
- data/spec/pulse_meter/command_aggregator/sync_spec.rb +0 -25
- data/spec/pulse_meter/command_aggregator/udp_spec.rb +0 -45
- data/spec/pulse_meter/extensions/enumerable_spec.rb +0 -58
- data/spec/pulse_meter/mixins/cmd_spec.rb +0 -117
- data/spec/pulse_meter/mixins/dumper_spec.rb +0 -162
- data/spec/pulse_meter/mixins/utils_spec.rb +0 -212
- data/spec/pulse_meter/observer/extended_spec.rb +0 -92
- data/spec/pulse_meter/observer_spec.rb +0 -207
- data/spec/pulse_meter/sensor/base_spec.rb +0 -106
- data/spec/pulse_meter/sensor/configuration_spec.rb +0 -103
- data/spec/pulse_meter/sensor/counter_spec.rb +0 -54
- data/spec/pulse_meter/sensor/hashed_counter_spec.rb +0 -43
- data/spec/pulse_meter/sensor/hashed_indicator_spec.rb +0 -39
- data/spec/pulse_meter/sensor/indicator_spec.rb +0 -43
- data/spec/pulse_meter/sensor/multi_spec.rb +0 -137
- data/spec/pulse_meter/sensor/timeline_spec.rb +0 -88
- data/spec/pulse_meter/sensor/timelined/average_spec.rb +0 -6
- data/spec/pulse_meter/sensor/timelined/counter_spec.rb +0 -6
- data/spec/pulse_meter/sensor/timelined/hashed_counter_spec.rb +0 -8
- data/spec/pulse_meter/sensor/timelined/hashed_indicator_spec.rb +0 -8
- data/spec/pulse_meter/sensor/timelined/indicator_spec.rb +0 -6
- data/spec/pulse_meter/sensor/timelined/max_spec.rb +0 -7
- data/spec/pulse_meter/sensor/timelined/median_spec.rb +0 -7
- data/spec/pulse_meter/sensor/timelined/min_spec.rb +0 -7
- data/spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb +0 -21
- data/spec/pulse_meter/sensor/timelined/percentile_spec.rb +0 -17
- data/spec/pulse_meter/sensor/timelined/uniq_counter_spec.rb +0 -9
- data/spec/pulse_meter/sensor/uniq_counter_spec.rb +0 -28
- data/spec/pulse_meter/udp_server_spec.rb +0 -36
- data/spec/pulse_meter/visualize/app_spec.rb +0 -27
- data/spec/pulse_meter/visualize/dsl/layout_spec.rb +0 -64
- data/spec/pulse_meter/visualize/dsl/page_spec.rb +0 -62
- data/spec/pulse_meter/visualize/dsl/sensor_spec.rb +0 -30
- data/spec/pulse_meter/visualize/dsl/widget_spec.rb +0 -6
- data/spec/pulse_meter/visualize/dsl/widgets/area_spec.rb +0 -44
- data/spec/pulse_meter/visualize/dsl/widgets/gauge_spec.rb +0 -22
- data/spec/pulse_meter/visualize/dsl/widgets/line_spec.rb +0 -44
- data/spec/pulse_meter/visualize/dsl/widgets/pie_spec.rb +0 -35
- data/spec/pulse_meter/visualize/dsl/widgets/table_spec.rb +0 -36
- data/spec/pulse_meter/visualize/layout_spec.rb +0 -54
- data/spec/pulse_meter/visualize/page_spec.rb +0 -153
- data/spec/pulse_meter/visualize/sensor_spec.rb +0 -120
- data/spec/pulse_meter/visualize/series_extractor_spec.rb +0 -80
- data/spec/pulse_meter/visualize/widgets/area_spec.rb +0 -6
- data/spec/pulse_meter/visualize/widgets/gauge_spec.rb +0 -63
- data/spec/pulse_meter/visualize/widgets/line_spec.rb +0 -6
- data/spec/pulse_meter/visualize/widgets/pie_spec.rb +0 -73
- data/spec/pulse_meter/visualize/widgets/table_spec.rb +0 -6
- data/spec/pulse_meter/visualizer_spec.rb +0 -42
- data/spec/pulse_meter_spec.rb +0 -73
- data/spec/shared_examples/dsl_widget.rb +0 -106
- data/spec/shared_examples/timeline_sensor.rb +0 -439
- data/spec/shared_examples/timelined_subclass.rb +0 -23
- data/spec/shared_examples/widget.rb +0 -97
- data/spec/spec_helper.rb +0 -40
- data/spec/support/matchers.rb +0 -34
- data/spec/support/observered.rb +0 -40
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Sensor::Timelined::MultiPercentile do
|
4
|
-
it_should_behave_like "timeline sensor", {:p => [0.8]}
|
5
|
-
it_should_behave_like "timelined subclass", [5, 4, 2, 2, 2, 2, 2, 2, 2, 1], {0.8 => 2, 0.5 => 2}.to_json, {:p => [0.8, 0.5]}
|
6
|
-
it_should_behave_like "timelined subclass", [1], {0.8 => 1}.to_json, {:p => [0.8]}
|
7
|
-
|
8
|
-
let(:init_values) {{:ttl => 1, :raw_data_ttl => 1, :interval => 1, :reduce_delay => 1}}
|
9
|
-
let(:name) {"percentile"}
|
10
|
-
|
11
|
-
it "should raise exception when extra parameter is not array of percentiles" do
|
12
|
-
expect {described_class.new(name, init_values.merge({:p => :bad}))}.to raise_exception(ArgumentError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should raise exception when one of percentiles is not between 0 and 1" do
|
16
|
-
expect {described_class.new(name, init_values.merge({:p => [0.5, -1]}))}.to raise_exception(ArgumentError)
|
17
|
-
expect {described_class.new(name, init_values.merge({:p => [0.5, 1.1]}))}.to raise_exception(ArgumentError)
|
18
|
-
expect {described_class.new(name, init_values.merge({:p => [0.5, 0.1]}))}.not_to raise_exception(ArgumentError)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Sensor::Timelined::Percentile do
|
4
|
-
it_should_behave_like "timeline sensor", {:p => 0.8}
|
5
|
-
it_should_behave_like "timelined subclass", [5, 4, 2, 2, 2, 2, 2, 2, 2, 1], 2, {:p => 0.8}
|
6
|
-
it_should_behave_like "timelined subclass", [1], 1, {:p => 0.8}
|
7
|
-
|
8
|
-
let(:init_values) {{:ttl => 1, :raw_data_ttl => 1, :interval => 1, :reduce_delay => 1}}
|
9
|
-
let(:name) {"percentile"}
|
10
|
-
|
11
|
-
it "should raise exception when percentile is not between 0 and 1" do
|
12
|
-
expect {described_class.new(name, init_values.merge({:p => -1}))}.to raise_exception(ArgumentError)
|
13
|
-
expect {described_class.new(name, init_values.merge({:p => 1.1}))}.to raise_exception(ArgumentError)
|
14
|
-
expect {described_class.new(name, init_values.merge({:p => 0.1}))}.not_to raise_exception(ArgumentError)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Sensor::Timelined::UniqCounter do
|
4
|
-
it_should_behave_like "timeline sensor"
|
5
|
-
it_should_behave_like "timelined subclass", [:foo, :bar], 2
|
6
|
-
it_should_behave_like "timelined subclass", [:foo, :bar, :foo], 2
|
7
|
-
data = (1..100).map {rand(200)}
|
8
|
-
it_should_behave_like "timelined subclass", data, data.uniq.count
|
9
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Sensor::UniqCounter do
|
4
|
-
let(:name){ :some_counter }
|
5
|
-
let(:sensor){ described_class.new(name) }
|
6
|
-
let(:redis){ PulseMeter.redis }
|
7
|
-
|
8
|
-
describe "#event" do
|
9
|
-
it "should count unique values" do
|
10
|
-
expect{ sensor.event(:first) }.to change{sensor.value}.to(1)
|
11
|
-
expect{ sensor.event(:first) }.not_to change{sensor.value}
|
12
|
-
expect{ sensor.event(:second) }.to change{sensor.value}.from(1).to(2)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#value" do
|
17
|
-
it "should have initial value 0" do
|
18
|
-
sensor.value.should == 0
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return count of unique values" do
|
22
|
-
data = (1..100).map {rand(200)}
|
23
|
-
data.each {|e| sensor.event(e)}
|
24
|
-
sensor.value.should == data.uniq.count
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::UDPServer do
|
4
|
-
let(:host){'127.0.0.1'}
|
5
|
-
let(:port){33333}
|
6
|
-
let(:udp_sock){mock(:socket)}
|
7
|
-
let(:redis){PulseMeter.redis}
|
8
|
-
before do
|
9
|
-
UDPSocket.should_receive(:new).and_return(udp_sock)
|
10
|
-
udp_sock.should_receive(:bind).with(host, port).and_return(nil)
|
11
|
-
udp_sock.should_receive("do_not_reverse_lookup=").with(true).and_return(nil)
|
12
|
-
@server = described_class.new(host, port)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#start" do
|
16
|
-
let(:data){
|
17
|
-
[
|
18
|
-
["set", "xxxx", "zzzz"],
|
19
|
-
["set", "yyyy", "zzzz"]
|
20
|
-
].to_json
|
21
|
-
}
|
22
|
-
it "should process proper incoming commands" do
|
23
|
-
udp_sock.should_receive(:recvfrom).with(described_class::MAX_PACKET).and_return(data)
|
24
|
-
@server.start(1)
|
25
|
-
redis.get("xxxx").should == "zzzz"
|
26
|
-
redis.get("yyyy").should == "zzzz"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should suppress JSON errors" do
|
30
|
-
udp_sock.should_receive(:recvfrom).with(described_class::MAX_PACKET).and_return("xxx")
|
31
|
-
expect{ @server.start(1) }.not_to raise_exception
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::App do
|
4
|
-
include Rack::Test::Methods
|
5
|
-
before(:each) do
|
6
|
-
@layout = PulseMeter::Visualizer.draw do |l|
|
7
|
-
l.title "Foo meters"
|
8
|
-
l.page "Foo page" do
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def app
|
14
|
-
PulseMeter::Visualize::App.new(@layout)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "responds to /" do
|
18
|
-
get '/'
|
19
|
-
last_response.should be_ok
|
20
|
-
last_response.body.should include("Foo meters")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "responds to /application.js" do
|
24
|
-
get '/js/application.js'
|
25
|
-
last_response.should be_ok
|
26
|
-
end
|
27
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::DSL::Layout do
|
4
|
-
let(:interval){ 100 }
|
5
|
-
let(:sensor_name) { "some_sensor" }
|
6
|
-
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(sensor_name, :ttl => 1000, :interval => interval) }
|
7
|
-
let(:layout){ described_class.new }
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
it "should initialize pages, title, use_utc, gchart_options" do
|
11
|
-
l = layout.to_data
|
12
|
-
l.title.should == PulseMeter::Visualize::DSL::Layout::DEFAULT_TITLE
|
13
|
-
l.pages.should == []
|
14
|
-
l.use_utc.should be_false
|
15
|
-
l.gchart_options.should == {}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#page" do
|
20
|
-
it "should add page constructed by block to pages" do
|
21
|
-
layout.page "My Foo Page" do |p|
|
22
|
-
p.pie "foo_widget", sensor: sensor_name
|
23
|
-
p.line "bar_widget" do |w|
|
24
|
-
w.sensor(sensor_name)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
l = layout.to_data
|
28
|
-
l.pages.size.should == 1
|
29
|
-
p = l.pages.first
|
30
|
-
p.title.should == "My Foo Page"
|
31
|
-
p.widgets.size.should == 2
|
32
|
-
p.widgets.first.title.should == "foo_widget"
|
33
|
-
p.widgets.last.title.should == "bar_widget"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#title" do
|
38
|
-
it "should set layout title" do
|
39
|
-
layout.title "Foo Title"
|
40
|
-
layout.to_data.title.should == 'Foo Title'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#use_utc" do
|
45
|
-
it "should set use_utc" do
|
46
|
-
layout.use_utc false
|
47
|
-
layout.to_data.use_utc.should be_false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#gchart_options" do
|
52
|
-
it "should set gchart_options" do
|
53
|
-
layout.gchart_options({b: 1})
|
54
|
-
layout.to_data.gchart_options.should == {b: 1}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#to_data" do
|
59
|
-
it "should convert layout dsl data to Visualize::Layout" do
|
60
|
-
layout.to_data.should be_kind_of(PulseMeter::Visualize::Layout)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::DSL::Page do
|
4
|
-
let(:interval){ 100 }
|
5
|
-
let(:sensor_name) { "some_sensor" }
|
6
|
-
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(sensor_name, :ttl => 1000, :interval => interval) }
|
7
|
-
let(:title) { "page title" }
|
8
|
-
let(:page){ PulseMeter::Visualize::DSL::Page.new(title) }
|
9
|
-
|
10
|
-
describe '.new' do
|
11
|
-
it "should initialize title and widgets" do
|
12
|
-
p = page.to_data
|
13
|
-
p.title.should == title
|
14
|
-
p.widgets.should == []
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
[:area, :line, :table, :pie, :gauge].each do |widget_type|
|
19
|
-
|
20
|
-
describe "##{widget_type}" do
|
21
|
-
it "should add #{widget_type} widget initialized by args to widgets" do
|
22
|
-
page.send(widget_type, :some_widget_name, sensor: sensor_name, width: 7)
|
23
|
-
w = page.to_data.widgets.first
|
24
|
-
w.width.should == 7
|
25
|
-
w.title.should == "some_widget_name"
|
26
|
-
w.sensors.first.name.should == sensor_name
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should add #{widget_type} widget initialized by block" do
|
30
|
-
page.send(widget_type, :some_widget_name) do |w|
|
31
|
-
w.sensor(sensor_name)
|
32
|
-
w.sensor(sensor_name)
|
33
|
-
w.title "foo_widget"
|
34
|
-
w.width 7
|
35
|
-
end
|
36
|
-
w = page.to_data.widgets.first
|
37
|
-
w.type.should == widget_type.to_s
|
38
|
-
w.width.should == 7
|
39
|
-
w.title.should == "foo_widget"
|
40
|
-
w.sensors.size.should == 2
|
41
|
-
w.sensors.first.name.should == sensor_name
|
42
|
-
w.sensors.last.name.should == sensor_name
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#title" do
|
49
|
-
it "should set page title" do
|
50
|
-
page.title "Foo Title"
|
51
|
-
page.to_data.title.should == 'Foo Title'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#to_data" do
|
56
|
-
it "should convert DSL data to Visualize::Page" do
|
57
|
-
page.to_data.should be_kind_of(PulseMeter::Visualize::Page)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::DSL::Sensor do
|
4
|
-
let(:interval){ 100 }
|
5
|
-
let(:name) { "some_sensor" }
|
6
|
-
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
7
|
-
|
8
|
-
describe '.new' do
|
9
|
-
it "should save passed name and create Visualize::Sensor with it" do
|
10
|
-
described_class.new(name).to_data.name.to_s.should == name
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#process_args' do
|
15
|
-
it "should pass args transparently to Visualize::Sensor" do
|
16
|
-
s = described_class.new(name)
|
17
|
-
s.process_args color: :red
|
18
|
-
s.to_data.color.to_s.should == 'red'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#to_data' do
|
23
|
-
# actually tested above
|
24
|
-
it "should convert dsl data to sensor" do
|
25
|
-
described_class.new(name).to_data.should be_kind_of(PulseMeter::Visualize::Sensor)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::DSL::Widgets::Area do
|
4
|
-
it_should_behave_like "dsl widget"
|
5
|
-
|
6
|
-
let(:interval){ 100 }
|
7
|
-
let(:name) { "some_sensor" }
|
8
|
-
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
10
|
-
let(:widget_name){ "some_widget" }
|
11
|
-
let(:w){ described_class.new(widget_name) }
|
12
|
-
|
13
|
-
describe "#to_data" do
|
14
|
-
it "should produce PulseMeter::Visualize::Widgets::Area class" do
|
15
|
-
w.to_data.should be_kind_of(PulseMeter::Visualize::Widgets::Area)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#values_label" do
|
20
|
-
it "should set values_label" do
|
21
|
-
w.values_label "some y-axis legend"
|
22
|
-
w.to_data.values_label.should == "some y-axis legend"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#show_last_point" do
|
27
|
-
it "should set show_last_point" do
|
28
|
-
w.show_last_point true
|
29
|
-
w.to_data.show_last_point.should be_true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#timespan" do
|
34
|
-
it "should set timespan" do
|
35
|
-
w.timespan 5
|
36
|
-
w.to_data.timespan.should == 5
|
37
|
-
end
|
38
|
-
it "should raise exception if timespan is negative" do
|
39
|
-
expect{ w.timespan(-1) }.to raise_exception(PulseMeter::Visualize::DSL::BadWidgetTimeSpan)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::DSL::Widgets::Gauge do
|
4
|
-
it_should_behave_like "dsl widget"
|
5
|
-
|
6
|
-
let(:interval){ 100 }
|
7
|
-
let(:name) { "some_sensor" }
|
8
|
-
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
10
|
-
let(:widget_name){ "some_widget" }
|
11
|
-
let(:w){ described_class.new(widget_name) }
|
12
|
-
|
13
|
-
describe "#to_data" do
|
14
|
-
it "should produce PulseMeter::Visualize::Widgets::Gauge class" do
|
15
|
-
w.to_data.should be_kind_of(PulseMeter::Visualize::Widgets::Gauge)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PulseMeter::Visualize::DSL::Widgets::Line do
|
4
|
-
it_should_behave_like "dsl widget"
|
5
|
-
|
6
|
-
let(:interval){ 100 }
|
7
|
-
let(:name) { "some_sensor" }
|
8
|
-
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
10
|
-
let(:widget_name){ "some_widget" }
|
11
|
-
let(:w){ described_class.new(widget_name) }
|
12
|
-
|
13
|
-
describe "#to_data" do
|
14
|
-
it "should produce PulseMeter::Visualize::Widgets::Area class" do
|
15
|
-
w.to_data.should be_kind_of(PulseMeter::Visualize::Widgets::Line)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#values_label" do
|
20
|
-
it "should set values_label" do
|
21
|
-
w.values_label "some y-axis legend"
|
22
|
-
w.to_data.values_label.should == "some y-axis legend"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#show_last_point" do
|
27
|
-
it "should set show_last_point" do
|
28
|
-
w.show_last_point true
|
29
|
-
w.to_data.show_last_point.should be_true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#timespan" do
|
34
|
-
it "should set timespan" do
|
35
|
-
w.timespan 5
|
36
|
-
w.to_data.timespan.should == 5
|
37
|
-
end
|
38
|
-
it "should raise exception if timespan is negative" do
|
39
|
-
expect{ w.timespan(-1) }.to raise_exception(PulseMeter::Visualize::DSL::BadWidgetTimeSpan)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|