dm-redis-adapter 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -14,6 +14,7 @@ h1. Upgrading
14
14
 
15
15
  h1. Changelog
16
16
 
17
+ * v0.3.0 Updates to support ruby 1.9.2 (thanks arbarlow!)
17
18
  * v0.2.1 Fixes to sorting
18
19
  * v0.1.1 Update to redis-rb v2.0.0
19
20
  * v0.1 Update to store records as redis hash values
@@ -25,7 +26,7 @@ Prerequisites:
25
26
  * Redis:
26
27
  ** <a href="http://code.google.com/p/redis/">Redis, v2.0.x RC series</a>
27
28
  * Gems:
28
- ** <a href="http://github.com/datamapper/dm-core/">dm-core</a> v1.0.0
29
+ ** <a href="http://github.com/datamapper/dm-core/">dm-core</a> v1.0.2
29
30
 
30
31
  Install the dm-redis adapter:
31
32
  <pre>
@@ -97,4 +98,6 @@ h1. Badass contributors
97
98
  * <a href="http://github.com/aeden">Anthony Eden (aeden)</a> Gem cleanup, update to jeweler
98
99
  * <a href="http://github.com/sr">Simon Roset (sr)</a> Fixes for edge dm-core
99
100
  * <a href="http://github.com/cehoffman">Chris Hoffman (cehoffman)</a> Fixes for Ruby 1.9, bundler for development deps, fixes for sorting
100
- * <a href="http://github.com/bpo">brian p o'rourke (bpo)</a> Updates for newer versions of redis client and DM JSON type support, move to hash storage
101
+ * <a href="http://github.com/bpo">brian p o'rourke (bpo)</a> Updates for newer versions of redis client and DM JSON type support, move to hash storage
102
+ * <a href="http://github.com/arbarlow">Alex Barlow (arbarlow)</a> Fixes for ruby 1.9.2
103
+
data/Rakefile CHANGED
@@ -26,8 +26,8 @@ begin
26
26
  gemspec.homepage = HOMEPAGE
27
27
  gemspec.description = SUMMARY
28
28
  gemspec.authors = AUTHORS
29
- gemspec.add_dependency "dm-core", ">= 1.0.0"
30
- gemspec.add_dependency "dm-types", ">= 1.0.0"
29
+ gemspec.add_dependency "dm-core", ">= 1.0.2"
30
+ gemspec.add_dependency "dm-types", ">= 1.0.2"
31
31
  gemspec.add_dependency "redis", ">= 2.0.3"
32
32
  gemspec.files = %w(MIT-LICENSE README.textile Rakefile) + Dir.glob("{lib,spec}/**/*")
33
33
  gemspec.has_rdoc = false
@@ -51,7 +51,8 @@ module DataMapper
51
51
  record[name] = [Integer, Date].include?(property.primitive) ? property.typecast( value ) : value
52
52
  end
53
53
  end
54
- records = query.filter_records(records)
54
+ records = query.match_records(records)
55
+ records = query.sort_records(records)
55
56
  records
56
57
  end
57
58
 
@@ -87,10 +88,11 @@ module DataMapper
87
88
  #
88
89
  # @api semipublic
89
90
  def delete(collection)
90
- records_for(collection.query).each do |record|
91
+ collection.count.times do |x|
92
+ record = collection[x]
91
93
  @redis.del("#{collection.query.model.to_s.downcase}:#{record[redis_key_for(collection.query.model)]}")
92
94
  @redis.srem(key_set_for(collection.query.model), record[redis_key_for(collection.query.model)])
93
- collection.query.model.properties.select {|p| p.index}.each do |p|
95
+ record.model.properties.select {|p| p.index}.each do |p|
94
96
  @redis.srem("#{collection.query.model.to_s.downcase}:#{p.name}:#{encode(record[p.name])}", record[redis_key_for(collection.query.model)])
95
97
  end
96
98
  end
@@ -111,7 +113,7 @@ module DataMapper
111
113
  attributes = resource.dirty_attributes
112
114
 
113
115
  resource.model.properties.select {|p| p.index}.each do |property|
114
- @redis.sadd("#{resource.model.to_s.downcase}:#{property.name}:#{encode(resource[property.name.to_s])}", resource.key)
116
+ @redis.sadd("#{resource.model.to_s.downcase}:#{property.name}:#{encode(resource[property.name.to_s])}", resource.key.first.to_s)
115
117
  end
116
118
 
117
119
  properties_to_set = []
@@ -212,7 +214,7 @@ module DataMapper
212
214
  # Array of id's of all members matching the query
213
215
  # @api private
214
216
  def find_matches(query, operand)
215
- @redis.smembers("#{query.model.to_s.downcase}:#{operand.subject.name}:#{encode(operand.value)}")
217
+ @redis.smembers("#{query.model.to_s.downcase}:#{operand.subject.name}:#{encode(operand.value.to_s)}")
216
218
  end
217
219
 
218
220
  ##
@@ -32,7 +32,7 @@ describe DataMapper::Adapters::RedisAdapter do
32
32
 
33
33
  property :id, Serial
34
34
  property :name, String
35
- property :env, DataMapper::Property::Json, :default => lambda { {} }
35
+ property :env, DataMapper::Property::Json, :default => {}
36
36
  end
37
37
  end
38
38
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-redis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 2
9
7
  - 3
10
- version: 0.2.3
8
+ - 0
9
+ version: 0.3.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Dan Herrera
@@ -15,57 +14,54 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-13 00:00:00 -07:00
17
+ date: 2011-03-13 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
21
+ name: dm-core
22
+ requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 23
30
27
  segments:
31
28
  - 1
32
29
  - 0
33
- - 0
34
- version: 1.0.0
35
- name: dm-core
36
- requirement: *id001
37
- - !ruby/object:Gem::Dependency
30
+ - 2
31
+ version: 1.0.2
38
32
  type: :runtime
39
33
  prerelease: false
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: dm-types
37
+ requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
39
  requirements:
43
40
  - - ">="
44
41
  - !ruby/object:Gem::Version
45
- hash: 23
46
42
  segments:
47
43
  - 1
48
44
  - 0
49
- - 0
50
- version: 1.0.0
51
- name: dm-types
52
- requirement: *id002
53
- - !ruby/object:Gem::Dependency
45
+ - 2
46
+ version: 1.0.2
54
47
  type: :runtime
55
48
  prerelease: false
56
- version_requirements: &id003 !ruby/object:Gem::Requirement
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: redis
52
+ requirement: &id003 !ruby/object:Gem::Requirement
57
53
  none: false
58
54
  requirements:
59
55
  - - ">="
60
56
  - !ruby/object:Gem::Version
61
- hash: 9
62
57
  segments:
63
58
  - 2
64
59
  - 0
65
60
  - 3
66
61
  version: 2.0.3
67
- name: redis
68
- requirement: *id003
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: *id003
69
65
  description: DataMapper adapter for the Redis key-value database
70
66
  email: whoahbot@gmail.com
71
67
  executables: []
@@ -111,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
107
  requirements:
112
108
  - - ">="
113
109
  - !ruby/object:Gem::Version
114
- hash: 3
110
+ hash: -599772013771505698
115
111
  segments:
116
112
  - 0
117
113
  version: "0"
@@ -120,7 +116,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
116
  requirements:
121
117
  - - ">="
122
118
  - !ruby/object:Gem::Version
123
- hash: 3
124
119
  segments:
125
120
  - 0
126
121
  version: "0"