easy_redis 0.1.0 → 1.0.0

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: e2c7608b84ca28703f16633aaeab78a9147eec77
4
- data.tar.gz: afc1463e509c5a4601848b33c95d3b57b0217338
3
+ metadata.gz: 0599027ad5d267276bfbf6cc69332748e9a726fc
4
+ data.tar.gz: 2918ebe6d5525aaa8dd4e04f7af43a49c40695b2
5
5
  SHA512:
6
- metadata.gz: 88fcc844f823ac8e34c87ce68254bd60b26a234b2858677305519ff6e99837865334db9348623d3543f0af382efdfe8b9ad71dbc85b2430c417f4524fe6df383
7
- data.tar.gz: 122dc04851af1d39322b230959de780c565f2a552712ca11c32d5827cce8b778ce38e28a3fdb6342ac958f4888262d58858cbe0a29451fa87f2e43914da06f1d
6
+ metadata.gz: 094f2cfaf9cd6d8fbfa5a8d4432c278c78ffec05c2fbc69b35cb7d7ac2fbebdf8b6434aba367ed34e59098f464bd860ae6fa05e46af2d4274de7c7970b2f3494
7
+ data.tar.gz: c4ec05dc97137289c4100e1567bfd235e8455e01b0cf502f1ece99b85530cbc9e1a125e5c663ae91560a8d07b0ad76a8166680bac5f56c908c4b2e58a529ad35
Binary file
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "activerecord"
24
24
  spec.add_development_dependency "bundler", "~> 1.6"
25
25
  spec.add_development_dependency "rake"
26
- spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency "rspec"
27
27
  spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "sqlite3-ruby"
28
29
  end
Binary file
@@ -7,7 +7,7 @@ module EasyRedis
7
7
  end
8
8
 
9
9
  def method_missing(meth, *args, &block)
10
- (meth.to_s =~ /^redis_del_(.+)$/ || meth.to_s =~ /^r_del_(.+)$/) ? r_del($1) : super
10
+ (meth.to_s =~ /^redis_del_(.+)$/ || meth.to_s =~ /^r_del_(.+)$/ || meth.to_s =~ /^r_delete_(.+)$/ || meth.to_s =~ /^redis_delete_(.+)$/) ? r_del($1) : super
11
11
  end
12
12
 
13
13
  alias_method :r_delete, :r_del
@@ -1,3 +1,3 @@
1
1
  module EasyRedis
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -3,10 +3,7 @@ require 'spec_helper'
3
3
  describe EasyRedis::Redis do
4
4
 
5
5
  context 'redis method' do
6
- it 'should return nil object if redis did not setted' do
7
- expect(EasyRedis::Redis.redis).to eql(nil)
8
- end
9
- it 'should return nil object if redis did not setted' do
6
+ it 'should return redis object' do
10
7
  redis = Redis.new
11
8
  EasyRedis::Redis.configure(redis: redis)
