redisable 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/redisable.rb +2 -2
- data/lib/redisable/{kvs_key.rb → key.rb} +4 -4
- data/lib/redisable/version.rb +1 -1
- data/spec/{kvs_key_spec.rb → key_spec.rb} +6 -6
- data/spec/redisable_spec.rb +3 -3
- metadata +26 -16
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -56,10 +56,10 @@ class User < ActiveRecord::Base
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
class UserStatus
|
59
|
+
class UserStatus < ActionController::Base
|
60
60
|
include Redisable
|
61
|
-
|
62
|
-
|
61
|
+
redis_key :followers_ids
|
62
|
+
redis_key :unread_news_ids
|
63
63
|
|
64
64
|
def initialize(id)
|
65
65
|
@user_id = id
|
data/lib/redisable.rb
CHANGED
@@ -4,12 +4,12 @@ require "redis"
|
|
4
4
|
module Redisable
|
5
5
|
autoload :Config, "redisable/config"
|
6
6
|
autoload :Connection, "redisable/connection"
|
7
|
-
autoload :
|
7
|
+
autoload :Key, "redisable/key"
|
8
8
|
|
9
9
|
def self.included(base)
|
10
10
|
base.extend ClassMethods
|
11
11
|
base.send :include, InstanceMethods
|
12
|
-
base.send :include,
|
12
|
+
base.send :include, Key
|
13
13
|
end
|
14
14
|
|
15
15
|
module ClassMethods
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module Redisable
|
3
|
-
module
|
3
|
+
module Key
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
# return model_name:id:field_name
|
10
|
-
def
|
10
|
+
def redis_key(name, options={})
|
11
11
|
klass_name ||= self.name
|
12
12
|
define_method(name) do |id_=nil|
|
13
13
|
id_ ||= if options[:id]
|
@@ -15,11 +15,11 @@ module Redisable
|
|
15
15
|
else
|
16
16
|
self.id
|
17
17
|
end
|
18
|
-
|
18
|
+
Key.join_key(klass_name, id_, name, options[:blank_field])
|
19
19
|
end
|
20
20
|
define_singleton_method(name) do |id_=nil|
|
21
21
|
id_ ||= options[:id].call(self)
|
22
|
-
|
22
|
+
Key.join_key(klass_name, id_, name, options[:blank_field])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/redisable/version.rb
CHANGED
@@ -2,27 +2,27 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
class User
|
5
|
-
include Redisable::
|
5
|
+
include Redisable::Key
|
6
6
|
end
|
7
7
|
|
8
|
-
describe Redisable::
|
8
|
+
describe Redisable::Key do
|
9
9
|
describe ".join_key" do
|
10
10
|
context "Field name is not blank" do
|
11
11
|
it "join with ':' specified key, id and name" do
|
12
|
-
Redisable::
|
12
|
+
Redisable::Key.join_key("user", "100", "status", false).should == "user:100:status"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
context "Field name is blank" do
|
17
17
|
it "join with ':' specified key, id" do
|
18
|
-
Redisable::
|
18
|
+
Redisable::Key.join_key("user", "100", "status", true).should == "user:100"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "to include" do
|
24
|
-
it "defined '
|
25
|
-
defined?(User.
|
24
|
+
it "defined 'redis_key' method" do
|
25
|
+
defined?(User.redis_key).should == "method"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/spec/redisable_spec.rb
CHANGED
@@ -8,12 +8,12 @@ describe Redisable do
|
|
8
8
|
it "autoload modules" do
|
9
9
|
defined?(Redisable::Config).should == "constant"
|
10
10
|
defined?(Redisable::Connection).should == "constant"
|
11
|
-
defined?(Redisable::
|
11
|
+
defined?(Redisable::Key).should == "constant"
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Include module" do
|
15
|
-
it "define
|
16
|
-
defined?(User.
|
15
|
+
it "define redis_key method" do
|
16
|
+
defined?(User.redis_key).should == "method"
|
17
17
|
end
|
18
18
|
it "define redis method" do
|
19
19
|
defined?(User.redis).should == "method"
|
metadata
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redisable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- yoppi
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-04
|
12
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: redis
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: bundler
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,29 +46,33 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rake
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rspec
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
description: Thin wrapper library for Redis, enable any Ruby class to access Redis.
|
@@ -82,42 +91,43 @@ files:
|
|
82
91
|
- lib/redisable.rb
|
83
92
|
- lib/redisable/config.rb
|
84
93
|
- lib/redisable/connection.rb
|
85
|
-
- lib/redisable/
|
94
|
+
- lib/redisable/key.rb
|
86
95
|
- lib/redisable/version.rb
|
87
96
|
- redisable.gemspec
|
88
97
|
- spec/config_spec.rb
|
89
98
|
- spec/connection_spec.rb
|
90
|
-
- spec/
|
99
|
+
- spec/key_spec.rb
|
91
100
|
- spec/redisable_spec.rb
|
92
101
|
- spec/spec_helper.rb
|
93
102
|
homepage: http://github.com/yoppi/redisable
|
94
103
|
licenses:
|
95
104
|
- MIT
|
96
|
-
metadata: {}
|
97
105
|
post_install_message:
|
98
106
|
rdoc_options: []
|
99
107
|
require_paths:
|
100
108
|
- lib
|
101
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
102
111
|
requirements:
|
103
|
-
- - '>='
|
112
|
+
- - ! '>='
|
104
113
|
- !ruby/object:Gem::Version
|
105
114
|
version: '0'
|
106
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
107
117
|
requirements:
|
108
|
-
- - '>='
|
118
|
+
- - ! '>='
|
109
119
|
- !ruby/object:Gem::Version
|
110
120
|
version: '0'
|
111
121
|
requirements: []
|
112
122
|
rubyforge_project:
|
113
|
-
rubygems_version:
|
123
|
+
rubygems_version: 1.8.23
|
114
124
|
signing_key:
|
115
|
-
specification_version:
|
125
|
+
specification_version: 3
|
116
126
|
summary: Thin wrapper library for Redis.
|
117
127
|
test_files:
|
118
128
|
- spec/config_spec.rb
|
119
129
|
- spec/connection_spec.rb
|
120
|
-
- spec/
|
130
|
+
- spec/key_spec.rb
|
121
131
|
- spec/redisable_spec.rb
|
122
132
|
- spec/spec_helper.rb
|
123
133
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 2e8d5906a34c29ae4e302386f7bfef20a9b1e8a6
|
4
|
-
data.tar.gz: c7dc0d17e489374762a9679a296581d2d48854bb
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 85af8c2c234195956e15233fb2f6b95e986170d460ef20ec3a41551d1ee0471b87a6e68a93e7cfe6f58383140d99f1c4f81541902ea790928b3606f24daa4adf
|
7
|
-
data.tar.gz: 4c878c500a9437678298811795004bba2a13073859c1fd22243824cd82009770052952492d67efe2550c9bc363b6e4625ac8a98dd5e6a09afccd0f074fbf95f7
|