norton 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/norton/counter.rb +1 -1
- data/lib/norton/timestamp.rb +8 -1
- data/lib/norton/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3d218b2bff9e0a867ec67221c1eeb8a2759fbe7
|
4
|
+
data.tar.gz: 168813296e582bb141da14a8e09d5fca605bbe68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9239c23469e7b94fbee668808b9dc742ad6e4fb8d833d0d140f291a004e00405e24a2c94d41b2d46abdc959f790aa851fd31e688e63ae215a330b4ea1fea1a90
|
7
|
+
data.tar.gz: fa2a530be3592c7c9eb9b1f0b80a5f2eb9849e8131f2a19e6a10f56fdf1dfcaca9ced81ea92bc30f043a22ef8b985b94275bccbfe5d7ca53cab091857dd3e5e2
|
data/lib/norton/counter.rb
CHANGED
@@ -9,7 +9,7 @@ module Norton
|
|
9
9
|
# @param touches={} [type] [description]
|
10
10
|
#
|
11
11
|
# @return [type] [description]
|
12
|
-
def counter(name, options, &blk)
|
12
|
+
def counter(name, options={}, &blk)
|
13
13
|
define_method(name) do
|
14
14
|
Norton.redis.with do |conn|
|
15
15
|
conn.get("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}").try(:to_i) || 0
|
data/lib/norton/timestamp.rb
CHANGED
@@ -12,8 +12,15 @@ module Norton
|
|
12
12
|
def timestamp(name, touches={})
|
13
13
|
define_method(name) do
|
14
14
|
Norton.redis.with do |conn|
|
15
|
-
conn.get("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}").try(:to_i)
|
15
|
+
ts = conn.get("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}").try(:to_i)
|
16
|
+
|
17
|
+
if ts.nil?
|
18
|
+
ts = Time.now.to_i
|
19
|
+
conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", ts)
|
20
|
+
end
|
16
21
|
end
|
22
|
+
|
23
|
+
ts
|
17
24
|
end
|
18
25
|
|
19
26
|
define_method("touch_#{name}") do
|
data/lib/norton/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: norton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|