pulse-meter 0.1.11 → 0.2.0
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/README.md +9 -18
- data/Rakefile +1 -1
- data/examples/basic.ru +20 -12
- data/examples/full/server.ru +9 -18
- data/examples/minimal/client.rb +2 -1
- data/lib/pulse-meter/version.rb +1 -1
- data/lib/pulse-meter/visualize/dsl/layout.rb +11 -10
- data/lib/pulse-meter/visualize/dsl/page.rb +15 -6
- data/lib/pulse-meter/visualize/layout.rb +4 -7
- data/lib/pulse-meter/visualize/page.rb +2 -2
- data/lib/pulse-meter/visualize/public/js/application.coffee +109 -67
- data/lib/pulse-meter/visualize/public/js/application.js +114 -69
- data/lib/pulse-meter/visualize/sensor.rb +11 -7
- data/lib/pulse-meter/visualize/series_extractor.rb +4 -4
- data/lib/pulse-meter/visualize/views/main.haml +16 -4
- data/lib/pulse-meter/visualize/widget.rb +64 -8
- data/spec/pulse_meter/visualize/dsl/layout_spec.rb +7 -7
- data/spec/pulse_meter/visualize/dsl/page_spec.rb +2 -2
- data/spec/pulse_meter/visualize/layout_spec.rb +7 -8
- data/spec/pulse_meter/visualize/page_spec.rb +55 -85
- data/spec/pulse_meter/visualize/sensor_spec.rb +17 -17
- data/spec/pulse_meter/visualize/series_extractor_spec.rb +3 -3
- data/spec/pulse_meter/visualize/widget_spec.rb +26 -35
- data/spec/pulse_meter/visualizer_spec.rb +2 -2
- metadata +3 -4
- data/lib/pulse-meter/visualize/public/js/highcharts.js +0 -203
@@ -52,9 +52,9 @@ describe PulseMeter::Visualize::DSL::Page do
|
|
52
52
|
|
53
53
|
describe "#chart" do
|
54
54
|
it "should create widget width type :chart" do
|
55
|
-
page.
|
55
|
+
page.line(:some_widget_name)
|
56
56
|
w = page.to_page.widgets.first
|
57
|
-
w.type.should == :
|
57
|
+
w.type.should == :line
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -5,12 +5,12 @@ describe PulseMeter::Visualize::Layout do
|
|
5
5
|
l = PulseMeter::Visualize::DSL::Layout.new
|
6
6
|
l.page "page1" do |p|
|
7
7
|
p.line "w1"
|
8
|
-
p.
|
9
|
-
p.
|
8
|
+
p.line "w2"
|
9
|
+
p.gchart_options({a: 1})
|
10
10
|
end
|
11
11
|
l.page "page2" do |p|
|
12
12
|
p.line "w3"
|
13
|
-
p.
|
13
|
+
p.line "w4"
|
14
14
|
end
|
15
15
|
l.to_layout
|
16
16
|
end
|
@@ -18,8 +18,8 @@ describe PulseMeter::Visualize::Layout do
|
|
18
18
|
describe "#page_infos" do
|
19
19
|
it "should return list of page infos with ids" do
|
20
20
|
layout.page_infos.should == [
|
21
|
-
{title: "page1", id: 1,
|
22
|
-
{title: "page2", id: 2,
|
21
|
+
{title: "page1", id: 1, gchart_options: {a: 1}},
|
22
|
+
{title: "page2", id: 2, gchart_options: {}}
|
23
23
|
]
|
24
24
|
end
|
25
25
|
end
|
@@ -28,10 +28,9 @@ describe PulseMeter::Visualize::Layout do
|
|
28
28
|
it "should return layout options" do
|
29
29
|
ldsl = PulseMeter::Visualize::DSL::Layout.new
|
30
30
|
ldsl.use_utc true
|
31
|
-
ldsl.
|
32
|
-
ldsl.highchart_options({a: 1})
|
31
|
+
ldsl.gchart_options({a: 1})
|
33
32
|
l = ldsl.to_layout
|
34
|
-
l.options.should == {use_utc: true,
|
33
|
+
l.options.should == {use_utc: true, gchart_options: {a: 1}}
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -67,68 +67,49 @@ describe PulseMeter::Visualize::Page do
|
|
67
67
|
it "should generate correct data of single widget" do
|
68
68
|
Timecop.freeze(interval_start + 2 * interval - 1) do
|
69
69
|
page.widget_data(0)[:series].should ==
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
{
|
81
|
-
name: b_sensor.annotation,
|
82
|
-
color: b_color,
|
83
|
-
y: 33
|
84
|
-
}
|
85
|
-
]
|
86
|
-
|
87
|
-
}
|
88
|
-
]
|
70
|
+
{
|
71
|
+
data: [
|
72
|
+
[a_sensor.annotation, 12],
|
73
|
+
[b_sensor.annotation, 33]
|
74
|
+
],
|
75
|
+
options: [
|
76
|
+
{color: a_color},
|
77
|
+
{color: b_color}
|
78
|
+
]
|
79
|
+
}
|
89
80
|
page.widget_data(1)[:series].should ==
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
}]
|
81
|
+
{
|
82
|
+
titles: [a_sensor.annotation, b_sensor.annotation],
|
83
|
+
rows: [[interval_start.to_i * 1000, 12, 33]],
|
84
|
+
options: [
|
85
|
+
{color: a_color},
|
86
|
+
{color: b_color}
|
87
|
+
]
|
88
|
+
}
|
99
89
|
end
|
100
90
|
|
101
91
|
Timecop.freeze(interval_start + 2 * interval - 1) do
|
102
92
|
page.widget_data(0, timespan: 0)[:series].should ==
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
{
|
114
|
-
name: b_sensor.annotation,
|
115
|
-
color: b_color,
|
116
|
-
y: 33
|
117
|
-
}
|
118
|
-
]
|
119
|
-
|
120
|
-
}
|
121
|
-
]
|
93
|
+
{
|
94
|
+
data: [
|
95
|
+
[a_sensor.annotation, 12],
|
96
|
+
[b_sensor.annotation, 33]
|
97
|
+
],
|
98
|
+
options: [
|
99
|
+
{color: a_color},
|
100
|
+
{color: b_color}
|
101
|
+
]
|
102
|
+
}
|
122
103
|
page.widget_data(1, timespan: 1)[:series].should ==
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
104
|
+
{
|
105
|
+
titles: [a_sensor.annotation, b_sensor.annotation],
|
106
|
+
rows: [],
|
107
|
+
options: [
|
108
|
+
{color: a_color},
|
109
|
+
{color: b_color}
|
110
|
+
]
|
111
|
+
}
|
112
|
+
|
132
113
|
end
|
133
114
|
|
134
115
|
|
@@ -146,38 +127,27 @@ describe PulseMeter::Visualize::Page do
|
|
146
127
|
Timecop.freeze(interval_start + 2 * interval - 1) do
|
147
128
|
|
148
129
|
page.widget_datas.map{|h| h[:series]}.should == [
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
],
|
168
|
-
[{
|
169
|
-
name: a_sensor.annotation,
|
170
|
-
color: a_color,
|
171
|
-
data: [{x: interval_start.to_i * 1000, y: 12}]
|
172
|
-
}, {
|
173
|
-
name: b_sensor.annotation,
|
174
|
-
color: b_color,
|
175
|
-
data: [{x: interval_start.to_i * 1000, y: 33}]
|
176
|
-
}]
|
130
|
+
{
|
131
|
+
data: [
|
132
|
+
[a_sensor.annotation, 12],
|
133
|
+
[b_sensor.annotation, 33]
|
134
|
+
],
|
135
|
+
options: [
|
136
|
+
{color: a_color},
|
137
|
+
{color: b_color}
|
138
|
+
]
|
139
|
+
},
|
140
|
+
{
|
141
|
+
titles: [a_sensor.annotation, b_sensor.annotation],
|
142
|
+
rows: [[interval_start.to_i * 1000, 12, 33]],
|
143
|
+
options: [
|
144
|
+
{color: a_color},
|
145
|
+
{color: b_color}
|
146
|
+
]
|
147
|
+
}
|
177
148
|
]
|
178
149
|
end
|
179
150
|
|
180
|
-
|
181
151
|
end
|
182
152
|
end
|
183
153
|
end
|
@@ -16,14 +16,14 @@ describe PulseMeter::Visualize::Sensor do
|
|
16
16
|
describe '#last_value' do
|
17
17
|
context "when sensor does not exist" do
|
18
18
|
it "should raise RestoreError" do
|
19
|
-
expect{ bad_sensor.last_value }.to raise_exception(PulseMeter::RestoreError)
|
19
|
+
expect{ bad_sensor.last_value(Time.now) }.to raise_exception(PulseMeter::RestoreError)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
|
24
24
|
context "when sensor has no data" do
|
25
25
|
it "should return nil" do
|
26
|
-
sensor.last_value.should be_nil
|
26
|
+
sensor.last_value(Time.now).should be_nil
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -34,7 +34,7 @@ describe PulseMeter::Visualize::Sensor do
|
|
34
34
|
real_sensor.event(101)
|
35
35
|
end
|
36
36
|
Timecop.freeze(interval_start+1) do
|
37
|
-
sensor.last_value(true).should == 101
|
37
|
+
sensor.last_value(Time.now, true).should == 101
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -45,10 +45,10 @@ describe PulseMeter::Visualize::Sensor do
|
|
45
45
|
real_sensor.event(101)
|
46
46
|
end
|
47
47
|
Timecop.freeze(interval_start + 1) do
|
48
|
-
sensor.last_value.should be_nil
|
48
|
+
sensor.last_value(Time.now).should be_nil
|
49
49
|
end
|
50
50
|
Timecop.freeze(interval_start + interval + 1) do
|
51
|
-
sensor.last_value.should == 101
|
51
|
+
sensor.last_value(Time.now).should == 101
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -60,7 +60,7 @@ describe PulseMeter::Visualize::Sensor do
|
|
60
60
|
|
61
61
|
context "when sensor does not exist" do
|
62
62
|
it "should raise RestoreError" do
|
63
|
-
expect{ bad_sensor.last_point_data }.to raise_exception(PulseMeter::RestoreError)
|
63
|
+
expect{ bad_sensor.last_point_data(Time.now) }.to raise_exception(PulseMeter::RestoreError)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -69,10 +69,10 @@ describe PulseMeter::Visualize::Sensor do
|
|
69
69
|
real_sensor.event(101)
|
70
70
|
end
|
71
71
|
Timecop.freeze(interval_start + 1) do
|
72
|
-
sensor.last_point_data(true).should == {name: annotation, y: 101}
|
73
|
-
sensor.last_point_data.should == {name: annotation, y: nil}
|
74
|
-
sensor_with_color.last_point_data(true).should == {name: annotation, y: 101, color: color}
|
75
|
-
sensor_with_color.last_point_data.should == {name: annotation, y: nil, color: color}
|
72
|
+
sensor.last_point_data(Time.now, true).should == [{name: annotation, y: 101}]
|
73
|
+
sensor.last_point_data(Time.now).should == [{name: annotation, y: nil}]
|
74
|
+
sensor_with_color.last_point_data(Time.now, true).should == [{name: annotation, y: 101, color: color}]
|
75
|
+
sensor_with_color.last_point_data(Time.now).should == [{name: annotation, y: nil, color: color}]
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -89,7 +89,7 @@ describe PulseMeter::Visualize::Sensor do
|
|
89
89
|
|
90
90
|
context "when sensor does not exist" do
|
91
91
|
it "should raise RestoreError" do
|
92
|
-
expect{ bad_sensor.timeline_data(interval) }.to raise_exception(PulseMeter::RestoreError)
|
92
|
+
expect{ bad_sensor.timeline_data(Time.now, interval) }.to raise_exception(PulseMeter::RestoreError)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -97,21 +97,21 @@ describe PulseMeter::Visualize::Sensor do
|
|
97
97
|
describe "returned value" do
|
98
98
|
it "should contain sensor annotation" do
|
99
99
|
Timecop.freeze(interval_start + interval + 1) do
|
100
|
-
sensor.timeline_data(interval)[:name].should == annotation
|
100
|
+
sensor.timeline_data(Time.now, interval).first[:name].should == annotation
|
101
101
|
end
|
102
102
|
end
|
103
103
|
it "should contain sensor color" do
|
104
104
|
Timecop.freeze(interval_start + interval + 1) do
|
105
|
-
sensor_with_color.timeline_data(interval)[:color].should == color
|
105
|
+
sensor_with_color.timeline_data(Time.now, interval).first[:color].should == color
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should contain [interval_start, value] pairs for each interval" do
|
110
110
|
Timecop.freeze(interval_start + interval + 1) do
|
111
|
-
data = sensor.timeline_data(interval * 2)
|
112
|
-
data[:data].should == [{x: interval_start.to_i * 1000, y: 101}]
|
113
|
-
data = sensor.timeline_data(interval * 2, true)
|
114
|
-
data[:data].should == [{x: interval_start.to_i * 1000, y: 101}, {x: (interval_start + interval).to_i * 1000, y: 55}]
|
111
|
+
data = sensor.timeline_data(Time.now, interval * 2)
|
112
|
+
data.first[:data].should == [{x: interval_start.to_i * 1000, y: 101}]
|
113
|
+
data = sensor.timeline_data(Time.now, interval * 2, true)
|
114
|
+
data.first[:data].should == [{x: interval_start.to_i * 1000, y: 101}, {x: (interval_start + interval).to_i * 1000, y: 55}]
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -25,7 +25,7 @@ describe PulseMeter::Visualize::SeriesExtractor do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should create point data correctly" do
|
28
|
-
extractor.point_data(123).should == {y: 123, name: 'simple sensor'}
|
28
|
+
extractor.point_data(123).should == [{y: 123, name: 'simple sensor'}]
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should create timeline data correctly" do
|
@@ -33,10 +33,10 @@ describe PulseMeter::Visualize::SeriesExtractor do
|
|
33
33
|
PulseMeter::SensorData.new(Time.at(1), 11),
|
34
34
|
PulseMeter::SensorData.new(Time.at(2), "22")
|
35
35
|
]
|
36
|
-
extractor.series_data(tl_data).should == {
|
36
|
+
extractor.series_data(tl_data).should == [{
|
37
37
|
name: 'simple sensor',
|
38
38
|
data: [{x: 1000, y: 11}, {x: 2000, y: 22}]
|
39
|
-
}
|
39
|
+
}]
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
@@ -30,7 +30,7 @@ describe PulseMeter::Visualize::Widget do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
let(:widgets) do
|
33
|
-
[:line, :
|
33
|
+
[:line, :area, :pie].each_with_object({}) do |type, h|
|
34
34
|
w = PulseMeter::Visualize::DSL::Widget.new(type, widget_name)
|
35
35
|
add_widget_settings(w)
|
36
36
|
h[type] = w.to_widget
|
@@ -66,20 +66,17 @@ describe PulseMeter::Visualize::Widget do
|
|
66
66
|
it "should contain valid pie series" do
|
67
67
|
|
68
68
|
Timecop.freeze(@current_time) do
|
69
|
-
widgets[:pie].data[:series].should ==
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
}]
|
81
|
-
|
82
|
-
}]
|
69
|
+
widgets[:pie].data[:series].should ==
|
70
|
+
{
|
71
|
+
data: [
|
72
|
+
[a_sensor.annotation, 12],
|
73
|
+
[b_sensor.annotation, 33]
|
74
|
+
],
|
75
|
+
options: [
|
76
|
+
{color: a_color},
|
77
|
+
{color: b_color}
|
78
|
+
]
|
79
|
+
}
|
83
80
|
end
|
84
81
|
|
85
82
|
end
|
@@ -90,34 +87,28 @@ describe PulseMeter::Visualize::Widget do
|
|
90
87
|
|
91
88
|
Timecop.freeze(@current_time) do
|
92
89
|
|
93
|
-
[:line, :
|
90
|
+
[:line, :area].each do |type|
|
94
91
|
|
95
92
|
widget = widgets[type]
|
96
|
-
widget.data[:series].should ==
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
93
|
+
widget.data[:series].should ==
|
94
|
+
{
|
95
|
+
titles: [a_sensor.annotation, b_sensor.annotation],
|
96
|
+
rows: [[interval_start.to_i * 1000, 12, 33]],
|
97
|
+
options: [
|
98
|
+
{color: a_color},
|
99
|
+
{color: b_color}
|
100
|
+
]
|
101
|
+
}
|
105
102
|
end
|
106
103
|
end
|
107
104
|
end
|
108
105
|
|
109
106
|
it "should accept custom timespan" do
|
110
107
|
Timecop.freeze(@current_time + interval) do
|
111
|
-
[:line, :
|
108
|
+
[:line, :area].each do |type|
|
112
109
|
widget = widgets[type]
|
113
|
-
widget.data(timespan: timespan)[:series].
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
widget.data(timespan: timespan + interval)[:series].each do |s|
|
118
|
-
s[:data].size.should == 2
|
119
|
-
end
|
120
|
-
|
110
|
+
widget.data(timespan: timespan)[:series][:rows].size.should == 1
|
111
|
+
widget.data(timespan: timespan + interval)[:series][:rows].size.should == 2
|
121
112
|
end
|
122
113
|
end
|
123
114
|
end
|
@@ -128,4 +119,4 @@ describe PulseMeter::Visualize::Widget do
|
|
128
119
|
end
|
129
120
|
|
130
121
|
end
|
131
|
-
end
|
122
|
+
end
|
@@ -8,7 +8,7 @@ describe PulseMeter::Visualizer do
|
|
8
8
|
l.title "My Gauges"
|
9
9
|
|
10
10
|
l.page "Dashboard" do |p|
|
11
|
-
p.
|
11
|
+
p.line :convertion do |c|
|
12
12
|
c.sensor :adv_clicks, color: :green
|
13
13
|
c.sensor :adv_shows, color: :red
|
14
14
|
end
|
@@ -23,7 +23,7 @@ describe PulseMeter::Visualizer do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
l.page "Request stats" do |p|
|
26
|
-
p.
|
26
|
+
p.line :rph_total, sensor: :rph_total
|
27
27
|
p.line :rph_main_page, sensor: :rph_main_page
|
28
28
|
p.line :request_time_p95_hour
|
29
29
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulse-meter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gon-sinatra
|
@@ -360,7 +360,6 @@ files:
|
|
360
360
|
- lib/pulse-meter/visualize/public/js/application.js
|
361
361
|
- lib/pulse-meter/visualize/public/js/backbone-min.js
|
362
362
|
- lib/pulse-meter/visualize/public/js/bootstrap.js
|
363
|
-
- lib/pulse-meter/visualize/public/js/highcharts.js
|
364
363
|
- lib/pulse-meter/visualize/public/js/jquery-1.7.2.min.js
|
365
364
|
- lib/pulse-meter/visualize/public/js/json2.js
|
366
365
|
- lib/pulse-meter/visualize/public/js/underscore-min.js
|
@@ -424,7 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
424
423
|
version: '0'
|
425
424
|
segments:
|
426
425
|
- 0
|
427
|
-
hash:
|
426
|
+
hash: 2820697990026524466
|
428
427
|
requirements: []
|
429
428
|
rubyforge_project:
|
430
429
|
rubygems_version: 1.8.24
|