pulse_meter_visualizer 0.4.20 → 0.4.21
Sign up to get free protection for your applications and to get access to all the features.
- data/pulse_meter_visualizer.gemspec +2 -2
- data/spec/pulse_meter/visualize/app_spec.rb +3 -3
- data/spec/pulse_meter/visualize/dsl/layout_spec.rb +19 -19
- data/spec/pulse_meter/visualize/dsl/page_spec.rb +18 -18
- data/spec/pulse_meter/visualize/dsl/sensor_spec.rb +6 -6
- data/spec/pulse_meter/visualize/dsl/widgets/area_spec.rb +10 -10
- data/spec/pulse_meter/visualize/dsl/widgets/gauge_spec.rb +3 -3
- data/spec/pulse_meter/visualize/dsl/widgets/line_spec.rb +10 -10
- data/spec/pulse_meter/visualize/dsl/widgets/pie_spec.rb +7 -7
- data/spec/pulse_meter/visualize/dsl/widgets/table_spec.rb +8 -8
- data/spec/pulse_meter/visualize/layout_spec.rb +11 -11
- data/spec/pulse_meter/visualize/page_spec.rb +17 -13
- data/spec/pulse_meter/visualize/sensor_spec.rb +24 -24
- data/spec/pulse_meter/visualize/series_extractor_spec.rb +15 -15
- data/spec/pulse_meter/visualize/widgets/gauge_spec.rb +9 -9
- data/spec/pulse_meter/visualize/widgets/pie_spec.rb +9 -8
- data/spec/pulse_meter/visualizer_spec.rb +3 -3
- data/spec/shared_examples/dsl_widget.rb +30 -30
- data/spec/shared_examples/widget.rb +16 -15
- metadata +54 -9
- checksums.yaml +0 -15
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
15
|
gem.name = "pulse_meter_visualizer"
|
16
16
|
gem.require_paths = ["lib"]
|
17
|
-
gem.version = "0.4.
|
17
|
+
gem.version = "0.4.21"
|
18
18
|
|
19
19
|
gem.add_runtime_dependency('pulse_meter_core')
|
20
20
|
gem.add_runtime_dependency('gon-sinatra')
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |gem|
|
|
32
32
|
gem.add_development_dependency('rake')
|
33
33
|
gem.add_development_dependency('rb-fsevent')
|
34
34
|
gem.add_development_dependency('redcarpet')
|
35
|
-
gem.add_development_dependency('rspec')
|
35
|
+
gem.add_development_dependency('rspec', '~> 3.0')
|
36
36
|
gem.add_development_dependency('simplecov')
|
37
37
|
gem.add_development_dependency('sprockets')
|
38
38
|
gem.add_development_dependency('timecop')
|
@@ -16,12 +16,12 @@ describe PulseMeter::Visualize::App do
|
|
16
16
|
|
17
17
|
it "responds to /" do
|
18
18
|
get '/'
|
19
|
-
last_response.
|
20
|
-
last_response.body.
|
19
|
+
expect(last_response).to be_ok
|
20
|
+
expect(last_response.body).to include("Foo meters")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "responds to /application.js" do
|
24
24
|
get '/js/application.js'
|
25
|
-
last_response.
|
25
|
+
expect(last_response).to be_ok
|
26
26
|
end
|
27
27
|
end
|
@@ -7,17 +7,17 @@ describe PulseMeter::Visualize::DSL::Layout do
|
|
7
7
|
let(:layout){ described_class.new }
|
8
8
|
|
9
9
|
describe '.new' do
|
10
|
-
it "
|
10
|
+
it "initializes pages, title, use_utc, gchart_options" do
|
11
11
|
l = layout.to_data
|
12
|
-
l.title.
|
13
|
-
l.pages.
|
14
|
-
l.use_utc.
|
15
|
-
l.gchart_options.
|
12
|
+
expect(l.title).to eq(PulseMeter::Visualize::DSL::Layout::DEFAULT_TITLE)
|
13
|
+
expect(l.pages).to eq([])
|
14
|
+
expect(l.use_utc).to eq(false)
|
15
|
+
expect(l.gchart_options).to eq({})
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#page" do
|
20
|
-
it "
|
20
|
+
it "adds page constructed by block to pages" do
|
21
21
|
layout.page "My Foo Page" do |p|
|
22
22
|
p.pie "foo_widget", sensor: sensor_name
|
23
23
|
p.line "bar_widget" do |w|
|
@@ -25,39 +25,39 @@ describe PulseMeter::Visualize::DSL::Layout do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
l = layout.to_data
|
28
|
-
l.pages.size.
|
28
|
+
expect(l.pages.size).to eq(1)
|
29
29
|
p = l.pages.first
|
30
|
-
p.title.
|
31
|
-
p.widgets.size.
|
32
|
-
p.widgets.first.title.
|
33
|
-
p.widgets.last.title.
|
30
|
+
expect(p.title).to eq("My Foo Page")
|
31
|
+
expect(p.widgets.size).to eq(2)
|
32
|
+
expect(p.widgets.first.title).to eq("foo_widget")
|
33
|
+
expect(p.widgets.last.title).to eq("bar_widget")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#title" do
|
38
|
-
it "
|
38
|
+
it "sets layout title" do
|
39
39
|
layout.title "Foo Title"
|
40
|
-
layout.to_data.title.
|
40
|
+
expect(layout.to_data.title).to eq('Foo Title')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "#use_utc" do
|
45
|
-
it "
|
45
|
+
it "sets use_utc" do
|
46
46
|
layout.use_utc false
|
47
|
-
layout.to_data.use_utc.
|
47
|
+
expect(layout.to_data.use_utc).to eq(false)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#gchart_options" do
|
52
|
-
it "
|
52
|
+
it "sets gchart_options" do
|
53
53
|
layout.gchart_options({b: 1})
|
54
|
-
layout.to_data.gchart_options.
|
54
|
+
expect(layout.to_data.gchart_options).to eq({b: 1})
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "#to_data" do
|
59
|
-
it "
|
60
|
-
layout.to_data.
|
59
|
+
it "converts layout dsl data to Visualize::Layout" do
|
60
|
+
expect(layout.to_data).to be_kind_of(PulseMeter::Visualize::Layout)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -8,25 +8,25 @@ describe PulseMeter::Visualize::DSL::Page do
|
|
8
8
|
let(:page){ PulseMeter::Visualize::DSL::Page.new(title) }
|
9
9
|
|
10
10
|
describe '.new' do
|
11
|
-
it "
|
11
|
+
it "initializes title and widgets" do
|
12
12
|
p = page.to_data
|
13
|
-
p.title.
|
14
|
-
p.widgets.
|
13
|
+
expect(p.title).to eq(title)
|
14
|
+
expect(p.widgets).to eq([])
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
[:area, :line, :table, :pie, :gauge].each do |widget_type|
|
19
19
|
|
20
20
|
describe "##{widget_type}" do
|
21
|
-
it "
|
21
|
+
it "adds #{widget_type} widget initialized by args to widgets" do
|
22
22
|
page.send(widget_type, :some_widget_name, sensor: sensor_name, width: 7)
|
23
23
|
w = page.to_data.widgets.first
|
24
|
-
w.width.
|
25
|
-
w.title.
|
26
|
-
w.sensors.first.name.
|
24
|
+
expect(w.width).to eq(7)
|
25
|
+
expect(w.title).to eq("some_widget_name")
|
26
|
+
expect(w.sensors.first.name).to eq(sensor_name)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "adds #{widget_type} widget initialized by block" do
|
30
30
|
page.send(widget_type, :some_widget_name) do |w|
|
31
31
|
w.sensor(sensor_name)
|
32
32
|
w.sensor(sensor_name)
|
@@ -34,27 +34,27 @@ describe PulseMeter::Visualize::DSL::Page do
|
|
34
34
|
w.width 7
|
35
35
|
end
|
36
36
|
w = page.to_data.widgets.first
|
37
|
-
w.type.
|
38
|
-
w.width.
|
39
|
-
w.title.
|
40
|
-
w.sensors.size.
|
41
|
-
w.sensors.first.name.
|
42
|
-
w.sensors.last.name.
|
37
|
+
expect(w.type).to eq(widget_type.to_s)
|
38
|
+
expect(w.width).to eq(7)
|
39
|
+
expect(w.title).to eq("foo_widget")
|
40
|
+
expect(w.sensors.size).to eq(2)
|
41
|
+
expect(w.sensors.first.name).to eq(sensor_name)
|
42
|
+
expect(w.sensors.last.name).to eq(sensor_name)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "#title" do
|
49
|
-
it "
|
49
|
+
it "sets page title" do
|
50
50
|
page.title "Foo Title"
|
51
|
-
page.to_data.title.
|
51
|
+
expect(page.to_data.title).to eq('Foo Title')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "#to_data" do
|
56
|
-
it "
|
57
|
-
page.to_data.
|
56
|
+
it "converts DSL data to Visualize::Page" do
|
57
|
+
expect(page.to_data).to be_kind_of(PulseMeter::Visualize::Page)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -6,23 +6,23 @@ describe PulseMeter::Visualize::DSL::Sensor do
|
|
6
6
|
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
7
7
|
|
8
8
|
describe '.new' do
|
9
|
-
it "
|
10
|
-
described_class.new(name).to_data.name.to_s.
|
9
|
+
it "saves passed name and create Visualize::Sensor with it" do
|
10
|
+
expect(described_class.new(name).to_data.name.to_s).to eq(name)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#process_args' do
|
15
|
-
it "
|
15
|
+
it "passes args transparently to Visualize::Sensor" do
|
16
16
|
s = described_class.new(name)
|
17
17
|
s.process_args color: :red
|
18
|
-
s.to_data.color.to_s.
|
18
|
+
expect(s.to_data.color.to_s).to eq('red')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#to_data' do
|
23
23
|
# actually tested above
|
24
|
-
it "
|
25
|
-
described_class.new(name).to_data.
|
24
|
+
it "converts dsl data to sensor" do
|
25
|
+
expect(described_class.new(name).to_data).to be_kind_of(PulseMeter::Visualize::Sensor)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -6,36 +6,36 @@ describe PulseMeter::Visualize::DSL::Widgets::Area do
|
|
6
6
|
let(:interval){ 100 }
|
7
7
|
let(:name) { "some_sensor" }
|
8
8
|
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
9
|
+
|
10
10
|
let(:widget_name){ "some_widget" }
|
11
11
|
let(:w){ described_class.new(widget_name) }
|
12
12
|
|
13
13
|
describe "#to_data" do
|
14
|
-
it "
|
15
|
-
w.to_data.
|
14
|
+
it "produces PulseMeter::Visualize::Widgets::Area class" do
|
15
|
+
expect(w.to_data).to be_kind_of(PulseMeter::Visualize::Widgets::Area)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#values_label" do
|
20
|
-
it "
|
20
|
+
it "sets values_label" do
|
21
21
|
w.values_label "some y-axis legend"
|
22
|
-
w.to_data.values_label.
|
22
|
+
expect(w.to_data.values_label).to eq("some y-axis legend")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#show_last_point" do
|
27
|
-
it "
|
27
|
+
it "sets show_last_point" do
|
28
28
|
w.show_last_point true
|
29
|
-
w.to_data.show_last_point.
|
29
|
+
expect(w.to_data.show_last_point).to eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "#timespan" do
|
34
|
-
it "
|
34
|
+
it "sets timespan" do
|
35
35
|
w.timespan 5
|
36
|
-
w.to_data.timespan.
|
36
|
+
expect(w.to_data.timespan).to eq(5)
|
37
37
|
end
|
38
|
-
it "
|
38
|
+
it "raises exception if timespan is negative" do
|
39
39
|
expect{ w.timespan(-1) }.to raise_exception(PulseMeter::Visualize::DSL::BadWidgetTimeSpan)
|
40
40
|
end
|
41
41
|
end
|
@@ -6,13 +6,13 @@ describe PulseMeter::Visualize::DSL::Widgets::Gauge do
|
|
6
6
|
let(:interval){ 100 }
|
7
7
|
let(:name) { "some_sensor" }
|
8
8
|
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
9
|
+
|
10
10
|
let(:widget_name){ "some_widget" }
|
11
11
|
let(:w){ described_class.new(widget_name) }
|
12
12
|
|
13
13
|
describe "#to_data" do
|
14
|
-
it "
|
15
|
-
w.to_data.
|
14
|
+
it "produces PulseMeter::Visualize::Widgets::Gauge class" do
|
15
|
+
expect(w.to_data).to be_kind_of(PulseMeter::Visualize::Widgets::Gauge)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -6,36 +6,36 @@ describe PulseMeter::Visualize::DSL::Widgets::Line do
|
|
6
6
|
let(:interval){ 100 }
|
7
7
|
let(:name) { "some_sensor" }
|
8
8
|
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
9
|
+
|
10
10
|
let(:widget_name){ "some_widget" }
|
11
11
|
let(:w){ described_class.new(widget_name) }
|
12
12
|
|
13
13
|
describe "#to_data" do
|
14
|
-
it "
|
15
|
-
w.to_data.
|
14
|
+
it "produces PulseMeter::Visualize::Widgets::Area class" do
|
15
|
+
expect(w.to_data).to be_kind_of(PulseMeter::Visualize::Widgets::Line)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#values_label" do
|
20
|
-
it "
|
20
|
+
it "sets values_label" do
|
21
21
|
w.values_label "some y-axis legend"
|
22
|
-
w.to_data.values_label.
|
22
|
+
expect(w.to_data.values_label).to eq("some y-axis legend")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#show_last_point" do
|
27
|
-
it "
|
27
|
+
it "sets show_last_point" do
|
28
28
|
w.show_last_point true
|
29
|
-
w.to_data.show_last_point.
|
29
|
+
expect(w.to_data.show_last_point).to eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "#timespan" do
|
34
|
-
it "
|
34
|
+
it "sets timespan" do
|
35
35
|
w.timespan 5
|
36
|
-
w.to_data.timespan.
|
36
|
+
expect(w.to_data.timespan).to eq(5)
|
37
37
|
end
|
38
|
-
it "
|
38
|
+
it "raises exception if timespan is negative" do
|
39
39
|
expect{ w.timespan(-1) }.to raise_exception(PulseMeter::Visualize::DSL::BadWidgetTimeSpan)
|
40
40
|
end
|
41
41
|
end
|
@@ -6,27 +6,27 @@ describe PulseMeter::Visualize::DSL::Widgets::Pie do
|
|
6
6
|
let(:interval){ 100 }
|
7
7
|
let(:name) { "some_sensor" }
|
8
8
|
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
9
|
+
|
10
10
|
let(:widget_name){ "some_widget" }
|
11
11
|
let(:w){ described_class.new(widget_name) }
|
12
12
|
|
13
13
|
describe "#to_data" do
|
14
|
-
it "
|
15
|
-
w.to_data.
|
14
|
+
it "produces PulseMeter::Visualize::Widgets::Pie class" do
|
15
|
+
expect(w.to_data).to be_kind_of(PulseMeter::Visualize::Widgets::Pie)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#values_label" do
|
20
|
-
it "
|
20
|
+
it "sets values_label" do
|
21
21
|
w.values_label "some y-axis legend"
|
22
|
-
w.to_data.values_label.
|
22
|
+
expect(w.to_data.values_label).to eq("some y-axis legend")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#show_last_point" do
|
27
|
-
it "
|
27
|
+
it "sets show_last_point" do
|
28
28
|
w.show_last_point true
|
29
|
-
w.to_data.show_last_point.
|
29
|
+
expect(w.to_data.show_last_point).to eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -6,29 +6,29 @@ describe PulseMeter::Visualize::DSL::Widgets::Table do
|
|
6
6
|
let(:interval){ 100 }
|
7
7
|
let(:name) { "some_sensor" }
|
8
8
|
let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(name, :ttl => 1000, :interval => interval) }
|
9
|
-
|
9
|
+
|
10
10
|
let(:widget_name){ "some_widget" }
|
11
11
|
let(:w){ described_class.new(widget_name) }
|
12
12
|
|
13
13
|
describe "#to_data" do
|
14
|
-
it "
|
15
|
-
w.to_data.
|
14
|
+
it "produces PulseMeter::Visualize::Widgets::Area class" do
|
15
|
+
expect(w.to_data).to be_kind_of(PulseMeter::Visualize::Widgets::Table)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#show_last_point" do
|
20
|
-
it "
|
20
|
+
it "sets show_last_point" do
|
21
21
|
w.show_last_point true
|
22
|
-
w.to_data.show_last_point.
|
22
|
+
expect(w.to_data.show_last_point).to eq(true)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#timespan" do
|
27
|
-
it "
|
27
|
+
it "sets timespan" do
|
28
28
|
w.timespan 5
|
29
|
-
w.to_data.timespan.
|
29
|
+
expect(w.to_data.timespan).to eq(5)
|
30
30
|
end
|
31
|
-
it "
|
31
|
+
it "raises exception if timespan is negative" do
|
32
32
|
expect{ w.timespan(-1) }.to raise_exception(PulseMeter::Visualize::DSL::BadWidgetTimeSpan)
|
33
33
|
end
|
34
34
|
end
|
@@ -16,38 +16,38 @@ describe PulseMeter::Visualize::Layout do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#page_infos" do
|
19
|
-
it "
|
20
|
-
layout.page_infos.
|
19
|
+
it "returns list of page infos with ids" do
|
20
|
+
expect(layout.page_infos).to eq([
|
21
21
|
{title: "page1", id: 1, gchart_options: {a: 1}},
|
22
22
|
{title: "page2", id: 2, gchart_options: {}}
|
23
|
-
]
|
23
|
+
])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "#options" do
|
28
|
-
it "
|
28
|
+
it "returns layout options" do
|
29
29
|
ldsl = PulseMeter::Visualize::DSL::Layout.new
|
30
30
|
ldsl.use_utc true
|
31
31
|
ldsl.gchart_options({a: 1})
|
32
32
|
l = ldsl.to_data
|
33
|
-
l.options.
|
33
|
+
expect(l.options).to eq({use_utc: true, gchart_options: {a: 1}})
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#widget" do
|
38
|
-
it "
|
38
|
+
it "returns data for correct widget" do
|
39
39
|
w = layout.widget(1, 0)
|
40
|
-
w.
|
40
|
+
expect(w).to include(id: 1, title: "w3")
|
41
41
|
w = layout.widget(0, 1, timespan: 123)
|
42
|
-
w.
|
42
|
+
expect(w).to include(id: 2, title: "w2")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#widgets" do
|
47
|
-
it "
|
47
|
+
it "returns data for correct widgets of a page" do
|
48
48
|
datas = layout.widgets(1)
|
49
|
-
datas[0].
|
50
|
-
datas[1].
|
49
|
+
expect(datas[0]).to include(id: 1, title: "w3")
|
50
|
+
expect(datas[1]).to include(id: 2, title: "w4")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|