redpear 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0ff88b2354ac6d4572f2684df91420336802223
4
- data.tar.gz: 1336df7350d638205e9cc5a5676455323e36f144
3
+ metadata.gz: 43b9457346f8717f197abb7126edf776529ac0a7
4
+ data.tar.gz: ba0cfb07aadfb5c6d9aed9a2a6db569e75d6472c
5
5
  SHA512:
6
- metadata.gz: b6516b9b62090729cfb0448f52cd5b59938757b399656f73844e6c731fd676e0a90d85381007ca4860adbb0133200bf24658159250673d196a6d64f154bf2474
7
- data.tar.gz: c601c67aa11bea491bda0b9411e84e0f4cb3bde81679c2ec79ec102a2331a111386bda127ac4a28cc55482e7e15e66230e7c14bc15cb60c94a5213f0e6fa9c67
6
+ metadata.gz: eb419ed421012e2ddcf0a1d4075df2dc6b7e574a7a7bdb9dbb3d212876add05e4323ab4a3fce6e70cfff8840a9e6945afaacdcf658c6acd2155daacdd7a37d89
7
+ data.tar.gz: c9a515798435daf015f72795356b388e9b4344bcbd307014974a2b726b6fada421410e426edc257029ebf52e73613a87e8c1adaefb1083c3a67fa68213e64690
@@ -3,12 +3,13 @@ require 'securerandom'
3
3
  class Redpear::Store::Base
4
4
 
5
5
  # Transforamtions
6
- IS_NIL = lambda {|v| v.nil? }.freeze
7
- IS_ZERO = lambda {|v| v.zero? }.freeze
8
- IS_TRUE = lambda {|v| !!v }.freeze
9
- TO_INT = lambda {|v| v.to_i }.freeze
10
- TO_SET = lambda {|v| v.to_set }.freeze
11
- PICK_FIRST = lambda {|v| v.first }.freeze
6
+ IS_NIL = ->v { v.nil? }.freeze
7
+ IS_ZERO = ->v { v.zero? }.freeze
8
+ IS_ONE = ->v { v == 1 }.freeze
9
+ IS_TRUE = ->v { !!v }.freeze
10
+ TO_INT = ->v { v.to_i }.freeze
11
+ TO_SET = ->v { v.to_set }.freeze
12
+ PICK_FIRST = ->v { v.first }.freeze
12
13
 
13
14
  attr_reader :key, :conn
14
15
 
@@ -54,7 +55,7 @@ class Redpear::Store::Base
54
55
 
55
56
  # @return [Boolean] true if the record exists
56
57
  def exists?
57
- !!conn.exists(key)
58
+ conn.exists(key)
58
59
  end
59
60
 
60
61
  # Watch this key
@@ -96,7 +97,12 @@ class Redpear::Store::Base
96
97
 
97
98
  # Deletes the whole record
98
99
  def purge!
99
- conn.del(key) == 1
100
+ case value = conn.del(key)
101
+ when Redis::Future
102
+ value.instance_eval { @transformation = IS_ONE }
103
+ else
104
+ value == 1
105
+ end
100
106
  end
101
107
 
102
108
  # Deletes the record and returns the value
@@ -22,7 +22,7 @@ class Redpear::Store::Hash < Redpear::Store::Enumerable
22
22
 
23
23
  # @return [Boolean] true, if field exists
24
24
  def key?(field)
25
- !!conn.hexists(key, field)
25
+ conn.hexists(key, field)
26
26
  end
27
27
  alias_method :has_key?, :key?
28
28
  alias_method :member?, :key?
@@ -101,13 +101,9 @@ class Redpear::Store::Hash < Redpear::Store::Enumerable
101
101
 
102
102
  # @param [Hash] hash
103
103
  # The pairs to update
104
- def update(hash)
105
- case result = merge!(hash)
106
- when Redis::Future
107
- result
108
- else
109
- to_hash
110
- end
104
+ def update(hash)
105
+ result = merge!(hash)
106
+ Redis::Future === result ? result : to_hash
111
107
  end
112
108
 
113
109
  # @param [Hash] hash
@@ -51,12 +51,7 @@ class Redpear::Store::List < Redpear::Store::Enumerable
51
51
  else
52
52
  trim(start, start + length - 1)
53
53
  end
54
- case result
55
- when Redis::Future
56
- result
57
- else
58
- to_a
59
- end
54
+ Redis::Future === result ? result : to_a
60
55
  end
61
56
 
62
57
  # @param [Integer] start
@@ -9,7 +9,7 @@ class Redpear::Store::Lock < Redpear::Store::Base
9
9
  #
10
10
  # @return [Hash] default options
11
11
  def default_options
12
- @default_options ||= { :lock_timeout => 2, :wait_timeout => 2 }
12
+ @default_options ||= { lock_timeout: 2, wait_timeout: 2 }
13
13
  end
14
14
 
15
15
  end
@@ -15,7 +15,7 @@ class Redpear::Store::Set < Redpear::Store::Enumerable
15
15
  value.instance_eval { @transformation = TO_SET }
16
16
  else
17
17
  value.to_set
18
- end
18
+ end
19
19
  end
20
20
  alias_method :to_set, :all
21
21
  alias_method :value, :all
@@ -50,7 +50,7 @@ class Redpear::Store::Set < Redpear::Store::Enumerable
50
50
 
51
51
  # @return [Boolean] true, if value is included
52
52
  def include?(value)
53
- !!conn.sismember(key, value)
53
+ conn.sismember(key, value)
54
54
  end
55
55
  alias_method :member?, :include?
56
56
 
@@ -45,8 +45,8 @@ class Redpear::Store::Value < Redpear::Store::Base
45
45
  def ==(other)
46
46
  case value = self.value
47
47
  when Redis::Future
48
- value.instance_eval { @transformation = Kernel.lambda {|v| v == other } }
49
- else
48
+ value.instance_eval { @transformation = ->v { v == other } }
49
+ else
50
50
  value == other
51
51
  end
52
52
  end
@@ -56,7 +56,7 @@ class Redpear::Store::Value < Redpear::Store::Base
56
56
  case value = self.value
57
57
  when Redis::Future
58
58
  value.instance_eval { @transformation = IS_NIL }
59
- else
59
+ else
60
60
  value.nil?
61
61
  end
62
62
  end
@@ -2,7 +2,7 @@ module Redpear
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
@@ -14,16 +14,22 @@ dependencies:
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.5
20
+ - - <
18
21
  - !ruby/object:Gem::Version
19
- version: 3.0.0
22
+ version: 3.1.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.5
30
+ - - <
25
31
  - !ruby/object:Gem::Version
26
- version: 3.0.0
32
+ version: 3.1.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement