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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8de7d288d5c2e1b54399508842ffc761063d2bbf
4
- data.tar.gz: b2cb45b37ca12fa36e8adf03455220fba96153ea
3
+ metadata.gz: cbb10d14e0bb84de906695604f612419d0cf08bc
4
+ data.tar.gz: 115421a1dc95e880f86c5edc172dd88483dca2cf
5
5
  SHA512:
6
- metadata.gz: afeb424fb75456de2a6dafa5eb1285dc6bdf6e6fbdca78e1b1c5e8bb819a60da37957a108d638747030c134c94f71aef55349533bd1cde6bd3fa73494dfcff43
7
- data.tar.gz: 38a31ffb7c30e55f60061abd6e49be42955ffa4a9cc8b59b3a7bcff8aa68c49ad03aefd145808ee6ef310f2ffc83144005b145d5484bde8e74632c2ab5adb46f
6
+ metadata.gz: 09e28c1dd8c068c30917a588e92c4f59a6062e42f4165848ce0c48586443a77152d7bdf8a992776b8eb51d435110c5a4bbc37bbc41eae48f29cdf34eb696e1b3
7
+ data.tar.gz: f94aaedf2d9ae8106a13998f77c6af5f175a2d47dd9782e1d48f5d0519c7509b0cba4070c9c6ac14cd86cad609159f773e29a3ff440fe4174eee026437b11da3
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+
3
+ services:
4
+ - redis-server
5
+
6
+ rvm:
7
+ - 2.3.0
8
+
9
+ script:
10
+ - RAILS_ENV=test bundle exec rake
11
+
12
+ notifications:
13
+ email: false
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://ruby.taobao.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in norton.gemspec
4
4
  gemspec
@@ -1,5 +1,5 @@
1
1
  module Norton
2
- module Hash
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::HashMap.new(norton_field_key(name))
10
+ Norton::Objects::Hash.new(norton_field_key(name))
11
11
  )
12
12
  end
13
13
 
@@ -1,6 +1,6 @@
1
1
  module Norton
2
2
  module Objects
3
- class HashMap
3
+ class Hash
4
4
  attr_reader :key
5
5
 
6
6
  def initialize(key)
@@ -1,3 +1,3 @@
1
1
  module Norton
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
3
3
  end
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/hash_map"
11
- require "norton/hash"
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 HashObject
4
- include Norton::Hash
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::Hash do
13
+ describe Norton::HashMap do
14
14
  describe "#norton_field_key" do
15
15
  it "generates the correct field key" do
16
- object = HashObject.new
17
- expect(object.norton_field_key(:profile)).to eq("hash_objects:99:profile")
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 = HashObject.new
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 = HashObject.new
31
- expect(object.profile).to be_a(Norton::Objects::HashMap)
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::HashMap do
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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::HashMap.new("users:99:profile")
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.20
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-15 00:00:00.000000000 Z
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/hash.rb
184
+ - lib/norton/hash_map.rb
184
185
  - lib/norton/helper.rb
185
- - lib/norton/objects/hash_map.rb
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/hash_spec.rb
192
+ - spec/norton/hash_map_spec.rb
192
193
  - spec/norton/helper_spec.rb
193
- - spec/norton/objects/hash_map_spec.rb
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/hash_spec.rb
225
+ - spec/norton/hash_map_spec.rb
225
226
  - spec/norton/helper_spec.rb
226
- - spec/norton/objects/hash_map_spec.rb
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