redis-objects 0.9.0 → 0.9.1

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: 95f1e710f5708a5b30fb2a843fcfdacaff0af044
4
- data.tar.gz: 1d4816620d04019576ae1e277be3c5676b0c5be0
3
+ metadata.gz: 4ddda2781d9f2c900706e383d1079321a1499153
4
+ data.tar.gz: 0120673e2299b6739dd24d4a1e8aea2ee42b1d18
5
5
  SHA512:
6
- metadata.gz: d68499ab0eafd74dcd51838f1723ee14d561bd772725dbef69ce26d86dc66bca412c7520be5f02c5cad9b761a77670e9c8707f5b34737409ada232c99b5a44d4
7
- data.tar.gz: 0a59d05c7d974f0e7d20f5f938b6451a582ec5c025d450cb85073ff328b9abc19d250971f13fe6e2b191f3f3e7c6312a3f81f8f10e93c1b47c9459b12680f775
6
+ metadata.gz: 5e677129dc40412d9a6c11585f84c4703703006d6b02b5a71e047a6bcd8fabf44a22c90073f1f730eec0025776689c75e586ceb8203a7791167f6528b177d96e
7
+ data.tar.gz: d7c948a177c2dea105ce215e4792f490324331e1f9a2acefaa95ee053be71acb3c4065a3517b801125e7f4952161565bd9bf579aac31639e4857641b88cea5e0
@@ -1,5 +1,13 @@
1
1
  = Changelog for Redis::Objects
2
2
 
3
+ == 0.9.1 (25 Mar 2024)
4
+
5
+ * Fix bad marshal calls in SortedSet [Fleurer, nateware]
6
+
7
+ * Handle marshalling/unmarshalling of nil values [anujdas]
8
+
9
+ * Add :default as synonym to :start for Counter [Fleurer]
10
+
3
11
  == 0.9.0 (6 Feb 2014)
4
12
 
5
13
  * Ensure we don't double-unmarshal values, which could be a security issue [markijbema, nateware]
@@ -54,7 +62,7 @@
54
62
 
55
63
  == 0.6.0 (13 Dec 2012)
56
64
 
57
- * Add +@set.merge()+ method to add multiple members at once [hfwang]
65
+ * Add +@set.merge()+ method to add multiple members at once [hfwang]
58
66
 
59
67
  * Add +insert+ method to Redis::List instances [giglemad]
60
68
 
@@ -62,7 +70,7 @@
62
70
 
63
71
  * Add HashKey#bulk_values for fetching values in the same order than the given keys [aspgems]
64
72
 
65
- * Lists now handle the insert command
73
+ * Lists now handle the insert command
66
74
 
67
75
  * Changed +@sset.score+ method on SortedSet to return nil for invalid members [hkarthik]
68
76
 
@@ -88,7 +96,7 @@
88
96
 
89
97
  * Added zcount method to SortedSet [dunedain289]
90
98
 
91
- * Updated redis-objects to look for Redis.current and prefer it over global $redis variable [Jean Boussier]
99
+ * Updated redis-objects to look for Redis.current and prefer it over global $redis variable [Jean Boussier]
92
100
 
93
101
  * Updated URLs to reflect new redis.io website [Jérémy Lecour]
94
102
 
@@ -15,7 +15,7 @@ class Redis
15
15
  attr_reader :key, :options
16
16
  def initialize(key, *args)
17
17
  super(key, *args)
18
- @options[:start] ||= 0
18
+ @options[:start] ||= @options[:default] || 0
19
19
  raise ArgumentError, "Marshalling redis counters does not make sense" if @options[:marshal]
20
20
  redis.setnx(key, @options[:start]) unless @options[:start] == 0 || @options[:init] === false
21
21
  end
@@ -57,9 +57,7 @@ class Redis
57
57
  end
58
58
 
59
59
  def marshal(value, domarshal=false)
60
- if value.nil?
61
- nil
62
- elsif options[:marshal] || domarshal
60
+ if options[:marshal] || domarshal
63
61
  Marshal.dump(value)
64
62
  else
65
63
  value
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  module Objects
3
- VERSION = "0.9.0"
3
+ VERSION = "0.9.1"
4
4
  end
5
5
  end
@@ -86,8 +86,7 @@ class Redis
86
86
  # Return all members of the sorted set with their scores. Extremely CPU-intensive.
87
87
  # Better to use a range instead.
