17 Commits

Author SHA1 Message Date
66510fe344 Merge branch 'release/v0.0.7' 2010-12-29 17:29:13 +00:00
745473862f added note about system_timer gem to readme 2010-12-29 17:28:56 +00:00
a5c8fc6fbf Version bump to 0.0.7 2010-12-29 17:27:19 +00:00
115b223d7c added class_name option to Model warpper for
customizing the scope used in Redis keys
2010-12-29 17:26:22 +00:00
0597b587fd Merge branch 'feature/ruby19' into dev 2010-12-29 17:14:40 +00:00
89932759ef Merge branch 'master' of https://github.com/JamesHarrison/redistat into feature/ruby19 2010-12-29 16:42:50 +00:00
55e0687837 Merge branch 'dev' into feature/ruby19 2010-12-29 16:42:36 +00:00
James Harrison
93360dbeb9 Specs pass again - problem with Time.now resolution surpassing that provided by values stored in a Redistat::Date, truncated to seconds by using to_s, which is accurate enough for testing purposes 2010-12-28 23:55:39 +00:00
James Harrison
6a66605e0b 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 2010-12-28 23:46:25 +00:00
James Harrison
d9ce0daade Removes SystemTimer for Ruby 1.9.2 compat 2010-12-28 22:11:33 +00:00
f6ec2e97b2 Merge branch 'dev' of github.com:jimeh/redistat into dev 2010-12-09 22:42:55 +00:00
67dc9433c7 fixed typo in deprecation warning 2010-12-09 22:42:27 +00:00
f0fcd2110d Merge branch 'release/v0.0.6' into dev 2010-12-01 13:41:48 +00:00
24112e4705 Merge branch 'release/v0.0.6' 2010-12-01 13:41:44 +00:00
b9752ff92f Version bump to 0.0.6 2010-12-01 13:41:30 +00:00
14a093d79b updated gem dependencies to less specific versions
as older versions should work
2010-12-01 13:40:55 +00:00
84a05363dd Merge branch 'release/v0.0.5' into dev 2010-11-28 11:56:23 +00:00
13 changed files with 51 additions and 21 deletions

View File

@@ -1,11 +1,10 @@
PATH
remote: .
specs:
redistat (0.0.4)
redistat (0.0.6)
activesupport (>= 2.3.0)
json (>= 1.4.6)
redis (>= 2.1.1)
system_timer (>= 1.0.0)
json (>= 1.4.0)
redis (>= 2.1.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)
@@ -35,10 +33,9 @@ PLATFORMS
DEPENDENCIES
activesupport (>= 2.3.0)
json (>= 1.4.6)
redis (>= 2.1.1)
json (>= 1.4.0)
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

@@ -14,6 +14,8 @@ Redis fits perfectly with all of these requirements. It has atomic operations li
gem install redistat
If you are using Ruby 1.8.x, it's recommended you also install the `system_timer` gem, as the Redis gem will otherwise complain.
## Usage
The simplest way to use Redistat is through the model wrapper.

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
@@ -54,7 +55,7 @@ module Redistat
end
def flush
puts "WARNING: Redistat.flush is deprecated. Use Redistat.redis.flush instead."
puts "WARNING: Redistat.flush is deprecated. Use Redistat.redis.flushdb instead."
connection.flushdb
end

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|

View File

@@ -39,6 +39,15 @@ module Redistat
end
end
def class_name(class_name = nil)
if !class_name.nil?
options[:class_name] = class_name
else
options[:class_name] || nil
end
end
alias :scope :class_name
def depth(depth = nil)
if !depth.nil?
options[:depth] = depth
@@ -62,7 +71,7 @@ module Redistat
private
def name
@name ||= self.to_s
options[:class_name] || (@name ||= self.to_s)
end
end

View File

@@ -1,3 +1,3 @@
module Redistat
VERSION = "0.0.5"
VERSION = "0.0.7"
end

View File

@@ -20,9 +20,8 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.add_runtime_dependency 'activesupport', '>= 2.3.0'
s.add_runtime_dependency 'json', '>= 1.4.6'
s.add_runtime_dependency 'redis', '>= 2.1.1'
s.add_runtime_dependency 'system_timer', '>= 1.0.0'
s.add_runtime_dependency 'json', '>= 1.4.0'
s.add_runtime_dependency 'redis', '>= 2.1.0'
s.add_runtime_dependency 'time_ext', '>= 0.2.8'
s.add_development_dependency 'rspec', '>= 2.1.0'

View File

@@ -20,7 +20,7 @@ describe Redistat::Event do
@event.scope.should == @scope
@event.label.should == @label
@event.label_hash.should == @label_hash
@event.date.to_time.should == @date
@event.date.to_time.to_s.should == @date.to_s
@event.stats.should == @stats
@event.meta.should == @meta
@event.options.should == @event.default_options.merge(@options)
@@ -28,10 +28,10 @@ describe Redistat::Event do
it "should allow changing attributes" do
# date
@event.date.to_time.should == @date
@event.date.to_time.to_s.should == @date.to_s
@date = Time.now
@event.date = @date
@event.date.to_time.should == @date
@event.date.to_time.to_s.should == @date.to_s
# label
@event.label.should == @label
@event.label_hash.should == @label_hash

View File

@@ -46,10 +46,10 @@ describe Redistat::Key do
@key.scope = @scope
@key.scope.should == @scope
# date
@key.date.to_time.should == @date
@key.date.to_time.to_s.should == @date.to_s
@date = Time.now
@key.date = @date
@key.date.to_time.should == @date
@key.date.to_time.to_s.should == @date.to_s
# label
@key.label.should == @label
@key.label_hash == @label_hash

View File

@@ -20,4 +20,11 @@ class ModelHelper3
connect_to :port => 8379, :db => 14
end
class ModelHelper4
include Redistat::Model
class_name "FancyHelper"
end

View File

@@ -8,6 +8,7 @@ describe Redistat::Model do
ModelHelper1.redis.flushdb
ModelHelper2.redis.flushdb
ModelHelper3.redis.flushdb
ModelHelper4.redis.flushdb
end
it "should should name itself correctly" do
@@ -19,6 +20,7 @@ describe Redistat::Model do
ModelHelper2.depth.should == :day
ModelHelper2.store_event.should == true
ModelHelper2.hashed_label.should == true
ModelHelper2.class_name.should be_nil
ModelHelper1.depth.should == nil
ModelHelper1.store_event.should == nil
@@ -35,6 +37,9 @@ describe Redistat::Model do
ModelHelper1.depth.should == nil
ModelHelper1.store_event.should == nil
ModelHelper1.hashed_label.should == nil
ModelHelper4.class_name.should == "FancyHelper"
ModelHelper4.send(:name).should == "FancyHelper"
end
it "should store and fetch stats" do