12
9
  expect(EasyRedis::Redis.redis).to eql(redis)
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe EasyRedis::Deleters do
4
+
5
+ before(:each) do
6
+ @user = User.create(name: "Mehmet Emin")
7
+ @user.r_set("foo", true)
8
+ end
9
+
10
+ context 'r_del method' do
11
+ it 'should delete attribute from redis' do
12
+ @user.r_del("foo")
13
+ expect(@user.r_get("foo")).to eql(nil)
14
+ end
15
+ end
16
+
17
+ context 'redis_del method' do
18
+ it 'should delete attribute from redis' do
19
+ @user.redis_del("foo")
20
+ expect(@user.r_get("foo")).to eql(nil)
21
+ end
22
+ end
23
+
24
+ context 'r_delete method' do
25
+ it 'should delete attribute from redis' do
26
+ @user.r_delete("foo")
27
+ expect(@user.r_get("foo")).to eql(nil)
28
+ end
29
+ end
30
+
31
+ context 'redis_delete method' do
32
+ it 'should delete attribute from redis' do
33
+ @user.redis_delete("foo")
34
+ expect(@user.r_get("foo")).to eql(nil)
35
+ end
36
+ end
37
+
38
+ context 'r_del_attribute method' do
39
+ it 'should delete attribute from redis' do
40
+ @user.r_del_foo
41
+ expect(@user.r_get("foo")).to eql(nil)
42
+ end
43
+ end
44
+
45
+ context 'redis_del_attribute method' do
46
+ it 'should delete attribute from redis' do
47
+ @user.redis_del_foo
48
+ expect(@user.r_get("foo")).to eql(nil)
49
+ end
50
+ end
51
+
52
+ context 'r_delete_attribute method' do
53
+ it 'should delete attribute from redis' do
54
+ @user.r_delete_foo
55
+ expect(@user.r_get("foo")).to eql(nil)
56
+ end
57
+ end
58
+
59
+ context 'redis_delete_attribute method' do
60
+ it 'should delete attribute from redis' do
61
+ @user.redis_delete_foo
62
+ expect(@user.r_get("foo")).to eql(nil)
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe EasyRedis::Getters do
4
+
5
+ before(:each) do
6
+ @user = User.create(name: "Mehmet Emin")
7
+ @user.r_set("foo", true)
8
+ end
9
+
10
+ context 'r_get method' do
11
+ it 'should set value for given attribute and returns true' do
12
+ expect(@user.r_get("foo")).to eql(true)
13
+ end
14
+ end
15
+
16
+ context 'redis_get method' do
17
+ it 'should set value for given attribute and returns true' do
18
+ expect(@user.redis_get("foo")).to eql(true)
19
+ end
20
+ end
21
+
22
+ context 'r_get_attribute method' do
23
+ it 'should set value for given attribute and returns true' do
24
+ expect(@user.r_get_foo).to eql(true)
25
+ end
26
+ end
27
+
28
+ context 'redis_get_attribute method' do
29
+ it 'should set value for given attribute and returns true' do
30
+ expect(@user.redis_get_foo).to eql(true)
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe EasyRedis::Setters do
4
+
5
+ before(:each) do
6
+ @user = User.create(name: "Mehmet Emin")
7
+ end
8
+
9
+ context 'r_set method' do
10
+ it 'should raise error for new records' do
11
+ allow(EasyRedis::Redis).to receive(:raise_non_existent_object_error?) { true }
12
+ u = User.new
13
+ expect{u.r_set_foo "bar"}.to raise_error(NonExistentObjectError)
14
+ end
15
+ it 'should set value for given attribute and returns true' do
16
+ expect(@user.r_set("foo", "bar")).to eql(true)
17
+ end
18
+ it 'should update value for given attribute and returns false' do
19
+ @user.r_set("foo", "bar")
20
+ expect(@user.r_set("foo", "baz")).to eql(false)
21
+ end
22
+ end
23
+
24
+ context 'redis_set method' do
25
+ it 'should set value for given attribute and returns true' do
26
+ expect(@user.redis_set("foo", "bar")).to eql(true)
27
+ end
28
+ it 'should update value for given attribute and returns false' do
29
+ @user.redis_set("foo", "bar")
30
+ expect(@user.redis_set("foo", "baz")).to eql(false)
31
+ end
32
+ end
33
+
34
+ context 'r_set_attribute method' do
35
+ it 'should set value for given attribute and returns true' do
36
+ expect(@user.r_set_boo("bar")).to eql(true)
37
+ end
38
+ it 'should update value for given attribute and returns false' do
39
+ @user.r_set_foo("bar")
40
+ expect(@user.r_set_foo("baz")).to eql(false)
41
+ end
42
+ end
43
+
44
+ context 'redis_set_attribute method' do
45
+ it 'should set value for given attribute and returns true' do
46
+ expect(@user.redis_set_boo("bar")).to eql(true)
47
+ end
48
+ it 'should update value for given attribute and returns false' do
49
+ @user.redis_set_foo("bar")
50
+ expect(@user.redis_set_foo("baz")).to eql(false)
51
+ end
52
+ end
53
+
54
+ end
@@ -1,3 +1,14 @@
1
1
  require 'easy_redis'
2
2
  require 'pry'
3
- require 'redis'
3
+ require 'redis'
4
+ Dir["#{File.dirname(__FILE__)}/support/*.rb"].each {|f| require f }
5
+
6
+ RSpec.configure do |config|
7
+
8
+ EasyRedis::Redis.configure(redis: Redis.new)
9
+
10
+ config.after(:each) do
11
+ EasyRedis::Redis.redis.flushdb
12
+ end
13
+
14
+ end
@@ -0,0 +1,7 @@
1
+ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "easyredis")
2
+
3
+ ActiveRecord::Schema.define(version: 0) do
4
+ create_table :users, force: true do |t|
5
+ t.string :name
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class User < ActiveRecord::Base
2
+
3
+ validates_presence_of :name
4
+
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Emin İNAÇ
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3-ruby
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Creates getter and setter methods for redis store.
98
112
  email:
99
113
  - mehmetemininac@gmail.com
@@ -107,7 +121,9 @@ files:
107
121
  - LICENSE.txt
108
122
  - README.md
109
123
  - Rakefile
124
+ - easy_redis
110
125
  - easy_redis.gemspec
126
+ - easyredis
111
127
  - lib/easy_redis.rb
112
128
  - lib/easy_redis/easy_redis.rb
113
129
  - lib/easy_redis/errors/non_existent_object_error.rb
@@ -118,7 +134,12 @@ files:
118
134
  - lib/easy_redis/methods/setters.rb
119
135
  - lib/easy_redis/version/version.rb
120
136
  - spec/lib/easy_redis/easy_redis_spec.rb
137
+ - spec/lib/easy_redis/methods/deleters_spec.rb
138
+ - spec/lib/easy_redis/methods/getters_spec.rb
139
+ - spec/lib/easy_redis/methods/setters_spec.rb
121
140
  - spec/spec_helper.rb
141
+ - spec/support/db.rb
142
+ - spec/support/user.rb
122
143
  homepage: http://github.com/meinac/easy_redis
123
144
  licenses:
124
145
  - MIT
@@ -145,4 +166,9 @@ specification_version: 4
145
166
  summary: Less coding for redis store
146
167
  test_files:
147
168
  - spec/lib/easy_redis/easy_redis_spec.rb
169
+ - spec/lib/easy_redis/methods/deleters_spec.rb
170
+ - spec/lib/easy_redis/methods/getters_spec.rb
171
+ - spec/lib/easy_redis/methods/setters_spec.rb
148
172
  - spec/spec_helper.rb
173
+ - spec/support/db.rb
174
+ - spec/support/user.rb