Adds Ruby 1.9.2 compat (references to TimeExt#round collide with the new real Time#now, changed to TimeExt#beginning_of_closest), 3 specs failing relating to time equality testing

This commit is contained in:
James Harrison
2010-12-28 23:46:25 +00:00
parent d9ce0daade
commit 6a66605e0b
5 changed files with 13 additions and 5 deletions

View File

@@ -5,7 +5,6 @@ PATH
activesupport (>= 2.3.0)
json (>= 1.4.0)
redis (>= 2.1.0)
system_timer (>= 1.0.0)
time_ext (>= 0.2.8)
GEM
@@ -24,7 +23,6 @@ GEM
rspec-expectations (2.1.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.1.0)
system_timer (1.0)
time_ext (0.2.8)
activesupport (>= 2.3.0)
i18n (>= 0.4.2)
@@ -39,6 +37,5 @@ DEPENDENCIES
redis (>= 2.1.0)
redistat!
rspec (>= 2.1.0)
system_timer (>= 1.0.0)
time_ext (>= 0.2.8)
yard (>= 0.6.3)

View File

@@ -26,6 +26,7 @@ require 'redistat/summary'
require 'redistat/core_ext/date'
require 'redistat/core_ext/time'
require 'redistat/core_ext/fixnum'
require 'redistat/core_ext/bignum'
module Redistat

View File

@@ -0,0 +1,8 @@
class Bignum
include Redistat::DateHelper
def to_time
Time.at(self)
end
end

View File

@@ -22,6 +22,8 @@ module Redistat
from_string(input)
elsif input.is_a?(::Fixnum)
from_integer(input)
elsif input.is_a?(::Bignum)
from_integer(input)
end
end

View File

@@ -42,7 +42,7 @@ module Redistat
return find_start_year_for(start_date, end_date, lowest_depth) if unit == :year
index = Date::DEPTHS.index(unit)
nunit = Date::DEPTHS[(index > 0) ? index-1 : index]
if start_date < start_date.round(nunit) || start_date.next(nunit).beginning_of(nunit) > end_date.beginning_of(nunit)
if start_date < start_date.beginning_of_closest(nunit) || start_date.next(nunit).beginning_of(nunit) > end_date.beginning_of(nunit)
add = []
start_date.beginning_of_each(unit, :include_start => lowest_depth).until(start_date.end_of(nunit)) do |t|
add << t.to_rs.to_s(unit) if t < end_date.beginning_of(unit)
@@ -59,7 +59,7 @@ module Redistat
index = Date::DEPTHS.index(unit)
nunit = Date::DEPTHS[(index > 0) ? index-1 : index]
has_nunit = end_date.prev(nunit).beginning_of(nunit) >= start_date.beginning_of(nunit)
nearest_nunit = end_date.round(nunit)
nearest_nunit = end_date.beginning_of_closest(nunit)
if end_date >= nearest_nunit && has_nunit
add = []
end_date.beginning_of(nunit).beginning_of_each(unit, :include_start => true, :include_end => lowest_depth).until(end_date) do |t|