johnf-fnordmetric 1.2.7 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,11 @@ class FnordMetric::API
4
4
 
5
5
  def initialize(opts={})
6
6
  @@opts = FnordMetric.default_options(opts)
7
- connect
7
+ if @@opts[:redis]
8
+ @redis = @@opts.delete :redis
9
+ else
10
+ connect
11
+ end
8
12
  end
9
13
 
10
14
  def connect
@@ -1,3 +1,3 @@
1
1
  module FnordMetric
2
- VERSION = "1.2.7"
2
+ VERSION = "1.2.10"
3
3
  end
@@ -96,10 +96,10 @@ describe FnordMetric::Widget do
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]).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)
99
+ Time.at(widget.ticks.to_a[0]).utc.should == Time.utc(1992,01,12,18,00)
100
+ Time.at(widget.ticks.to_a[1]).utc.should == Time.utc(1992,01,12,19,00)
101
+ Time.at(widget.ticks.to_a[-1]).utc.should == Time.utc(1992,01,13,18,00)
102
+ Time.at(widget.ticks.to_a[-2]).utc.should == Time.utc(1992,01,13,17,00)
103
103
  end
104
104
  end
105
105
 
@@ -110,4 +110,4 @@ private
110
110
  (a.last.to_i - b.last.to_i).should == 0
111
111
  end
112
112
 
113
- end
113
+ end
@@ -2,10 +2,6 @@ FnordMetric.util.getNextWidgetUID = function(){
2
2
  return (FnordMetric.currentWidgetUID += 1);
3
3
  }
4
4
 
5
- FnordMetric.util.decPrint = function(val){
6
- return (val < 10 ? '0'+val : val);
7
- }
8
-
9
5
  FnordMetric.util.formatTimeOfDay = function(_time){
10
6
  if(_time === null) {
11
7
  return "";
@@ -18,22 +14,6 @@ FnordMetric.util.formatTimeOfDay = function(_time){
18
14
  }
19
15
  }
20
16
 
21
- FnordMetric.util.formatTimeRange = function(range){
22
- if (range < 60){
23
- return parseInt(range) + ' sec';
24
- } else if(range<3600){
25
- return parseInt(range/60) + ' min';
26
- } else if(range==3600){
27
- return '1 hour';
28
- } else if(range<(3600*24)){
29
- return parseInt(range/3600) + ' hours';
30
- } else if(range==(3600*24)){
31
- return '1 day';
32
- } else {
33
- return parseInt(range/(3600*24)) + ' days';
34
- }
35
- }
36
-
37
17
  FnordMetric.util.formatTimeRangePre = function(range, offset){
38
18
  if(!offset){ offset=0; } else { offset=parseInt(offset); }
39
19
  if((offset == 0) && (range==(3600*24))){
@@ -80,42 +60,6 @@ FnordMetric.util.formatOffset = function(offset, next_offset){
80
60
  }
81
61
  }
82
62
 
83
- FnordMetric.util.formatValue = function(value){
84
- if(value < 10){
85
- return value.toFixed(1);
86
- }
87
- if(value < 100){
88
- return value.toFixed(1);
89
- } else if(value > 1000){
90
- return (value/1000.0).toFixed(1) + "k";
91
- } else {
92
- return value.toFixed(0);
93
- }
94
- }
95
-
96
- FnordMetric.util.formatTimeValue = function(value){
97
- if (value < 60){
98
- return parseFloat(value).toFixed(1) + 's';
99
- } else if(value<3600){
100
- return parseFloat(value/60).toFixed(1) + 'm';
101
- } else if(value<(3600*24)){
102
- return parseFloat(value/3600).toFixed(1) + 'h';
103
- } else {
104
- return parseFloat(value/(3600*24)).toFixed(1) + 'd';
105
- }
106
- }
107
-
108
- FnordMetric.util.formatPercentValue = function(value){
109
- value = parseFloat(value);
110
- if(value < 10){
111
- return value.toFixed(2) + '%';
112
- } else if(value < 100){
113
- return value.toFixed(1) + '%';
114
- } else {
115
- return '100%';
116
- }
117
- }
118
-
119
63
  FnordMetric.util.formatGaugeValue = function(gauge_key, value){
120
64
  if(!gauge_key){ gauge_key = ""; }
121
65
  if(gauge_key.slice(0,8) === '__time__'){
@@ -160,15 +104,6 @@ FnordMetric.util.updateNumbers = function(trgt_elem, diff_factor, single){
160
104
  }
161
105
  }
162
106
 
163
- FnordMetric.util.dateFormat = function(timestamp){
164
- var t = new Date(timestamp*1000);
165
- return FnordMetric.util.decPrint(t.getDate()) + "." +
166
- FnordMetric.util.decPrint((t.getMonth()+1)) + "." +
167
- FnordMetric.util.decPrint(t.getFullYear()) + " " +
168
- FnordMetric.util.decPrint(t.getHours()) + ":" +
169
- FnordMetric.util.decPrint(t.getMinutes()) + " ";
170
- }
171
-
172
107
  FnordMetric.util.format = function(elem){
173
108
  $('.ui_trend, .ui_value', $(elem)).each(function(){
174
109
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: johnf-fnordmetric
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-18 00:00:00.000000000 Z
12
+ date: 2013-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -407,7 +407,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
407
407
  version: '0'
408
408
  segments:
409
409
  - 0
410
- hash: -4560229331879220322
410
+ hash: 1119626446438757459
411
411
  required_rubygems_version: !ruby/object:Gem::Requirement
412
412
  none: false
413
413
  requirements:
@@ -416,7 +416,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
416
  version: '0'
417
417
  segments:
418
418
  - 0
419
- hash: -4560229331879220322
419
+ hash: 1119626446438757459
420
420
  requirements: []
421
421
  rubyforge_project:
422
422
  rubygems_version: 1.8.23