dm-redis-adapter 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -32,16 +32,16 @@ Setup your adapter, define your models and properties:
32
32
  require 'rubygems'
33
33
  require 'dm-core'
34
34
  require 'dm_redis'
35
-
35
+
36
36
  DataMapper.setup(:default, {:adapter => "redis"})
37
-
37
+
38
38
  class Cafe
39
39
  include DataMapper::Resource
40
-
40
+
41
41
  property :id, Serial
42
42
  property :name, Text
43
43
  end
44
-
44
+
45
45
  Cafe.create(:name => "Whoahbot's Caffienitorium")
46
46
  </code>
47
47
  </pre>
@@ -54,11 +54,11 @@ If you want to do finds on specific String fields, add an index:
54
54
  <code>
55
55
  class Coffee
56
56
  include DataMapper::Resource
57
-
57
+
58
58
  property :id, Serial
59
59
  property :description, String, :index => true
60
60
  end
61
-
61
+
62
62
  Coffee.create(:description => "Notes of crude oil and sulphur")
63
63
  Coffee.first(:description => "Notes of crude oil and sulphur") # will now work
64
64
  </code>
@@ -75,7 +75,7 @@ Validations on unique fields are now supported through indices and dm-validation
75
75
  property :id, Serial
76
76
  property :flavor, String, :index => true
77
77
  end
78
-
78
+
79
79
  Crumblecake.create(:flavor => "snozzbler")
80
80
  Crumblecake.new(:flavor => "snozzbler").valid? # false (of course! Who ever heard of a snozzbler crumblecake?)
81
81
  </code>
@@ -84,4 +84,5 @@ Validations on unique fields are now supported through indices and dm-validation
84
84
  h1. Badass contributors
85
85
 
86
86
  * <a href="http://github.com/aeden">Anthony Eden (aeden)</a> Gem cleanup, update to jeweler
87
- * <a href="http://github.com/sr">Simon Roset (sr)</a> Fixes for edge dm-core
87
+ * <a href="http://github.com/sr">Simon Roset (sr)</a> Fixes for edge dm-core
88
+ * <a href="http://github.com/">Chris Hoffman (cehoffman)</a> Fixes for Ruby 1.9, bundler for development deps
data/Rakefile CHANGED
@@ -1,4 +1,13 @@
1
- require 'rubygems'
1
+ begin
2
+ # Try to require the preresolved locked set of gems.
3
+ require File.expand_path('../.bundle/environment', __FILE__)
4
+ rescue LoadError
5
+ # Fall back on doing an unlocked resolve at runtime.
6
+ require "rubygems"
7
+ require "bundler"
8
+ Bundler.setup
9
+ end
10
+
2
11
  require 'spec/rake/spectask'
3
12
 
4
13
  GEM = 'dm-redis-adapter'
data/lib/dm_redis.rb CHANGED
@@ -17,7 +17,7 @@ module DataMapper
17
17
  def create(resources)
18
18
  resources.each do |resource|
19
19
  initialize_serial(resource, @redis.incr("#{resource.model.to_s.downcase}:#{redis_key_for(resource.model)}:serial"))
20
- @redis.set_add(key_set_for(resource.model), resource.key)
20
+ @redis.set_add(key_set_for(resource.model), resource.key.join)
21
21
  end
22
22
  update_attributes(resources)
23
23
  end
@@ -61,7 +61,7 @@ module DataMapper
61
61
  # @api semipublic
62
62
  def update(attributes, collection)
63
63
  attributes = attributes_as_fields(attributes)
64
-
64
+
65
65
  records_to_update = records_for(collection.query)
66
66
  records_to_update.each {|r| r.update(attributes)}
67
67
  update_attributes(collection)
@@ -89,7 +89,7 @@ module DataMapper
89
89
  end
90
90
  end
91
91
  end
92
-
92
+
93
93
  private
94
94
 
95
95
  ##
@@ -104,10 +104,10 @@ module DataMapper
104
104
  resource.model.properties.select {|p| p.index}.each do |property|
