redpear 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,11 +7,14 @@ class Redpear::Connection
7
7
 
8
8
  MASTER_METHODS = [
9
9
  :append, :blpop, :brpop, :brpoplpush, :decr, :decrby, :del, :discard,
10
- :exec, :expire, :expireat, :getset, :hset, :hsetnx, :hincrby, :hmset,
11
- :hdel, :incr, :incrby, :linsert, :lpop, :lpush, :lpushx, :lrem, :lset,
12
- :ltrim, :mapped_hmset, :mapped_mset, :mapped_msetnx, :move, :mset, :msetnx,
10
+ :eval, :evalsha, :exec, :expire, :expireat, :getset,
11
+ :hset, :hsetnx, :hincrby, :hmset, :hdel, :hincrbyfloat,
12
+ :incr, :incrby, :incrbyfloat,
13
+ :linsert, :lpop, :lpush, :lpushx, :lrem, :lset, :ltrim,
14
+ :mapped_hmset, :mapped_mset, :mapped_msetnx, :move, :mset, :msetnx,
13
15
  :multi, :persist, :pipelined, :rename, :renamenx, :rpop, :rpoplpush,
14
- :rpush, :rpushx, :sadd, :sdiffstore, :set, :setbit, :setex, :setnx,
16
+ :pexpire, :pexpireat, :psetex, :pttl, :rpush, :rpushx,
17
+ :sadd, :script, :sdiffstore, :set, :setbit, :setex, :setnx,
15
18
  :setrange, :sinterstore, :smove, :spop, :srem, :sunionstore, :unwatch,
16
19
  :watch, :zadd, :zincrby, :zinterstore, :zrem, :zremrangebyrank,
17
20
  :zremrangebyscore, :zunionstore, :[]=
@@ -23,9 +26,9 @@ class Redpear::Connection
23
26
  :hlen, :hkeys, :hvals, :hgetall, :info, :keys, :lastsave, :lindex, :llen,
24
27
  :lrange, :mapped_hmget, :mapped_mget, :mget, :monitor, :object, :ping,
25
28
  :publish, :psubscribe, :punsubscribe, :quit, :randomkey, :save, :scard,
26
- :sdiff, :select, :shutdown, :sinter, :sismember, :slaveof, :smembers,
27
- :sort, :srandmember, :strlen, :subscribe, :subscribed?, :substr, :sunion,
28
- :sync, :synchronize, :ttl, :type, :unsubscribe, :zcard, :zcount, :zrange,
29
+ :sdiff, :select, :shutdown, :sinter, :sismember, :slaveof, :slowlog, :smembers,
30
+ :sort, :srandmember, :strlen, :subscribe, :subscribed?, :sunion, :sync, :synchronize,
31
+ :time, :ttl, :type, :unsubscribe, :zcard, :zcount, :zrange,
29
32
  :zrangebyscore, :zrank, :zrevrange, :zrevrangebyscore, :zrevrank, :zscore,
30
33
  :[]
31
34
  ].freeze
data/lib/redpear/model.rb CHANGED
@@ -214,11 +214,9 @@ class Redpear::Model < Hash
214
214
  # @return [Boolean] true if successful
215
215
  def destroy
216
216
  before_destroy
217
- self.class.transaction do
218
- lookups.each {|l| l.delete(id) }
219
- attributes.purge!
220
- after_destroy
221
- end
217
+ lookups.each {|l| l.delete(id) }
218
+ attributes.purge!
219
+ after_destroy
222
220
  freeze
223
221
  end
224
222
 
@@ -51,8 +51,8 @@ class Redpear::Store::Base
51
51
 
52
52
  # Watch this key
53
53
  # @return [Boolean] true if successful
54
- def watch
55
- conn.watch(key) == "OK"
54
+ def watch(&block)
55
+ conn.watch(key, &block).nil?
56
56
  end
57
57
 
58
58
  # @return [Integer] remaining time-to-live in seconds (if set)
@@ -115,11 +115,15 @@ class Redpear::Store::Base
115
115
 
116
116
  private
117
117
 
118
- def range_pair(range)
119
- first = range.first.to_i
120
- last = range.last.to_i
121
- last -= 1 if range.exclude_end?
122
- [first, last]
118
+ def range_pair(value, reversed = false)
119
+ case value
120
+ when Range
121
+ first, last = value.first.to_i, value.last.to_i
122
+ last -= 1 if value.exclude_end?
123
+ reversed ? [last, first] : [first, last]
124
+ when Array
125
+ [value.first, value.last]
126
+ end
123
127
  end
124
128
 
125
129
  end
@@ -34,7 +34,7 @@ class Redpear::Store::List < Redpear::Store::Enumerable
34
34
  else
