norton 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/Gemfile +1 -1
- data/lib/norton/{hash.rb → hash_map.rb} +2 -2
- data/lib/norton/objects/{hash_map.rb → hash.rb} +1 -1
- data/lib/norton/version.rb +1 -1
- data/lib/norton.rb +2 -2
- data/spec/norton/{hash_spec.rb → hash_map_spec.rb} +8 -8
- data/spec/norton/objects/{hash_map_spec.rb → hash_spec.rb} +13 -13
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbb10d14e0bb84de906695604f612419d0cf08bc
|
4
|
+
data.tar.gz: 115421a1dc95e880f86c5edc172dd88483dca2cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09e28c1dd8c068c30917a588e92c4f59a6062e42f4165848ce0c48586443a77152d7bdf8a992776b8eb51d435110c5a4bbc37bbc41eae48f29cdf34eb696e1b3
|
7
|
+
data.tar.gz: f94aaedf2d9ae8106a13998f77c6af5f175a2d47dd9782e1d48f5d0519c7509b0cba4070c9c6ac14cd86cad609159f773e29a3ff440fe4174eee026437b11da3
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Norton
|
2
|
-
module
|
2
|
+
module HashMap
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
@@ -7,7 +7,7 @@ module Norton
|
|
7
7
|
define_method(name) do
|
8
8
|
instance_variable_get("@#{name}") ||
|
9
9
|
instance_variable_set("@#{name}",
|
10
|
-
Norton::Objects::
|
10
|
+
Norton::Objects::Hash.new(norton_field_key(name))
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
data/lib/norton/version.rb
CHANGED
data/lib/norton.rb
CHANGED
@@ -7,8 +7,8 @@ require "norton/timestamp"
|
|
7
7
|
require "norton/counter"
|
8
8
|
require "norton/timed_value"
|
9
9
|
require "norton/helper"
|
10
|
-
require "norton/objects/
|
11
|
-
require "norton/
|
10
|
+
require "norton/objects/hash"
|
11
|
+
require "norton/hash_map"
|
12
12
|
|
13
13
|
module Norton
|
14
14
|
class NilObjectId < StandardError; end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
include Norton::
|
3
|
+
class HashMapObject
|
4
|
+
include Norton::HashMap
|
5
5
|
|
6
6
|
hash_map :profile
|
7
7
|
|
@@ -10,15 +10,15 @@ class HashObject
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe Norton::
|
13
|
+
describe Norton::HashMap do
|
14
14
|
describe "#norton_field_key" do
|
15
15
|
it "generates the correct field key" do
|
16
|
-
object =
|
17
|
-
expect(object.norton_field_key(:profile)).to eq("
|
16
|
+
object = HashMapObject.new
|
17
|
+
expect(object.norton_field_key(:profile)).to eq("hash_map_objects:99:profile")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "raises NilObjectId if the object id is nil" do
|
21
|
-
object =
|
21
|
+
object = HashMapObject.new
|
22
22
|
allow(object).to receive(:id) { nil }
|
23
23
|
|
24
24
|
expect { object.norton_field_key(:profile) }.to raise_error(Norton::NilObjectId)
|
@@ -27,8 +27,8 @@ describe Norton::Hash do
|
|
27
27
|
|
28
28
|
describe "#hash_map" do
|
29
29
|
it "sets a instance variable" do
|
30
|
-
object =
|
31
|
-
expect(object.profile).to be_a(Norton::Objects::
|
30
|
+
object = HashMapObject.new
|
31
|
+
expect(object.profile).to be_a(Norton::Objects::Hash)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Norton::Objects::
|
3
|
+
describe Norton::Objects::Hash do
|
4
4
|
describe "#hset" do
|
5
5
|
it "saves the value of the field in redis" do
|
6
|
-
hash_map = Norton::Objects::
|
6
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
7
7
|
hash_map.hset(:name, "Bob")
|
8
8
|
expect(Norton.redis.with { |conn| conn.hget(hash_map.key, :name) }).to eq("Bob")
|
9
9
|
end
|
@@ -11,7 +11,7 @@ describe Norton::Objects::HashMap do
|
|
11
11
|
|
12
12
|
describe "#hget" do
|
13
13
|
it "returns the value of the field from redis" do
|
14
|
-
hash_map = Norton::Objects::
|
14
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
15
15
|
hash_map.hset(:name, "Bob")
|
16
16
|
|
17
17
|
expect(hash_map.hget(:name)).to eq("Bob")
|
@@ -20,7 +20,7 @@ describe Norton::Objects::HashMap do
|
|
20
20
|
|
21
21
|
describe "#hdel" do
|
22
22
|
it "deletes the field from redis" do
|
23
|
-
hash_map = Norton::Objects::
|
23
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
24
24
|
hash_map.hset(:name, "Bob")
|
25
25
|
|
26
26
|
hash_map.hdel(:name)
|
@@ -29,7 +29,7 @@ describe Norton::Objects::HashMap do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "deletes multiple fields from redis" do
|
32
|
-
hash_map = Norton::Objects::
|
32
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
33
33
|
hash_map.hset(:name, "Bob")
|
34
34
|
hash_map.hset(:age, 21)
|
35
35
|
|
@@ -42,7 +42,7 @@ describe Norton::Objects::HashMap do
|
|
42
42
|
|
43
43
|
describe "#hmget" do
|
44
44
|
it "returns the values associated with the specified fields in the hash" do
|
45
|
-
hash_map = Norton::Objects::
|
45
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
46
46
|
hash_map.hset(:name, "Bob")
|
47
47
|
hash_map.hset(:age, 21)
|
48
48
|
|
@@ -52,7 +52,7 @@ describe Norton::Objects::HashMap do
|
|
52
52
|
|
53
53
|
describe "#hincrby" do
|
54
54
|
it "increments value by integer at field" do
|
55
|
-
hash_map = Norton::Objects::
|
55
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
56
56
|
hash_map.hset(:age, 21)
|
57
57
|
|
58
58
|
hash_map.hincrby(:age, 2)
|
@@ -60,7 +60,7 @@ describe Norton::Objects::HashMap do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "increments value by 1" do
|
63
|
-
hash_map = Norton::Objects::
|
63
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
64
64
|
hash_map.hset(:age, 21)
|
65
65
|
|
66
66
|
hash_map.hincrby(:age)
|
@@ -70,7 +70,7 @@ describe Norton::Objects::HashMap do
|
|
70
70
|
|
71
71
|
describe "#hdecrby" do
|
72
72
|
it "decrements value by integer at field" do
|
73
|
-
hash_map = Norton::Objects::
|
73
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
74
74
|
hash_map.hset(:age, 21)
|
75
75
|
|
76
76
|
hash_map.hdecrby(:age, 2)
|
@@ -80,14 +80,14 @@ describe Norton::Objects::HashMap do
|
|
80
80
|
|
81
81
|
describe "#hexists" do
|
82
82
|
it "returns true if the field exists in redis" do
|
83
|
-
hash_map = Norton::Objects::
|
83
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
84
84
|
hash_map.hset(:name, "Bob")
|
85
85
|
|
86
86
|
expect(hash_map.hexists(:name)).to be(true)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "returns false if the field doesn't exist in redis" do
|
90
|
-
hash_map = Norton::Objects::
|
90
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
91
91
|
|
92
92
|
expect(hash_map.hexists(:name)).to be(false)
|
93
93
|
end
|
@@ -95,7 +95,7 @@ describe Norton::Objects::HashMap do
|
|
95
95
|
|
96
96
|
describe "#hkeys" do
|
97
97
|
it "returns all keys in a hash" do
|
98
|
-
hash_map = Norton::Objects::
|
98
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
99
99
|
hash_map.hset(:name, "Bob")
|
100
100
|
hash_map.hset(:age, 21)
|
101
101
|
|
@@ -105,7 +105,7 @@ describe Norton::Objects::HashMap do
|
|
105
105
|
|
106
106
|
describe "#clear" do
|
107
107
|
it "deletes the hash from redis" do
|
108
|
-
hash_map = Norton::Objects::
|
108
|
+
hash_map = Norton::Objects::Hash.new("users:99:profile")
|
109
109
|
hash_map.hset(:name, "Bob")
|
110
110
|
|
111
111
|
hash_map.clear
|
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.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -173,6 +173,7 @@ extra_rdoc_files: []
|
|
173
173
|
files:
|
174
174
|
- ".gitignore"
|
175
175
|
- ".rspec"
|
176
|
+
- ".travis.yml"
|
176
177
|
- Gemfile
|
177
178
|
- LICENSE
|
178
179
|
- LICENSE.txt
|
@@ -180,17 +181,17 @@ files:
|
|
180
181
|
- Rakefile
|
181
182
|
- lib/norton.rb
|
182
183
|
- lib/norton/counter.rb
|
183
|
-
- lib/norton/
|
184
|
+
- lib/norton/hash_map.rb
|
184
185
|
- lib/norton/helper.rb
|
185
|
-
- lib/norton/objects/
|
186
|
+
- lib/norton/objects/hash.rb
|
186
187
|
- lib/norton/timed_value.rb
|
187
188
|
- lib/norton/timestamp.rb
|
188
189
|
- lib/norton/version.rb
|
189
190
|
- norton.gemspec
|
190
191
|
- spec/norton/counter_spec.rb
|
191
|
-
- spec/norton/
|
192
|
+
- spec/norton/hash_map_spec.rb
|
192
193
|
- spec/norton/helper_spec.rb
|
193
|
-
- spec/norton/objects/
|
194
|
+
- spec/norton/objects/hash_spec.rb
|
194
195
|
- spec/norton/timestamp_spec.rb
|
195
196
|
- spec/norton_spec.rb
|
196
197
|
- spec/spec_helper.rb
|
@@ -221,9 +222,9 @@ summary: Provide simple helpers on persist values in redis for performance. Work
|
|
221
222
|
with ActiveRecord.
|
222
223
|
test_files:
|
223
224
|
- spec/norton/counter_spec.rb
|
224
|
-
- spec/norton/
|
225
|
+
- spec/norton/hash_map_spec.rb
|
225
226
|
- spec/norton/helper_spec.rb
|
226
|
-
- spec/norton/objects/
|
227
|
+
- spec/norton/objects/hash_spec.rb
|
227
228
|
- spec/norton/timestamp_spec.rb
|
228
229
|
- spec/norton_spec.rb
|
229
230
|
- spec/spec_helper.rb
|