fnordmetric 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/VERSION +1 -1
- data/doc/preview1.png +0 -0
- data/doc/preview2.png +0 -0
- data/doc/ulm_stats.rb +622 -0
- data/doc/version +1 -0
- data/fnordmetric.gemspec +16 -38
- data/haml/app.haml +12 -5
- data/lib/fnordmetric.rb +3 -0
- data/lib/fnordmetric/app.rb +19 -10
- data/lib/fnordmetric/bars_widget.rb +26 -0
- data/lib/fnordmetric/context.rb +3 -3
- data/lib/fnordmetric/gauge.rb +20 -0
- data/lib/fnordmetric/gauge_calculations.rb +28 -4
- data/lib/fnordmetric/gauge_modifiers.rb +39 -6
- data/lib/fnordmetric/logger.rb +19 -0
- data/lib/fnordmetric/numbers_widget.rb +5 -15
- data/lib/fnordmetric/pie_widget.rb +23 -0
- data/lib/fnordmetric/standalone.rb +1 -1
- data/lib/fnordmetric/timeline_widget.rb +16 -23
- data/lib/fnordmetric/toplist_widget.rb +25 -0
- data/lib/fnordmetric/widget.rb +3 -3
- data/pub/{fnordmetric/fnordmetric.css → fnordmetric.css} +46 -36
- data/pub/fnordmetric.js +1069 -0
- data/pub/loader.gif +0 -0
- data/pub/{highcharts → vendor}/highcharts.js +0 -0
- data/pub/{jquery-1.6.1.min.js → vendor/jquery-1.6.1.min.js} +0 -0
- data/readme.rdoc +228 -311
- data/spec/app_spec.rb +63 -3
- data/spec/gauge_modifiers_spec.rb +157 -2
- data/spec/gauge_spec.rb +143 -12
- data/spec/widget_spec.rb +18 -18
- metadata +33 -58
- data/.document +0 -5
- data/_spec/app_spec.rb +0 -178
- data/_spec/cache_spec.rb +0 -53
- data/_spec/combine_metric_spec.rb +0 -19
- data/_spec/core_spec.rb +0 -50
- data/_spec/count_metric_spec.rb +0 -32
- data/_spec/dashboard_spec.rb +0 -67
- data/_spec/event_spec.rb +0 -46
- data/_spec/metric_spec.rb +0 -118
- data/_spec/report_spec.rb +0 -87
- data/_spec/sum_metric_spec.rb +0 -33
- data/_spec/widget_spec.rb +0 -107
- data/doc/example_server.rb +0 -56
- data/doc/import_dump.rb +0 -26
- data/pub/fnordmetric/fnordmetric.js +0 -543
- data/pub/fnordmetric/widget_numbers.js +0 -71
- data/pub/fnordmetric/widget_timeline.css +0 -0
- data/pub/fnordmetric/widget_timeline.js +0 -110
- data/pub/highcharts/adapters/mootools-adapter.js +0 -12
- data/pub/highcharts/adapters/mootools-adapter.src.js +0 -243
- data/pub/highcharts/adapters/prototype-adapter.js +0 -14
- data/pub/highcharts/adapters/prototype-adapter.src.js +0 -284
- data/pub/highcharts/highcharts.src.js +0 -11103
- data/pub/highcharts/modules/exporting.js +0 -22
- data/pub/highcharts/modules/exporting.src.js +0 -703
- data/pub/highcharts/themes/dark-blue.js +0 -268
- data/pub/highcharts/themes/dark-green.js +0 -268
- data/pub/highcharts/themes/gray.js +0 -262
- data/pub/highcharts/themes/grid.js +0 -97
- data/pub/raphael-min.js +0 -8
- data/pub/raphael-utils.js +0 -221
- data/ulm_stats.rb +0 -198
data/spec/widget_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe FnordMetric::Widget do
|
|
41
41
|
|
42
42
|
it "should raise an error if two gauges with different ticks are added" do
|
43
43
|
lambda{
|
44
|
-
widget = FnordMetric::
|
44
|
+
widget = FnordMetric::TimelineWidget.new(
|
45
45
|
:title => "My Widget",
|
46
46
|
:gauges => [@gauge1, @gauge2]
|
47
47
|
)
|
@@ -49,57 +49,57 @@ describe FnordMetric::Widget do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should generate the correct default range for daily graphs without include current" do
|
52
|
-
widget = FnordMetric::
|
52
|
+
widget = FnordMetric::TimelineWidget.new(
|
53
53
|
:title => "My Widget",
|
54
54
|
:include_current => false,
|
55
55
|
:gauges => [@gauge1]
|
56
56
|
)
|
57
57
|
range = widget.default_range(Time.utc(1992,01,13,18,23,23))
|
58
|
-
Time.at(range.last).utc.should == Time.utc(1992,01,
|
59
|
-
Time.at(range.first).utc.should == Time.utc(1991,12,
|
58
|
+
Time.at(range.last).utc.should == Time.utc(1992,01,12,00,00)
|
59
|
+
Time.at(range.first).utc.should == Time.utc(1991,12,13,00,00)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should generate the correct default range for daily graphs with include current" do
|
63
|
-
widget = FnordMetric::
|
63
|
+
widget = FnordMetric::TimelineWidget.new(
|
64
64
|
:title => "My Widget",
|
65
65
|
:gauges => [@gauge1]
|
66
66
|
)
|
67
67
|
range = widget.default_range(Time.utc(1992,01,13,18,23,23))
|
68
|
-
Time.at(range.last).utc.should == Time.utc(1992,01,
|
69
|
-
Time.at(range.first).utc.should == Time.utc(1991,12,
|
68
|
+
Time.at(range.last).utc.should == Time.utc(1992,01,13,00,00)
|
69
|
+
Time.at(range.first).utc.should == Time.utc(1991,12,14,00,00)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should generate the correct default range for hourly graphs with include current" do
|
73
|
-
widget = FnordMetric::
|
73
|
+
widget = FnordMetric::TimelineWidget.new(
|
74
74
|
:title => "My Widget",
|
75
75
|
:gauges => [@gauge2]
|
76
76
|
)
|
77
77
|
range = widget.default_range(Time.utc(1992,01,13,18,23,23))
|
78
|
-
Time.at(range.last).utc.should == Time.utc(1992,01,13,
|
79
|
-
Time.at(range.first).utc.should == Time.utc(1992,01,12,
|
78
|
+
Time.at(range.last).utc.should == Time.utc(1992,01,13,18,00)
|
79
|
+
Time.at(range.first).utc.should == Time.utc(1992,01,12,18,00)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should generate the correct default range for hourly graphs with include current" do
|
83
|
-
widget = FnordMetric::
|
83
|
+
widget = FnordMetric::TimelineWidget.new(
|
84
84
|
:title => "My Widget",
|
85
85
|
:include_current => false,
|
86
86
|
:gauges => [@gauge2]
|
87
87
|
)
|
88
88
|
range = widget.default_range(Time.utc(1992,01,13,18,23,23))
|
89
|
-
Time.at(range.last).utc.should == Time.utc(1992,01,13,
|
90
|
-
Time.at(range.first).utc.should == Time.utc(1992,01,12,
|
89
|
+
Time.at(range.last).utc.should == Time.utc(1992,01,13,17,00)
|
90
|
+
Time.at(range.first).utc.should == Time.utc(1992,01,12,17,00)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should generate the correct ticks" do
|
94
|
-
widget = FnordMetric::
|
94
|
+
widget = FnordMetric::TimelineWidget.new(
|
95
95
|
:title => "My Widget",
|
96
96
|
:gauges => [@gauge2]
|
97
97
|
)
|
98
98
|
Delorean.time_travel_to(Time.utc(1992,01,13,18,23,23)) do
|
99
|
-
Time.at(widget.ticks[0]).should == Time.utc(1992,01,12,
|
100
|
-
Time.at(widget.ticks[1]).should == Time.utc(1992,01,12,
|
101
|
-
Time.at(widget.ticks[-1]).should == Time.utc(1992,01,13,
|
102
|
-
Time.at(widget.ticks[-2]).should == Time.utc(1992,01,13,
|
99
|
+
Time.at(widget.ticks[0]).utc.should == Time.utc(1992,01,12,18,00)
|
100
|
+
Time.at(widget.ticks[1]).utc.should == Time.utc(1992,01,12,19,00)
|
101
|
+
Time.at(widget.ticks[-1]).utc.should == Time.utc(1992,01,13,18,00)
|
102
|
+
Time.at(widget.ticks[-2]).utc.should == Time.utc(1992,01,13,17,00)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: fnordmetric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Asmuth
|
@@ -10,11 +10,12 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-26 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: mongoid
|
18
|
+
prerelease: false
|
18
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
20
|
none: false
|
20
21
|
requirements:
|
@@ -22,10 +23,10 @@ dependencies:
|
|
22
23
|
- !ruby/object:Gem::Version
|
23
24
|
version: 2.2.0
|
24
25
|
type: :runtime
|
25
|
-
prerelease: false
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongo
|
29
|
+
prerelease: false
|
29
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
31
|
none: false
|
31
32
|
requirements:
|
@@ -33,10 +34,10 @@ dependencies:
|
|
33
34
|
- !ruby/object:Gem::Version
|
34
35
|
version: 1.4.0
|
35
36
|
type: :runtime
|
36
|
-
prerelease: false
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: bson_ext
|
40
|
+
prerelease: false
|
40
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
42
|
none: false
|
42
43
|
requirements:
|
@@ -44,10 +45,10 @@ dependencies:
|
|
44
45
|
- !ruby/object:Gem::Version
|
45
46
|
version: 1.4.0
|
46
47
|
type: :runtime
|
47
|
-
prerelease: false
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: sinatra
|
51
|
+
prerelease: false
|
51
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
52
53
|
none: false
|
53
54
|
requirements:
|
@@ -55,10 +56,10 @@ dependencies:
|
|
55
56
|
- !ruby/object:Gem::Version
|
56
57
|
version: 1.2.6
|
57
58
|
type: :runtime
|
58
|
-
prerelease: false
|
59
59
|
version_requirements: *id004
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: redis
|
62
|
+
prerelease: false
|
62
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
63
64
|
none: false
|
64
65
|
requirements:
|
@@ -66,10 +67,10 @@ dependencies:
|
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: 2.2.2
|
68
69
|
type: :runtime
|
69
|
-
prerelease: false
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: eventmachine
|
73
|
+
prerelease: false
|
73
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
74
75
|
none: false
|
75
76
|
requirements:
|
@@ -77,10 +78,10 @@ dependencies:
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: "0"
|
79
80
|
type: :runtime
|
80
|
-
prerelease: false
|
81
81
|
version_requirements: *id006
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: em-hiredis
|
84
|
+
prerelease: false
|
84
85
|
requirement: &id007 !ruby/object:Gem::Requirement
|
85
86
|
none: false
|
86
87
|
requirements:
|
@@ -88,10 +89,10 @@ dependencies:
|
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: "0"
|
90
91
|
type: :runtime
|
91
|
-
prerelease: false
|
92
92
|
version_requirements: *id007
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: json
|
95
|
+
prerelease: false
|
95
96
|
requirement: &id008 !ruby/object:Gem::Requirement
|
96
97
|
none: false
|
97
98
|
requirements:
|
@@ -99,10 +100,10 @@ dependencies:
|
|
99
100
|
- !ruby/object:Gem::Version
|
100
101
|
version: "0"
|
101
102
|
type: :runtime
|
102
|
-
prerelease: false
|
103
103
|
version_requirements: *id008
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: haml
|
106
|
+
prerelease: false
|
106
107
|
requirement: &id009 !ruby/object:Gem::Requirement
|
107
108
|
none: false
|
108
109
|
requirements:
|
@@ -110,10 +111,10 @@ dependencies:
|
|
110
111
|
- !ruby/object:Gem::Version
|
111
112
|
version: "0"
|
112
113
|
type: :runtime
|
113
|
-
prerelease: false
|
114
114
|
version_requirements: *id009
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: rack
|
117
|
+
prerelease: false
|
117
118
|
requirement: &id010 !ruby/object:Gem::Requirement
|
118
119
|
none: false
|
119
120
|
requirements:
|
@@ -121,10 +122,10 @@ dependencies:
|
|
121
122
|
- !ruby/object:Gem::Version
|
122
123
|
version: "0"
|
123
124
|
type: :runtime
|
124
|
-
prerelease: false
|
125
125
|
version_requirements: *id010
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rack-test
|
128
|
+
prerelease: false
|
128
129
|
requirement: &id011 !ruby/object:Gem::Requirement
|
129
130
|
none: false
|
130
131
|
requirements:
|
@@ -132,10 +133,10 @@ dependencies:
|
|
132
133
|
- !ruby/object:Gem::Version
|
133
134
|
version: "0"
|
134
135
|
type: :runtime
|
135
|
-
prerelease: false
|
136
136
|
version_requirements: *id011
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
name: yajl-ruby
|
139
|
+
prerelease: false
|
139
140
|
requirement: &id012 !ruby/object:Gem::Requirement
|
140
141
|
none: false
|
141
142
|
requirements:
|
@@ -143,10 +144,10 @@ dependencies:
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: "0"
|
145
146
|
type: :runtime
|
146
|
-
prerelease: false
|
147
147
|
version_requirements: *id012
|
148
148
|
- !ruby/object:Gem::Dependency
|
149
149
|
name: thin
|
150
|
+
prerelease: false
|
150
151
|
requirement: &id013 !ruby/object:Gem::Requirement
|
151
152
|
none: false
|
152
153
|
requirements:
|
@@ -154,10 +155,10 @@ dependencies:
|
|
154
155
|
- !ruby/object:Gem::Version
|
155
156
|
version: "0"
|
156
157
|
type: :runtime
|
157
|
-
prerelease: false
|
158
158
|
version_requirements: *id013
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: delorean
|
161
|
+
prerelease: false
|
161
162
|
requirement: &id014 !ruby/object:Gem::Requirement
|
162
163
|
none: false
|
163
164
|
requirements:
|
@@ -165,10 +166,10 @@ dependencies:
|
|
165
166
|
- !ruby/object:Gem::Version
|
166
167
|
version: "0"
|
167
168
|
type: :development
|
168
|
-
prerelease: false
|
169
169
|
version_requirements: *id014
|
170
170
|
- !ruby/object:Gem::Dependency
|
171
171
|
name: rspec
|
172
|
+
prerelease: false
|
172
173
|
requirement: &id015 !ruby/object:Gem::Requirement
|
173
174
|
none: false
|
174
175
|
requirements:
|
@@ -176,10 +177,10 @@ dependencies:
|
|
176
177
|
- !ruby/object:Gem::Version
|
177
178
|
version: 2.6.0
|
178
179
|
type: :development
|
179
|
-
prerelease: false
|
180
180
|
version_requirements: *id015
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: shoulda
|
183
|
+
prerelease: false
|
183
184
|
requirement: &id016 !ruby/object:Gem::Requirement
|
184
185
|
none: false
|
185
186
|
requirements:
|
@@ -187,10 +188,10 @@ dependencies:
|
|
187
188
|
- !ruby/object:Gem::Version
|
188
189
|
version: "0"
|
189
190
|
type: :development
|
190
|
-
prerelease: false
|
191
191
|
version_requirements: *id016
|
192
192
|
- !ruby/object:Gem::Dependency
|
193
193
|
name: bundler
|
194
|
+
prerelease: false
|
194
195
|
requirement: &id017 !ruby/object:Gem::Requirement
|
195
196
|
none: false
|
196
197
|
requirements:
|
@@ -198,10 +199,10 @@ dependencies:
|
|
198
199
|
- !ruby/object:Gem::Version
|
199
200
|
version: 1.0.0
|
200
201
|
type: :development
|
201
|
-
prerelease: false
|
202
202
|
version_requirements: *id017
|
203
203
|
- !ruby/object:Gem::Dependency
|
204
204
|
name: jeweler
|
205
|
+
prerelease: false
|
205
206
|
requirement: &id018 !ruby/object:Gem::Requirement
|
206
207
|
none: false
|
207
208
|
requirements:
|
@@ -209,7 +210,6 @@ dependencies:
|
|
209
210
|
- !ruby/object:Gem::Version
|
210
211
|
version: 1.5.2
|
211
212
|
type: :development
|
212
|
-
prerelease: false
|
213
213
|
version_requirements: *id018
|
214
214
|
description: FnordMetric is a Ruby Event-Tracking gem on steroids
|
215
215
|
email: paul@paulasmuth.com
|
@@ -220,30 +220,22 @@ extensions: []
|
|
220
220
|
extra_rdoc_files: []
|
221
221
|
|
222
222
|
files:
|
223
|
-
- .
|
223
|
+
- .travis.yml
|
224
224
|
- Gemfile
|
225
225
|
- Gemfile.lock
|
226
226
|
- Rakefile
|
227
227
|
- VERSION
|
228
|
-
-
|
229
|
-
-
|
230
|
-
-
|
231
|
-
-
|
232
|
-
- _spec/count_metric_spec.rb
|
233
|
-
- _spec/dashboard_spec.rb
|
234
|
-
- _spec/event_spec.rb
|
235
|
-
- _spec/metric_spec.rb
|
236
|
-
- _spec/report_spec.rb
|
237
|
-
- _spec/sum_metric_spec.rb
|
238
|
-
- _spec/widget_spec.rb
|
239
|
-
- doc/example_server.rb
|
240
|
-
- doc/import_dump.rb
|
228
|
+
- doc/preview1.png
|
229
|
+
- doc/preview2.png
|
230
|
+
- doc/ulm_stats.rb
|
231
|
+
- doc/version
|
241
232
|
- fnordmetric.gemspec
|
242
233
|
- haml/app.haml
|
243
234
|
- haml/widget.haml
|
244
235
|
- lib/fnordmetric.rb
|
245
236
|
- lib/fnordmetric/app.rb
|
246
237
|
- lib/fnordmetric/average_metric.rb
|
238
|
+
- lib/fnordmetric/bars_widget.rb
|
247
239
|
- lib/fnordmetric/cache.rb
|
248
240
|
- lib/fnordmetric/combine_metric.rb
|
249
241
|
- lib/fnordmetric/context.rb
|
@@ -260,34 +252,21 @@ files:
|
|
260
252
|
- lib/fnordmetric/metric_api.rb
|
261
253
|
- lib/fnordmetric/namespace.rb
|
262
254
|
- lib/fnordmetric/numbers_widget.rb
|
255
|
+
- lib/fnordmetric/pie_widget.rb
|
263
256
|
- lib/fnordmetric/report.rb
|
264
257
|
- lib/fnordmetric/session.rb
|
265
258
|
- lib/fnordmetric/standalone.rb
|
266
259
|
- lib/fnordmetric/sum_metric.rb
|
267
260
|
- lib/fnordmetric/timeline_widget.rb
|
261
|
+
- lib/fnordmetric/toplist_widget.rb
|
268
262
|
- lib/fnordmetric/widget.rb
|
269
263
|
- lib/fnordmetric/worker.rb
|
270
|
-
- pub/fnordmetric
|
271
|
-
- pub/fnordmetric
|
272
|
-
- pub/
|
273
|
-
- pub/fnordmetric/widget_timeline.css
|
274
|
-
- pub/fnordmetric/widget_timeline.js
|
275
|
-
- pub/highcharts/adapters/mootools-adapter.js
|
276
|
-
- pub/highcharts/adapters/mootools-adapter.src.js
|
277
|
-
- pub/highcharts/adapters/prototype-adapter.js
|
278
|
-
- pub/highcharts/adapters/prototype-adapter.src.js
|
279
|
-
- pub/highcharts/highcharts.js
|
280
|
-
- pub/highcharts/highcharts.src.js
|
281
|
-
- pub/highcharts/modules/exporting.js
|
282
|
-
- pub/highcharts/modules/exporting.src.js
|
283
|
-
- pub/highcharts/themes/dark-blue.js
|
284
|
-
- pub/highcharts/themes/dark-green.js
|
285
|
-
- pub/highcharts/themes/gray.js
|
286
|
-
- pub/highcharts/themes/grid.js
|
287
|
-
- pub/jquery-1.6.1.min.js
|
288
|
-
- pub/raphael-min.js
|
289
|
-
- pub/raphael-utils.js
|
264
|
+
- pub/fnordmetric.css
|
265
|
+
- pub/fnordmetric.js
|
266
|
+
- pub/loader.gif
|
290
267
|
- pub/sprite.png
|
268
|
+
- pub/vendor/highcharts.js
|
269
|
+
- pub/vendor/jquery-1.6.1.min.js
|
291
270
|
- readme.rdoc
|
292
271
|
- spec/app_spec.rb
|
293
272
|
- spec/context_spec.rb
|
@@ -300,7 +279,6 @@ files:
|
|
300
279
|
- spec/spec_helper.rb
|
301
280
|
- spec/widget_spec.rb
|
302
281
|
- spec/worker_spec.rb
|
303
|
-
- ulm_stats.rb
|
304
282
|
has_rdoc: true
|
305
283
|
homepage: http://github.com/paulasmuth/fnordmetric
|
306
284
|
licenses:
|
@@ -315,9 +293,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
293
|
requirements:
|
316
294
|
- - ">="
|
317
295
|
- !ruby/object:Gem::Version
|
318
|
-
hash: -764930577
|
319
|
-
segments:
|
320
|
-
- 0
|
321
296
|
version: "0"
|
322
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
323
298
|
none: false
|
data/.document
DELETED
data/_spec/app_spec.rb
DELETED
@@ -1,178 +0,0 @@
|
|
1
|
-
require ::File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
-
|
3
|
-
include Rack::Test::Methods
|
4
|
-
|
5
|
-
describe "app" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
FnordMetric::Event.destroy_all
|
9
|
-
end
|
10
|
-
|
11
|
-
def app
|
12
|
-
@app ||= FnordMetric::App
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should redirect to the default dashboard" do
|
16
|
-
get "/"
|
17
|
-
last_response.status.should == 302
|
18
|
-
last_response.location.should == "http://example.org/dashboard/default"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should render the dashboard" do
|
22
|
-
FnordMetric.dashboard("Deine Mama"){|dash|}
|
23
|
-
get "/dashboard/default"
|
24
|
-
last_response.status.should == 200
|
25
|
-
last_response.body.should include("Deine Mama")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should render the right dashboard" do
|
29
|
-
FnordMetric.dashboard("Deine Mama"){|dash|}
|
30
|
-
FnordMetric.dashboard("My Dashboard"){|dash|}
|
31
|
-
get "/dashboard/DeineMama"
|
32
|
-
last_response.status.should == 200
|
33
|
-
last_response.body.should include("Deine Mama")
|
34
|
-
get "/dashboard/MyDashboard"
|
35
|
-
last_response.status.should == 200
|
36
|
-
last_response.body.should include("My Dashboard")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should track an event without auth" do
|
40
|
-
post "/events", :type => "myevent", :fnord => "foobar"
|
41
|
-
last_response.status.should == 200
|
42
|
-
FnordMetric::Event.last.type.should == "myevent"
|
43
|
-
FnordMetric::Event.last.fnord.should == "foobar"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should return 400 if no type is provided" do
|
47
|
-
post "/events", :fnord => "foobar"
|
48
|
-
last_response.status.should == 400
|
49
|
-
last_response.body.should == "please specify the event_type"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should track an event in the past" do
|
53
|
-
my_time = (Time.now-3.years).to_i
|
54
|
-
post "/events", :type => "myevent", :time => my_time
|
55
|
-
last_response.status.should == 200
|
56
|
-
FnordMetric::Event.last.type.should == "myevent"
|
57
|
-
FnordMetric::Event.last.time.should == my_time
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should track an event with integer data" do
|
61
|
-
post "/events", :type => "myevent", :blubb => "123"
|
62
|
-
last_response.status.should == 200
|
63
|
-
FnordMetric::Event.last.type.should == "myevent"
|
64
|
-
FnordMetric::Event.last.blubb.should == 123
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should track an event with float data" do
|
68
|
-
post "/events", :type => "myevent", :blubb => "42.23"
|
69
|
-
last_response.status.should == 200
|
70
|
-
FnordMetric::Event.last.type.should == "myevent"
|
71
|
-
FnordMetric::Event.last.blubb.should == 42.23
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
describe "metrics api" do
|
76
|
-
|
77
|
-
before(:each) do
|
78
|
-
FnordMetric::Event.destroy_all
|
79
|
-
FnordMetric.metric('my_event_count', :count => true, :types => [:my_event_type])
|
80
|
-
FnordMetric.track('my_event_type', :time => 33.hours.ago)
|
81
|
-
FnordMetric.track('my_event_type', :time => 32.hours.ago)
|
82
|
-
FnordMetric.track('my_event_type', :time => 29.hours.ago)
|
83
|
-
FnordMetric.track('my_event_type', :time => 27.hours.ago)
|
84
|
-
FnordMetric.track('my_event_type', :time => 26.hours.ago)
|
85
|
-
FnordMetric.track('my_event_type', :time => 13.hours.ago)
|
86
|
-
FnordMetric.track('my_event_type', :time => 12.hours.ago)
|
87
|
-
FnordMetric.track('my_event_type', :time => 2.hours.ago)
|
88
|
-
FnordMetric.track('my_event_type', :time => 3.hours.ago)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should return the right answer for: /metric/:name" do
|
92
|
-
get "/metric/my_event_count"
|
93
|
-
JSON.parse(last_response.body)["value"].to_i.should == 9
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should return the right answer for: /metric/:name?at=timestamp" do
|
97
|
-
get "/metric/my_event_count", :at => 18.hours.ago.to_i.to_s
|
98
|
-
JSON.parse(last_response.body)["value"].to_i.should == 5
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp" do
|
102
|
-
get "/metric/my_event_count", :at => "#{30.hours.ago.to_i}-#{20.hours.ago.to_i}"
|
103
|
-
JSON.parse(last_response.body)["value"].to_i.should == 3
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
107
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i, :delta => true
|
108
|
-
JSON.parse(last_response.body)["values"].length.should == 6
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
112
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i, :delta => true
|
113
|
-
JSON.parse(last_response.body)["values"][0].first.should == 34.hours.ago.to_i
|
114
|
-
JSON.parse(last_response.body)["values"][0].last.should == 3
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
118
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i, :delta => true
|
119
|
-
JSON.parse(last_response.body)["values"][1].first.should == 28.hours.ago.to_i
|
120
|
-
JSON.parse(last_response.body)["values"][1].last.should == 2
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
124
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i, :delta => true
|
125
|
-
JSON.parse(last_response.body)["values"][2].first.should == 22.hours.ago.to_i
|
126
|
-
JSON.parse(last_response.body)["values"][2].last.should == 0
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
130
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i, :delta => true
|
131
|
-
JSON.parse(last_response.body)["values"][3].first.should == 16.hours.ago.to_i
|
132
|
-
JSON.parse(last_response.body)["values"][3].last.should == 2
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
136
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i, :delta => true
|
137
|
-
JSON.parse(last_response.body)["values"][5].first.should == 4.hours.ago.to_i
|
138
|
-
JSON.parse(last_response.body)["values"][5].last.should == 2
|
139
|
-
end
|
140
|
-
|
141
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
142
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i
|
143
|
-
JSON.parse(last_response.body)["values"].length.should == 6
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
147
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i
|
148
|
-
JSON.parse(last_response.body)["values"][0].first.should == 34.hours.ago.to_i
|
149
|
-
JSON.parse(last_response.body)["values"][0].last.should == 0
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
153
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i
|
154
|
-
JSON.parse(last_response.body)["values"][1].first.should == 28.hours.ago.to_i
|
155
|
-
JSON.parse(last_response.body)["values"][1].last.should == 3
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
159
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i
|
160
|
-
JSON.parse(last_response.body)["values"][2].first.should == 22.hours.ago.to_i
|
161
|
-
JSON.parse(last_response.body)["values"][2].last.should == 5
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
165
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i
|
166
|
-
JSON.parse(last_response.body)["values"][3].first.should == 16.hours.ago.to_i
|
167
|
-
JSON.parse(last_response.body)["values"][3].last.should == 5
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp&tick=seconds" do
|
171
|
-
get "/metric/my_event_count", :at => "#{34.hours.ago.to_i}-#{1.hour.ago.to_i}", :tick => 6.hours.to_i
|
172
|
-
JSON.parse(last_response.body)["values"][5].first.should == 4.hours.ago.to_i
|
173
|
-
JSON.parse(last_response.body)["values"][5].last.should == 7
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|