35
35
  conn.lindex(key, start) rescue nil
36
36
  end
37
- when Range
37
+ when Range, Array
38
38
  range *range_pair(start)
39
39
  else
40
40
  []
@@ -46,7 +46,7 @@ class Redpear::Store::List < Redpear::Store::Enumerable
46
46
  # @overload slice(start, length)
47
47
  def slice!(start, length = nil)
48
48
  case start
49
- when Range
49
+ when Range, Array
50
50
  trim *range_pair(start)
51
51
  else
52
52
  trim(start, start + length - 1)
@@ -23,6 +23,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
23
23
  end
24
24
  alias_method :size, :length
25
25
 
26
+ # Returns items from range
26
27
  # @param [Range] range
27
28
  # @return [Integer] the number of items within given score `range`
28
29
  def count(range)
@@ -86,7 +87,6 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
86
87
 
87
88
  # Returns a slice of members between index +range+, with the lower index returned first
88
89
  # @param [Range] range
89
- # The index range of the elements
90
90
  # @param [Hash] options
91
91
  # @option [Boolean] with_scores
92
92
  # Return with scores, defaults to true
@@ -98,8 +98,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
98
98
  alias_method :top, :slice
99
99
 
100
100
  # Returns a slice of members between rindex +range+, with the higher index returned first
101
- # @param [Range] range
102
- # The rindex range of the elements
101
+ # @param [Range] range The rindex range of the elements
103
102
  # @param [Hash] options
104
103
  # @option [Boolean] with_scores
105
104
  # Return with scores, defaults to true
@@ -111,8 +110,10 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
111
110
  alias_method :bottom, :rslice
112
111
 
113
112
  # Selects members between a score +range+. Lower scores returned first
114
- # @param [Range] range
115
- # The score range of the elements
113
+ # @overload select(range)
114
+ # @param [Range] range The score range of the elements
115
+ # @overload select(range)
116
+ # @param [Array] range as Array, e.g. ["-inf", "+inf"]
116
117
  # @param [Hash] options
117
118
  # @option [Boolean] with_scores
118
119
  # Return with scores, defaults to true
@@ -125,8 +126,10 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
125
126
  end
126
127
 
127
128
  # Selects members between a score +range+. Higher scores returned first
128
- # @param [Range] range
129
- # The score range of the elements
129
+ # @overload rselect(range)
130
+ # @param [Range] range The score range of the elements
131
+ # @overload rselect(range)
132
+ # @param [Array] range as Array, e.g. ["-inf", "+inf"]
130
133
  # @param [Hash] options
131
134
  # @option [Boolean] with_scores
132
135
  # Return with scores, defaults to true
@@ -134,7 +137,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
134
137
  # Limit the results
135
138
  # @return [Array] the members
136
139
  def rselect(range, options = {})
137
- start, finish = range_pair(range)
140
+ finish, start = range_pair(range, true)
138
141
  fetch_range :zrevrangebyscore, finish, start, options
139
142
  end
140
143
 
@@ -232,8 +235,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
232
235
  def fetch_range(method, start, finish, options = {})
233
236
  options[:limit] = [options[:offset] || 0, options[:limit]] if options[:offset] || options[:limit]
234
237
  options[:with_scores] = true unless options.key?(:with_scores)
235
- result = conn.send method, key, start, finish, options
236
- options[:with_scores] ? result.each_slice(2).map {|m,s| [m, s.to_f] } : result
238
+ conn.send method, key, start, finish, options
237
239
  end
238
240
 
239
241
  end
@@ -1,8 +1,8 @@
1
1
  module Redpear
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 7
5
- TINY = 7
4
+ MINOR = 8
5
+ TINY = 0
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redpear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-18 00:00:00.000000000 Z
12
+ date: 2012-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &7458360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.2.0
21
+ version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7458360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &7457740 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *7457740
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: bundler
38
- requirement: &7457080 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *7457080
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rspec
49
- requirement: &7456440 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *7456440
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: shoulda-matchers
60
- requirement: &7455900 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *7455900
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: machinist
71
- requirement: &7455480 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *7455480
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: factory_girl
82
- requirement: &7455060 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *7455060
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: hiredis
93
- requirement: &7454620 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,7 +133,12 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *7454620
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  description: Simple, elegant & efficient ORM for Redis
103
143
  email: dimitrij@blacksquaremedia.com
104
144
  executables: []
@@ -149,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
189
  version: 1.3.6
150
190
  requirements: []
151
191
  rubyforge_project:
152
- rubygems_version: 1.8.16
192
+ rubygems_version: 1.8.24
153
193
  signing_key:
154
194
  specification_version: 3
155
195
  summary: Redpear, a Redis ORM