redis_storage 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +3 -2
- data/README +24 -1
- data/lib/redis_storage/version.rb +1 -1
- data/lib/redis_storage.rb +1 -1
- data/spec/model_spec.rb +5 -5
- data/spec/spec_helper.rb +1 -1
- data/test/generator_test.rb +1 -1
- metadata +4 -4
data/.rvmrc
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#rvm use rbx-2.0.0pre@redisrecord --create
|
2
2
|
#export RBXOPT=-Xrbc.db=$HOME/.rbx
|
3
|
-
rvm use
|
3
|
+
rvm use 1.9.2@redisrecord --create
|
4
4
|
|
5
|
+
#install bundler if its not already
|
5
6
|
if ! command -v bundle ; then
|
6
7
|
gem install bundler
|
7
8
|
fi
|
8
|
-
# Bundle while
|
9
|
+
# Bundle while reducing excess noise.
|
9
10
|
bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
|
data/README
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
RedisStorage
|
2
2
|
---
|
3
3
|
|
4
|
-
|
4
|
+
This is a little gem which provides a redis interface for models. It works out of the box with rails or can be used standalone.
|
5
|
+
|
6
|
+
Basically I just got sick rewriting the same logic over and over again for each model of my little sinatra apps so this evolved. Then I wanted to write a new rails app an thought having this in a gem would be really nice, and a generator would be awesome.
|
7
|
+
|
8
|
+
Features
|
9
|
+
---
|
10
|
+
|
11
|
+
* stores the attributes_hash of the model as JSON in redis
|
12
|
+
* creates an index of all used ids(which will be set automatically)
|
13
|
+
* compatible with the default rails controller
|
5
14
|
* uses ActiveModel to provide things like validations
|
6
15
|
* provides a Rails 3 Generator
|
7
16
|
|
17
|
+
Roadmap aka. ToDo
|
18
|
+
---
|
19
|
+
|
20
|
+
* some wrappers for searching in a model(probably will need some indexes)
|
21
|
+
* add something to make it easy to add an index(but there will be the update problematic)
|
22
|
+
* perhaps some kind of dirty flag - or the ActiveModel::Dirty module, but that will make some things way more complicated
|
23
|
+
* more tests/specs are always good
|
24
|
+
|
8
25
|
Installation
|
9
26
|
---
|
10
27
|
|
@@ -74,6 +91,12 @@ or
|
|
74
91
|
meta
|
75
92
|
---
|
76
93
|
|
94
|
+
Tested with RSpec and testunit for the generator for
|
95
|
+
* ree-1.8.7-2011.03
|
96
|
+
* MRI 1.9.2
|
97
|
+
* rbx
|
98
|
+
* rbx-2.0.0pre
|
99
|
+
|
77
100
|
Inspired by
|
78
101
|
|
79
102
|
* some ideas from the redis backend in [scanty-redis](https://github.com/adamwiggins/scanty-redis)
|
data/lib/redis_storage.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe RedisStorage::Model do
|
|
14
14
|
|
15
15
|
context 'class' do
|
16
16
|
it 'should have a db_key with the name of the class' do
|
17
|
-
MockModel.db_key.should eq('
|
17
|
+
MockModel.db_key.should eq('MockModel')
|
18
18
|
end
|
19
19
|
context '#build' do
|
20
20
|
it 'should simply call new on MockModel' do
|
@@ -117,11 +117,11 @@ describe RedisStorage::Model do
|
|
117
117
|
end
|
118
118
|
it 'should create a redis entry' do
|
119
119
|
id = model.save
|
120
|
-
JSON.parse($db.get("
|
120
|
+
JSON.parse($db.get("MockModel:#{id}")).should == modelhash.merge('id'=>id)
|
121
121
|
end
|
122
122
|
it 'should add the id to the persisted set in redis' do
|
123
123
|
id = model.save
|
124
|
-
$db.sismember("
|
124
|
+
$db.sismember("MockModel:persisted", id).should be_true
|
125
125
|
end
|
126
126
|
end
|
127
127
|
context '#update_attributes' do
|
@@ -146,12 +146,12 @@ describe RedisStorage::Model do
|
|
146
146
|
it 'should remove the key from redis' do
|
147
147
|
id=model.save
|
148
148
|
model.delete!
|
149
|
-
$db.get("
|
149
|
+
$db.get("MockModel:#{id}").should be_nil
|
150
150
|
end
|
151
151
|
it 'should remove the id from the persisted set in redis' do
|
152
152
|
id=model.save
|
153
153
|
model.delete!
|
154
|
-
$db.sismember("
|
154
|
+
$db.sismember("MockModel:persisted", id).should be_false
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
data/spec/spec_helper.rb
CHANGED
data/test/generator_test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test/unit'
|
|
4
4
|
require 'bundler'
|
5
5
|
Bundler.setup
|
6
6
|
|
7
|
-
require 'lib/generators/rails/redis_generator'
|
7
|
+
require './lib/generators/rails/redis_generator'
|
8
8
|
|
9
9
|
class RedisGeneratorTest < Rails::Generators::TestCase
|
10
10
|
destination File.expand_path("../tmp", File.dirname(__FILE__))
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andreas Eger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: redis
|