nightfury 0.7.0 → 0.7.1

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.
@@ -2,8 +2,8 @@ module Nightfury
2
2
  module Metric
3
3
  class TimeSeries < Base
4
4
 
5
- def self.round_time(time, seconds=60)
6
- Time.at((time.to_f / seconds).round * seconds)
5
+ def self.floor_time(time, seconds=60)
6
+ Time.at((time.to_f / seconds).floor * seconds)
7
7
  end
8
8
 
9
9
  def initialize(name, options={})
@@ -90,17 +90,17 @@ module Nightfury
90
90
  [data_point[1], data_point[0], {}]
91
91
  end
92
92
 
93
- def round_time(time, seconds=60)
94
- self.class.round_time(time, seconds)
93
+ def floor_time(time, seconds=60)
94
+ self.class.floor_time(time, seconds)
95
95
  end
96
96
 
97
97
  def get_step_time(time)
98
98
  case step
99
- when :minute then round_time(time, 60)
100
- when :hour then round_time(time, 1.hour)
101
- when :day then round_time(time, 1.day)
102
- when :week then round_time(time, 1.week)
103
- when :month then round_time(time, Time.days_in_month(time.month, time.year))
99
+ when :minute then floor_time(time, 60)
100
+ when :hour then floor_time(time, 1.hour)
101
+ when :day then floor_time(time, 1.day)
102
+ when :week then floor_time(time, 1.week)
103
+ when :month then floor_time(time, Time.days_in_month(time.month, time.year))
104
104
  end
105
105
  end
106
106
 
@@ -1,3 +1,3 @@
1
1
  module Nightfury
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -39,7 +39,7 @@ describe Nightfury::Metric::CountTimeSeries do
39
39
  # Add a data point
40
40
  count_series.set(1, time_now - 10)
41
41
  count_series.incr(1,time_later)
42
- count_series.get.should == { round_time(time_later, 60).to_i.to_s => "2"}
42
+ count_series.get.should == { floor_time(time_later, 60).to_i.to_s => "2"}
43
43
  end
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ describe Nightfury::Metric::CountTimeSeries do
48
48
  count_series = Nightfury::Metric::CountTimeSeries.new(1)
49
49
  time_now = Time.now
50
50
  count_series.incr(2, time_now)
51
- count_series.get.should == { round_time(time_now, 60).to_i.to_s => "2"}
51
+ count_series.get.should == { floor_time(time_now, 60).to_i.to_s => "2"}
52
52
  end
53
53
  end
54
54
  end
@@ -91,7 +91,7 @@ describe Nightfury::Metric::CountTimeSeries do
91
91
  # Add a data point
92
92
  count_series.set(1, time_now - 10)
93
93
  count_series.decr(1,time_later)
94
- count_series.get.should == { round_time(time_later, 60).to_i.to_s => "0"}
94
+ count_series.get.should == { floor_time(time_later, 60).to_i.to_s => "0"}
95
95
  end
96
96
  end
97
97
 
@@ -100,7 +100,7 @@ describe Nightfury::Metric::CountTimeSeries do
100
100
  count_series = Nightfury::Metric::CountTimeSeries.new(1)
101
101
  time_now = Time.now
102
102
  count_series.decr(2, time_now)
103
- count_series.get.should == { round_time(time_now, 60).to_i.to_s => "-2"}
103
+ count_series.get.should == { floor_time(time_now, 60).to_i.to_s => "-2"}
104
104
  end
105
105
  end
106
106
  end
@@ -197,7 +197,7 @@ describe Nightfury::Metric::TimeSeries do
197
197
 
198
198
  flexmock(ts_metric.redis).should_receive(:zadd)
199
199
  .with(ts_metric.redis_key,
200
- round_time(time_now, 60).to_i,
200
+ floor_time(time_now, 60).to_i,
201
201
  FlexMock.any)
202
202
  .once
203
203
 
@@ -213,7 +213,7 @@ describe Nightfury::Metric::TimeSeries do
213
213
 
214
214
  flexmock(ts_metric.redis).should_receive(:zadd)
215
215
  .with(ts_metric.redis_key,
216
- round_time(time, 60).to_i,
216
+ floor_time(time, 60).to_i,
217
217
  FlexMock.any)
218
218
  .once
219
219
 
data/spec/spec_helper.rb CHANGED
@@ -34,6 +34,6 @@ RSpec.configure do |config|
34
34
  end
35
35
  end
36
36
 
37
- def round_time(time, seconds=60)
38
- Nightfury::Metric::TimeSeries.round_time(time, 60)
37
+ def floor_time(time, seconds=60)
38
+ Nightfury::Metric::TimeSeries.floor_time(time, 60)
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nightfury
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: