redistat 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/redistat/key.rb CHANGED
@@ -61,7 +61,6 @@ module Redistat
61
61
 
62
62
  def update_index
63
63
  @label.groups.each do |label|
64
- # break if label.parent.nil?
65
64
  parent = (label.parent || "")
66
65
  db.sadd("#{scope}#{LABEL_INDEX}#{parent}", label.me)
67
66
  end
@@ -11,6 +11,11 @@ module Redistat
11
11
  self.new(name, opts).save
12
12
  end
13
13
 
14
+ def self.join(*args)
15
+ args = args.map {|i| i.to_s}
16
+ self.new(args.reject {|i| i.blank? }.join(GROUP_SEPARATOR))
17
+ end
18
+
14
19
  def initialize(str, opts = {})
15
20
  parse_options(opts)
16
21
  @raw = str.to_s
@@ -1,3 +1,3 @@
1
1
  module Redistat
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/redistat.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency 'activesupport', '>= 2.3.6'
23
23
  s.add_runtime_dependency 'json', '>= 1.4.0'
24
24
  s.add_runtime_dependency 'redis', '>= 2.1.0'
25
- s.add_runtime_dependency 'time_ext', '>= 0.2.8'
25
+ s.add_runtime_dependency 'time_ext', '>= 0.2.9'
26
26
 
27
27
  s.add_development_dependency 'rspec', '>= 2.1.0'
28
28
  s.add_development_dependency 'rcov', '>= 0.9.9'
data/spec/key_spec.rb CHANGED
@@ -28,6 +28,8 @@ describe Redistat::Key do
28
28
  @key.to_s(props.last).should == "#{@scope}/#{@label}:#{@key.date.to_s(props.last)}"
29
29
  props.pop
30
30
  end
31
+ key = Redistat::Key.new(@scope, nil, @date, {:depth => :hour})
32
+ key.to_s.should == "#{@scope}:#{key.date.to_s(:hour)}"
31
33
  end
32
34
 
33
35
  it "should abide to hashed_label option" do
data/spec/label_spec.rb CHANGED
@@ -25,6 +25,19 @@ describe Redistat::Label do
25
25
  db.hget(Redistat::KEY_LABELS, label.hash).should == name
26
26
  end
27
27
 
28
+ it "should join labels" do
29
+ include Redistat
30
+ label = Label.join('email', 'message', 'public')
31
+ label.should be_a(Label)
32
+ label.to_s.should == 'email/message/public'
33
+ label = Label.join(Label.new('email'), Label.new('message'), Label.new('public'))
34
+ label.should be_a(Label)
35
+ label.to_s.should == 'email/message/public'
36
+ label = Label.join('email', '', 'message', nil, 'public')
37
+ label.should be_a(Label)
38
+ label.to_s.should == 'email/message/public'
39
+ end
40
+
28
41
  describe "Grouping" do
29
42
  before(:each) do
30
43
  @name = "message/public/offensive"
data/spec/summary_spec.rb CHANGED
@@ -46,6 +46,15 @@ describe Redistat::Summary do
46
46
  end
47
47
  end
48
48
 
49
+ it "should update summaries even if no label is set" do
50
+ key = Redistat::Key.new(@scope, nil, @date, {:depth => :day})
51
+ Redistat::Summary.update(key, @stats, :hour)
52
+ summary = db.hgetall(key.to_s(:hour))
53
+ summary.should have(2).items
54
+ summary["views"].should == "3"
55
+ summary["visitors"].should == "2"
56
+ end
57
+
49
58
  it "should inject stats key grouping summaries" do
50
59
  hash = { "count/hello" => 3, "count/world" => 7,
51
60
  "death/bomb" => 4, "death/unicorn" => 3,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redistat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Myhrberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-13 00:00:00 +00:00
18
+ date: 2011-03-14 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -74,12 +74,12 @@ dependencies:
74
74
  requirements:
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
- hash: 7
77
+ hash: 5
78
78
  segments:
79
79
  - 0
80
80
  - 2
81
- - 8
82
- version: 0.2.8
81
+ - 9
82
+ version: 0.2.9
83
83
  type: :runtime
84
84
  version_requirements: *id004
85
85
  - !ruby/object:Gem::Dependency
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  requirements: []
223
223
 
224
224
  rubyforge_project: redistat
225
- rubygems_version: 1.6.1
225
+ rubygems_version: 1.5.0
226
226
  signing_key:
227
227
  specification_version: 3
228
228
  summary: A Redis-backed statistics storage and querying library written in Ruby.