pulse-meter 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module PulseMeter
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -3,6 +3,8 @@ document.startApp = ->
3
3
 
4
4
  String::capitalize = ->
5
5
  @charAt(0).toUpperCase() + @slice(1)
6
+ String::strip = ->
7
+ if String::trim? then @trim() else @replace /^\s+|\s+$/g, ""
6
8
 
7
9
  PageInfo = Backbone.Model.extend {
8
10
  }
@@ -169,7 +171,7 @@ document.startApp = ->
169
171
  position: 'bottom'
170
172
  }
171
173
  vAxis: {
172
- title: @get('valuesTitle')
174
+ title: "#{@get('valuesTitle')} / #{@humanizedInterval()}"
173
175
  }
174
176
  hAxis: {
175
177
  format: format
@@ -177,6 +179,28 @@ document.startApp = ->
177
179
  series: @get('series').options
178
180
  axisTitlesPosition: 'in'
179
181
  }
182
+
183
+ humanizedInterval: ->
184
+ interval = @get('interval')
185
+ res = ""
186
+ s = interval % 60
187
+ res = "#{s} s" if s > 0
188
+ interval = (interval - s) / 60
189
+ return res unless interval > 0
190
+
191
+ m = interval % 60
192
+ res = "#{m} m #{res}".strip() if m > 0
193
+ interval = (interval - m) / 60
194
+ return res unless interval > 0
195
+
196
+ h = interval % 24
197
+ res = "#{h} h #{res}".strip() if h > 0
198
+ d = (interval - h) / 24
199
+ if d > 0
200
+ "#{d} d #{res}".strip()
201
+ else
202
+ res
203
+
180
204
 
181
205
  cutoff: (min, max) ->
182
206
  _.each(@get('series').rows, (row) ->
@@ -9,6 +9,13 @@
9
9
  String.prototype.capitalize = function() {
10
10
  return this.charAt(0).toUpperCase() + this.slice(1);
11
11
  };
12
+ String.prototype.strip = function() {
13
+ if (String.prototype.trim != null) {
14
+ return this.trim();
15
+ } else {
16
+ return this.replace(/^\s+|\s+$/g, "");
17
+ }
18
+ };
12
19
  PageInfo = Backbone.Model.extend({});
13
20
  PageInfoList = Backbone.Collection.extend({
14
21
  model: PageInfo,
@@ -227,7 +234,7 @@
227
234
  position: 'bottom'
228
235
  },
229
236
  vAxis: {
230
- title: this.get('valuesTitle')
237
+ title: "" + (this.get('valuesTitle')) + " / " + (this.humanizedInterval())
231
238
  },
232
239
  hAxis: {
233
240
  format: format
@@ -237,6 +244,28 @@
237
244
  });
238
245
  };
239
246
 
247
+ SeriesPresenter.prototype.humanizedInterval = function() {
248
+ var d, h, interval, m, res, s;
249
+ interval = this.get('interval');
250
+ res = "";
251
+ s = interval % 60;
252
+ if (s > 0) res = "" + s + " s";
253
+ interval = (interval - s) / 60;
254
+ if (!(interval > 0)) return res;
255
+ m = interval % 60;
256
+ if (m > 0) res = ("" + m + " m " + res).strip();
257
+ interval = (interval - m) / 60;
258
+ if (!(interval > 0)) return res;
259
+ h = interval % 24;
260
+ if (h > 0) res = ("" + h + " h " + res).strip();
261
+ d = (interval - h) / 24;
262
+ if (d > 0) {
263
+ return ("" + d + " d " + res).strip();
264
+ } else {
265
+ return res;
266
+ }
267
+ };
268
+
240
269
  SeriesPresenter.prototype.cutoff = function(min, max) {
241
270
  return _.each(this.get('series').rows, function(row) {
242
271
  var i, value, _i, _ref, _results;
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.2.5
4
+ version: 0.2.6
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-07-19 00:00:00.000000000 Z
13
+ date: 2012-07-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gon-sinatra
@@ -466,6 +466,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
466
466
  - - ! '>='
467
467
  - !ruby/object:Gem::Version
468
468
  version: '0'
469
+ segments:
470
+ - 0
471
+ hash: -2459703575174503606
469
472
  requirements: []
470
473
  rubyforge_project:
471
474
  rubygems_version: 1.8.24