dm-redis-adapter 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -49,6 +49,8 @@ Setup your adapter, define your models and properties:
49
49
  property :name, Text
50
50
  end
51
51
 
52
+ Cafe.finalize
53
+
52
54
  Cafe.create(:name => "Whoahbot's Caffienitorium")
53
55
  </code>
54
56
  </pre>
@@ -95,4 +97,5 @@ h1. Badass contributors
95
97
  * <a href="http://github.com/cehoffman">Chris Hoffman (cehoffman)</a> Fixes for Ruby 1.9, bundler for development deps, fixes for sorting
96
98
  * <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
97
99
  * <a href="http://github.com/arbarlow">Alex Barlow (arbarlow)</a> Fixes for ruby 1.9.2
100
+ * <a href="http://github.com/jof">Jonathan Lassoff (jof)</a> Fixes to support textual keys
98
101
 
@@ -150,7 +150,7 @@ module DataMapper
150
150
 
151
151
  if query.conditions.nil?
152
152
  @redis.smembers(key_set_for(query.model)).each do |key|
153
- keys << {redis_key_for(query.model) => key.to_i}
153
+ keys << {redis_key_for(query.model) => key}
154
154
  end
155
155
  else
156
156
  query.conditions.operands.each do |operand|
@@ -218,18 +218,18 @@ module DataMapper
218
218
  elsif operand.is_a?(DataMapper::Query::Conditions::InclusionComparison)
219
219
  value.each do |val|
220
220
  find_indexed_matches(subject, val).each do |k|
221
- matched_records << {redis_key_for(query.model) => k.to_i, "#{subject.name}" => val}
221
+ matched_records << {redis_key_for(query.model) => k, "#{subject.name}" => val}
222
222
  end
223
223
  end
224
224
  else
225
225
  find_indexed_matches(subject, value).each do |k|
226
- matched_records << {redis_key_for(query.model) => k.to_i, "#{subject.name}" => value}
226
+ matched_records << {redis_key_for(query.model) => k, "#{subject.name}" => value}
227
227
  end
228
228
  end
229
229
  else # worst case, loop through each record and match
230
230
  @redis.smembers(key_set_for(query.model)).each do |key|
231
231
  if operand.matches?(subject.typecast(@redis.hget("#{query.model.to_s.downcase}:#{key}", subject.name)))
232
- matched_records << {redis_key_for(query.model) => key.to_i}
232
+ matched_records << {redis_key_for(query.model) => key}
233
233
  end
234
234
  end
235
235
  end
@@ -267,7 +267,7 @@ module DataMapper
267
267
  # Array of id's of all members for an indexed field
268
268
  # @api private
269
269
  def find_indexed_matches(subject, value)
270
- @redis.smembers("#{subject.model.to_s.downcase}:#{subject.name}:#{encode(value)}")
270
+ @redis.smembers("#{subject.model.to_s.downcase}:#{subject.name}:#{encode(value)}").map {|id| id.to_i}
271
271
  end
272
272
 
273
273
  ##
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe DataMapper::Adapters::RedisAdapter do
4
+ before(:all) do
5
+ @adapter = DataMapper.setup(:default, {
6
+ :adapter => "redis",
7
+ :db => 15
8
+ })
9
+ end
10
+
11
+ after(:all) do
12
+ Redis.new(:db => 15).flushdb
13
+ end
14
+
15
+ describe "textual keys" do
16
+ it "should return the key" do
17
+ class Foo
18
+ include DataMapper::Resource
19
+ property :hostname, Text, :key => true
20
+ property :ip_address, Text
21
+ end
22
+ DataMapper.finalize
23
+
24
+ Foo.create(:hostname => "hostname1", :ip_address => '127.0.0.1')
25
+
26
+ Foo.first.hostname.should == "hostname1"
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,90 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dm-redis-adapter
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- - 1
9
- version: 0.5.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Dan Herrera
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-11-14 00:00:00 -08:00
12
+ date: 2012-02-07 00:00:00.000000000 -08:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: dm-core
22
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70176713790760 !ruby/object:Gem::Requirement
23
18
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 2
30
- - 0
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
31
22
  version: 1.2.0
32
23
  type: :runtime
33
24
  prerelease: false
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *70176713790760
26
+ - !ruby/object:Gem::Dependency
36
27
  name: dm-types
37
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &70176713790280 !ruby/object:Gem::Requirement
38
29
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 1
44
- - 2
45
- - 0
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
46
33
  version: 1.2.0
47
34
  type: :runtime
48
35
  prerelease: false
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *70176713790280
37
+ - !ruby/object:Gem::Dependency
51
38
  name: hiredis
52
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &70176713789800 !ruby/object:Gem::Requirement
53
40
  none: false
54
- requirements:
41
+ requirements:
55
42
  - - ~>
56
- - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
- - 3
60
- - 0
43
+ - !ruby/object:Gem::Version
61
44
  version: 0.3.0
62
45
  type: :runtime
63
46
  prerelease: false
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *70176713789800
48
+ - !ruby/object:Gem::Dependency
66
49
  name: redis
67
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &70176713789320 !ruby/object:Gem::Requirement
68
51
  none: false
69
- requirements:
52
+ requirements:
70
53
  - - ~>
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 2
74
- - 2
75
- version: "2.2"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.2'
76
56
  type: :runtime
77
57
  prerelease: false
78
- version_requirements: *id004
58
+ version_requirements: *70176713789320
79
59
  description: DataMapper adapter for the Redis key-value database
80
60
  email: whoahbot@gmail.com
81
61
  executables: []
82
-
83
62
  extensions: []
84
-
85
- extra_rdoc_files:
63
+ extra_rdoc_files:
86
64
  - MIT-LICENSE
87
- files:
65
+ files:
88
66
  - MIT-LICENSE
89
67
  - README.textile
90
68
  - Rakefile
@@ -96,42 +74,37 @@ files:
96
74
  - spec/dm_redis_spec.rb
97
75
  - spec/dm_redis_validations_spec.rb
98
76
  - spec/spec_helper.rb
77
+ - spec/textual_keys_spec.rb
99
78
  has_rdoc: true
100
79
  homepage: http://github.com/whoahbot/dm-redis-adapter
101
80
  licenses: []
102
-
103
81
  post_install_message:
104
- rdoc_options:
82
+ rdoc_options:
105
83
  - --charset=UTF-8
106
- require_paths:
84
+ require_paths:
107
85
  - lib
108
- required_ruby_version: !ruby/object:Gem::Requirement
86
+ required_ruby_version: !ruby/object:Gem::Requirement
109
87
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 82707661945259695
114
- segments:
115
- - 0
116
- version: "0"
117
- required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
93
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- segments:
123
- - 0
124
- version: "0"
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
125
98
  requirements: []
126
-
127
99
  rubyforge_project:
128
- rubygems_version: 1.3.7
100
+ rubygems_version: 1.6.2
129
101
  signing_key:
130
102
  specification_version: 3
131
103
  summary: DataMapper adapter for the Redis key-value database
132
- test_files:
104
+ test_files:
133
105
  - spec/dm_redis_associations_spec.rb
134
106
  - spec/dm_redis_finding_spec.rb
135
107
  - spec/dm_redis_spec.rb
136
108
  - spec/dm_redis_validations_spec.rb
137
109
  - spec/spec_helper.rb
110
+ - spec/textual_keys_spec.rb