105
105
  @redis.set_add("#{resource.model.to_s.downcase}:#{property.name}:#{encode(resource[property.name.to_s])}", resource.key)
106
106
  end
107
-
107
+
108
108
  resource.attributes(:field).each do |property, value|
109
109
  next if resource.key.include?(property)
110
- @redis["#{resource.model.to_s.downcase}:#{resource.key}:#{property}"] = value unless value.nil?
110
+ @redis["#{resource.model.to_s.downcase}:#{resource.key.join}:#{property}"] = value unless value.nil?
111
111
  end
112
112
  end
113
113
  end
@@ -124,7 +124,7 @@ module DataMapper
124
124
  # @api private
125
125
  def records_for(query)
126
126
  keys = []
127
-
127
+
128
128
  query.conditions.operands.select {|o| o.is_a?(DataMapper::Query::Conditions::EqualToComparison)}.each do |o|
129
129
  if query.model.key.include?(o.subject)
130
130
  if @redis.set_member?(key_set_for(query.model), o.value)
@@ -151,7 +151,7 @@ module DataMapper
151
151
 
152
152
  keys
153
153
  end
154
-
154
+
155
155
  ##
156
156
  # Creates a string representation for the keys in a given model
157
157
  #
@@ -168,7 +168,7 @@ module DataMapper
168
168
 
169
169
  ##
170
170
  # Return the key string for the set that contains all keys for a particular resource
171
- #
171
+ #
172
172
  # @return String
173
173
  # The string key for the :all set
174
174
  # @api private
@@ -178,7 +178,7 @@ module DataMapper
178
178
 
179
179
  ##
180
180
  # Find a matching entry for a query
181
- #
181
+ #
182
182
  # @return [Array]
183
183
  # Array of id's of all members matching the query
184
184
  # @api private
@@ -188,14 +188,14 @@ module DataMapper
188
188
 
189
189
  ##
190
190
  # Base64 encode a value as a string key for an index
191
- #
191
+ #
192
192
  # @return String
193
193
  # Base64 representation of a value
194
194
  # @api private
195
195
  def encode(value)
196
196
  Base64.encode64(value.to_s).gsub("\n", "")
197
197
  end
198
-
198
+
199
199
  ##
200
200
  # Make a new instance of the adapter. The @redis ivar is the 'data-store'
201
201
  # for this adapter.
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path("../spec_helper", __FILE__)
2
2
  require 'redis'
3
3
 
4
4
  require 'dm-core/spec/adapter_shared_spec'
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,13 @@
1
- require 'rubygems'
1
+ begin
2
+ # Try to require the preresolved locked set of gems.
3
+ require File.expand_path('../.bundle/environment', __FILE__)
4
+ rescue LoadError
5
+ # Fall back on doing an unlocked resolve at runtime.
6
+ require "rubygems"
7
+ require "bundler"
8
+ Bundler.setup
9
+ end
10
+
2
11
  require 'dm-core'
3
12
 
4
13
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib/dm_redis'))
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-redis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 10
9
+ version: 0.0.10
5
10
  platform: ruby
6
11
  authors:
7
12
  - Dan Herrera
@@ -14,24 +19,30 @@ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: dm-core
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 10
30
+ - 2
23
31
  version: 0.10.2
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: redis
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
33
43
  version: "0"
34
- version:
44
+ type: :runtime
45
+ version_requirements: *id002
35
46
  description: DataMapper adapter for the Redis key-value database
36
47
  email: whoahbot@gmail.com
37
48
  executables: []
@@ -60,18 +71,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
71
  requirements:
61
72
  - - ">="
62
73
  - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
63
76
  version: "0"
64
- version:
65
77
  required_rubygems_version: !ruby/object:Gem::Requirement
66
78
  requirements:
67
79
  - - ">="
68
80
  - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
69
83
  version: "0"
70
- version:
71
84
  requirements: []
72
85
 
73
86
  rubyforge_project:
74
- rubygems_version: 1.3.5
87
+ rubygems_version: 1.3.6
75
88
  signing_key:
76
89
  specification_version: 2
77
90
  summary: DataMapper adapter for the Redis key-value database