norton 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52cebefc625bc8849d14c08a088a65213b46e8d5
4
- data.tar.gz: 4b0b03f6c8ce33efd2ee204069f7f9591486c9ca
3
+ metadata.gz: 20422c62cc84a467cf851caf000e326cad7a591b
4
+ data.tar.gz: bfef0b9673d1b27f2daa4b5660a6180860767d42
5
5
  SHA512:
6
- metadata.gz: 1186e9ab5f99dd6080ab6617c5f1ad1a860ab05ff200cec9da882c637246f32306b78bea44c0fce160ad644a692dcca2404c3abdd721fc32192670cb53c70c69
7
- data.tar.gz: 1f779ccd40aab40c2c2b559cb5f3248668c2a9e64efcfb222feae13565da158a915a5894274636a3347cdefe35ffa7eace6d50daa0ee612c69d1cf649461ffc1
6
+ metadata.gz: f70c087bb056a4f11c9d19216653b12b3699df906b05b06814206d08688bb72a0615beb052956a24cc190ad29374e8ceb5fec64b021850cdbe4876b2534d5f05
7
+ data.tar.gz: eefb0c5a1ed7201a01acf3a9aecc3d466fd964c90d9d2925633040e44dfa1abd50f71e30a6808458de04afa074272c07bce57a64855fcb0b9365dd664e3e1ce2
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source 'http://ruby.taobao.org'
2
2
 
3
3
  # Specify your gem's dependencies in norton.gemspec
4
4
  gemspec
@@ -9,7 +9,7 @@ module Norton
9
9
  # @param touches={} [type] [description]
10
10
  #
11
11
  # @return [type] [description]
12
- def timestamp(name, touches={})
12
+ def timestamp(name, options={})
13
13
  define_method(name) do
14
14
  ts = nil
15
15
 
@@ -27,17 +27,21 @@ module Norton
27
27
 
28
28
  define_method("touch_#{name}") do
29
29
  Norton.redis.with do |conn|
30
- conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", Time.now.to_i)
30
+ if options[:digits].present? && options[:digits] == 13
31
+ conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", (Time.now.to_f * 1000).to_i)
32
+ else
33
+ conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", Time.now.to_i)
34
+ end
31
35
  end
32
36
  end
33
37
 
34
38
  # Add callback
35
- unless touches.empty?
36
- touches.each do |callback, condition|
39
+ unless options[:touch_on].empty?
40
+ options[:touch_on].each do |callback, condition|
37
41
  self.send callback, proc{ if instance_eval(&condition) then instance_eval("touch_#{name}") end }
38
42
  end
39
43
  end
40
44
  end
41
45
  end
42
46
  end
43
- end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module Norton
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
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.8
4
+ version: 0.0.9
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-05-21 00:00:00.000000000 Z
11
+ date: 2015-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.4.5
167
+ rubygems_version: 2.4.7
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Provide simple helpers on persist values in redis for performance. Works