counters 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/lib/counters/base.rb +14 -1
- data/lib/counters/version.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- metadata +2 -2
data/README.textile
CHANGED
@@ -81,7 +81,7 @@ Instantiate a StatsD instance:
|
|
81
81
|
Counter = Counters::StatsD.new(:url => "udp://127.0.0.1:8125", :namespace => "crawler")
|
82
82
|
</code></pre>
|
83
83
|
|
84
|
-
See the file "samples/crawler.rb":blob/master/samples/crawler.rb for a more detailed example.
|
84
|
+
See the file "samples/crawler.rb":https://github.com/francois/counters/blob/master/samples/crawler.rb for a more detailed example.
|
85
85
|
|
86
86
|
h2. LICENSE
|
87
87
|
|
data/lib/counters/base.rb
CHANGED
@@ -2,9 +2,11 @@ require "benchmark"
|
|
2
2
|
|
3
3
|
module Counters
|
4
4
|
class Base
|
5
|
-
|
5
|
+
|
6
|
+
attr_writer :namespace
|
6
7
|
|
7
8
|
def initialize(options={})
|
9
|
+
@options = options
|
8
10
|
@namespace = options[:namespace]
|
9
11
|
end
|
10
12
|
|
@@ -35,6 +37,16 @@ module Counters
|
|
35
37
|
record_ping(namespaced_key(key))
|
36
38
|
end
|
37
39
|
|
40
|
+
def namespace(*args)
|
41
|
+
if args.empty? then
|
42
|
+
@namespace
|
43
|
+
else
|
44
|
+
other = self.dup
|
45
|
+
other.namespace = [@namespace.to_s, args.first].join(".")
|
46
|
+
other
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
38
50
|
def record_hit(key)
|
39
51
|
raise "Subclass Responsibility Error: must be implemented in instances of #{self.class} but isn't"
|
40
52
|
end
|
@@ -65,5 +77,6 @@ module Counters
|
|
65
77
|
"#{namespace}.#{key}"
|
66
78
|
end
|
67
79
|
private :namespaced_key
|
80
|
+
|
68
81
|
end
|
69
82
|
end
|
data/lib/counters/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: counters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Fran\xC3\xA7ois Beausoleil"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-31 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|