norton 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/norton/counter.rb +5 -5
- data/lib/norton/timestamp.rb +4 -4
- data/lib/norton/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e366ba864730fb31251486d7479e432cda85e9ba
|
4
|
+
data.tar.gz: cc2c33ec37f5a2ce287546fa341a6cfba5bdd4e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e3fed01e4b0c1135df0e69d214dbf52fe56b1cd4ac6c88690604502be9db2ce78240170714cda8ffc02047d23ffdcc38451760a692434fc5af952a8d152573c
|
7
|
+
data.tar.gz: 1111b8b4ffb59c9b2108fe6ea76502241144e624455398d120434656abc38d2da6bb623070a792aa058d1579f2e1be1c617107cb4f588f23183f887d68bdb0ab
|
data/lib/norton/counter.rb
CHANGED
@@ -13,25 +13,25 @@ module Norton
|
|
13
13
|
def counter(name, options={}, &blk)
|
14
14
|
define_method(name) do
|
15
15
|
Norton.redis.with do |conn|
|
16
|
-
conn.get("#{self.class.to_s.pluralize.
|
16
|
+
conn.get("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}").try(:to_i) || 0
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
define_method("incr_#{name}") do
|
21
21
|
Norton.redis.with do |conn|
|
22
|
-
conn.incr("#{self.class.to_s.pluralize.
|
22
|
+
conn.incr("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
define_method("decr_#{name}") do
|
27
27
|
Norton.redis.with do |conn|
|
28
|
-
conn.decr("#{self.class.to_s.pluralize.
|
28
|
+
conn.decr("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
define_method("#{name}=") do |v|
|
33
33
|
Norton.redis.with do |conn|
|
34
|
-
conn.set("#{self.class.to_s.pluralize.
|
34
|
+
conn.set("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}", v)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,7 +39,7 @@ module Norton
|
|
39
39
|
count = instance_eval(&blk)
|
40
40
|
|
41
41
|
Norton.redis.with do |conn|
|
42
|
-
conn.set("#{self.class.to_s.pluralize.
|
42
|
+
conn.set("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}", count)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/lib/norton/timestamp.rb
CHANGED
@@ -14,11 +14,11 @@ module Norton
|
|
14
14
|
ts = nil
|
15
15
|
|
16
16
|
Norton.redis.with do |conn|
|
17
|
-
ts = conn.get("#{self.class.to_s.pluralize.
|
17
|
+
ts = conn.get("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}").try(:to_i)
|
18
18
|
|
19
19
|
if ts.nil?
|
20
20
|
ts = Time.now.to_i
|
21
|
-
conn.set("#{self.class.to_s.pluralize.
|
21
|
+
conn.set("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}", ts)
|
22
22
|
end
|
23
23
|
|
24
24
|
ts
|
@@ -28,9 +28,9 @@ module Norton
|
|
28
28
|
define_method("touch_#{name}") do
|
29
29
|
Norton.redis.with do |conn|
|
30
30
|
if options[:digits].present? && options[:digits] == 13
|
31
|
-
conn.set("#{self.class.to_s.pluralize.
|
31
|
+
conn.set("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}", (Time.now.to_f * 1000).to_i)
|
32
32
|
else
|
33
|
-
conn.set("#{self.class.to_s.pluralize.
|
33
|
+
conn.set("#{self.class.to_s.pluralize.underscore}:#{self.id}:#{name}", Time.now.to_i)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/norton/version.rb
CHANGED