some initial work on Redistat::Event

This commit is contained in:
2010-07-19 02:50:24 +03:00
parent 515d265853
commit 9a69c15ae2
2 changed files with 35 additions and 8 deletions

View File

@@ -1,17 +1,29 @@
module Redistat
class Event
attr_accessor :label
attr_reader :scope
attr_reader :label
attr_reader :key
attr_reader :options
def initialize(scope, options, data = {}, label = nil, time = nil)
key = [scope]
key << Digest::SHA1.hexdigest(label) if !label.nil?
def initialize(scope, label = nil, data = {}, date = nil, options = {})
@options = options
@scope = scope
@key = Key.new(scope, label, date, options)
@label = @key.label
#TODO ...intialize Redistat::Event
end
def date
@key.date.to_date
end
def time
@key.date.to_time
end
def save
time ||= Time.now
key << time.to_redistat(options ||= nil)
puts key.inspect
end
end

15
spec/event_spec.rb Normal file
View File

@@ -0,0 +1,15 @@
require "spec_helper"
describe Redistat::Event do
before(:each) do
@scope = "PageViews"
@label = "/about/us"
@label_hash = Digest::SHA1.hexdigest(@label)
@now = Time.now
@event = Redistat::Event.new(@scope, @label, {:views => 1}, @now, {:depth => :hour})
end
it "should initialize properly"
end