dm-redis-adapter 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dm-redis-adapter/adapter.rb +5 -5
- data/spec/dm_redis_validations_spec.rb +19 -6
- metadata +17 -17
@@ -127,7 +127,7 @@ module DataMapper
|
|
127
127
|
properties_to_set << property.name << attributes[property]
|
128
128
|
end
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
hash_key = "#{resource.model.to_s.downcase}:#{resource.key.join}"
|
132
132
|
properties_to_del.each {|prop| @redis.hdel(hash_key, prop) }
|
133
133
|
@redis.hmset(hash_key, *properties_to_set) unless properties_to_set.empty?
|
@@ -157,16 +157,16 @@ module DataMapper
|
|
157
157
|
keys << {"#{redis_key_for(query.model)}" => k, "#{o.subject.name}" => o.value}
|
158
158
|
end
|
159
159
|
end
|
160
|
-
|
161
|
-
if query.order || query.limit
|
160
|
+
|
161
|
+
if keys.empty? && (query.order || query.limit)
|
162
162
|
params = {}
|
163
163
|
params[:limit] = [query.offset, query.limit] if query.limit
|
164
|
-
|
164
|
+
|
165
165
|
if query.order
|
166
166
|
order = query.order.first
|
167
167
|
params[:order] = order.operator.to_s
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
@redis.sort(key_set_for(query.model), params).each do |val|
|
171
171
|
keys << {"#{redis_key_for(query.model)}" => val.to_i}
|
172
172
|
end
|
@@ -20,7 +20,7 @@ describe DataMapper::Adapters::RedisAdapter do
|
|
20
20
|
property :id, Serial
|
21
21
|
property :flavor, String, :index => true
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
Crumblecake.create(:flavor => "snozzbler")
|
25
25
|
Crumblecake.new(:flavor => "snozzbler").valid?.should be_false
|
26
26
|
end
|
@@ -65,15 +65,15 @@ describe DataMapper::Adapters::RedisAdapter do
|
|
65
65
|
u.save
|
66
66
|
u.reload.name.should == nil
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "should store Date fields" do
|
70
70
|
class Post
|
71
71
|
include DataMapper::Resource
|
72
|
-
|
72
|
+
|
73
73
|
property :id, Serial
|
74
74
|
property :posted_at, Date
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
Post.create :posted_at => Date.today
|
78
78
|
Post.first.posted_at.should be_a(Date)
|
79
79
|
end
|
@@ -92,9 +92,22 @@ describe DataMapper::Adapters::RedisAdapter do
|
|
92
92
|
GangMember.first.should == joey
|
93
93
|
GangMember.last.should == bobby
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
|
+
it "should pull up the first pirate that matches the nickname" do
|
97
|
+
class Blackguard
|
98
|
+
include DataMapper::Resource
|
99
|
+
|
100
|
+
property :id, Serial
|
101
|
+
property :nickname, String, :index => true
|
102
|
+
end
|
103
|
+
|
104
|
+
petey = Blackguard.create(:nickname => "Petey 'one-eye' McGraw")
|
105
|
+
james = Blackguard.create(:nickname => "James 'cannon-fingers' Doolittle")
|
106
|
+
Blackguard.first(:nickname => "James 'cannon-fingers' Doolittle").should == james
|
107
|
+
end
|
108
|
+
|
96
109
|
after(:all) do
|
97
110
|
redis = Redis.new(:db => 15)
|
98
111
|
redis.flushdb
|
99
112
|
end
|
100
|
-
end
|
113
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-redis-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Herrera
|
@@ -15,13 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-03 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
22
|
+
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -32,12 +32,12 @@ dependencies:
|
|
32
32
|
- 0
|
33
33
|
- 0
|
34
34
|
version: 1.0.0
|
35
|
-
|
36
|
-
|
35
|
+
name: dm-core
|
36
|
+
requirement: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
38
|
+
type: :runtime
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
@@ -48,12 +48,12 @@ dependencies:
|
|
48
48
|
- 0
|
49
49
|
- 0
|
50
50
|
version: 1.0.0
|
51
|
-
|
52
|
-
|
51
|
+
name: dm-types
|
52
|
+
requirement: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
|
54
|
+
type: :runtime
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -64,8 +64,8 @@ dependencies:
|
|
64
64
|
- 0
|
65
65
|
- 3
|
66
66
|
version: 2.0.3
|
67
|
-
|
68
|
-
|
67
|
+
name: redis
|
68
|
+
requirement: *id003
|
69
69
|
description: DataMapper adapter for the Redis key-value database
|
70
70
|
email: whoahbot@gmail.com
|
71
71
|
executables: []
|
@@ -88,7 +88,7 @@ has_rdoc: true
|
|
88
88
|
homepage: http://github.com/whoahbot/dm-redis-adapter
|
89
89
|
licenses: []
|
90
90
|
|
91
|
-
post_install_message:
|
91
|
+
post_install_message:
|
92
92
|
rdoc_options:
|
93
93
|
- --charset=UTF-8
|
94
94
|
require_paths:
|