88
88
  def members(options={})
89
- vals = range(0, -1, options)
90
- vals.nil? ? [] : vals.map{|v| unmarshal(v) }
89
+ range(0, -1, options) || []
91
90
  end
92
91
 
93
92
  # Return a range of values from +start_index+ to +end_index+. Can also use
@@ -103,7 +102,7 @@ class Redis
103
102
  # Return a range of values from +start_index+ to +end_index+ in reverse order. Redis: ZREVRANGE
104
103
  def revrange(start_index, end_index, options={})
105
104
  if options[:withscores] || options[:with_scores]
106
- redis.zrevrange(key, start_index, end_index, :with_scores => true).map{|v| unmarshal(v) }
105
+ redis.zrevrange(key, start_index, end_index, :with_scores => true).map{|v,s| [unmarshal(v), s] }
107
106
  else
108
107
  redis.zrevrange(key, start_index, end_index).map{|v| unmarshal(v) }
109
108
  end
@@ -580,6 +580,18 @@ describe Redis::HashKey do
580
580
  @hash.options[:marshal] = false
581
581
  end
582
582
 
583
+ it "should marshal nil correctly" do
584
+ @hash.options[:marshal] = true
585
+
586
+ @hash['test'].should.be.nil
587
+ @hash['test'] = nil
588
+ @hash['test'].should.be.nil
589
+ @hash.delete('test').should == 1
590
+ @hash['test'].should.be.nil
591
+
592
+ @hash.options[:marshal] = false
593
+ end
594
+
583
595
  it "should get and set values" do
584
596
  @hash['foo'] = 'bar'
585
597
  @hash['foo'].should == 'bar'
@@ -954,6 +966,7 @@ describe Redis::SortedSet do
954
966
  @set.range(0, 2).should == a[0..2]
955
967
  @set[0, 0].should == []
956
968
  @set.range(0,1,:withscores => true).should == [['a',3],['c',4]]
969
+ @set.revrange(0,1,:withscores => true).should == [['b',5.6],['c',4]]
957
970
  @set.range(0,-1).should == a[0..-1]
958
971
  @set.revrange(0,-1).should == a[0..-1].reverse
959
972
  @set[0..1].should == a[0..1]
@@ -967,6 +980,8 @@ describe Redis::SortedSet do
967
980
  @set.members(:withscores => true).should == [['a',3],['c',4],['b',5.6]]
968
981
  @set.members(:with_scores => true).should == [['a',3],['c',4],['b',5.6]]
969
982
  @set.members(:withscores => true).reverse.should == [['b',5.6],['c',4],['a',3]]
983
+ @set.members(:withscores => true).should == @set.range(0,-1,:withscores => true)
984
+ @set.members(:withscores => true).reverse.should == @set.revrange(0,-1,:withscores => true)
970
985
 
971
986
  @set['b'] = 5
972
987
  @set['b'] = 6
@@ -1038,12 +1053,21 @@ describe Redis::SortedSet do
1038
1053
  end
1039
1054
 
1040
1055
  it "should support marshaling key names" do
1056
+ @set_4.members.should == []
1057
+
1041
1058
  @set_4[Object] = 1.20
1042
1059
  @set_4[Module] = 2.30
1060
+ @set_4[nil] = 3.40
1061
+
1043
1062
  @set_4.incr(Object, 0.5)
1044
1063
  @set_4.decr(Module, 0.5)
1064
+ @set_4.incr(nil, 0.5)
1065
+
1045
1066
  @set_4[Object].round(1).should == 1.7
1046
1067
  @set_4[Module].round(1).should == 1.8
1068
+ @set_4[nil].round(1).should == 3.9
1069
+
1070
+ @set_4.members.should == [Object, Module, nil]
1047
1071
  end
1048
1072
 
1049
1073
  it "should support renaming sorted sets" do
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Wiger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bacon
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redis-namespace
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: activerecord
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.2'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.2'
97
97
  description: Map Redis types directly to Ruby objects. Works with any class or ORM.
@@ -101,8 +101,8 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
105
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
106
  - ATOMICITY.rdoc
107
107
  - CHANGELOG.rdoc
108
108
  - Gemfile
@@ -147,17 +147,17 @@ require_paths:
147
147
  - lib
148
148
  required_ruby_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - '>='
155
+ - - ">="
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.0.3
160
+ rubygems_version: 2.2.0
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Map Redis types directly to Ruby objects