rediska 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +3 -1
- data/lib/rediska/driver.rb +14 -3
- data/lib/rediska/version.rb +1 -1
- data/rediska.gemspec +1 -0
- data/spec/redis_spec.rb +0 -1
- data/spec/support/hashes.rb +13 -0
- data/spec/support/transactions.rb +8 -0
- metadata +18 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rediska (0.0.
|
4
|
+
rediska (0.0.7)
|
5
5
|
redis (~> 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -17,6 +17,7 @@ GEM
|
|
17
17
|
json (1.8.1)
|
18
18
|
mime-types (1.25)
|
19
19
|
multi_json (1.8.2)
|
20
|
+
rake (10.1.1)
|
20
21
|
rdoc (4.0.1)
|
21
22
|
json (~> 1.4)
|
22
23
|
redis (3.0.6)
|
@@ -44,6 +45,7 @@ PLATFORMS
|
|
44
45
|
|
45
46
|
DEPENDENCIES
|
46
47
|
coveralls
|
48
|
+
rake
|
47
49
|
rdoc
|
48
50
|
rediska!
|
49
51
|
rspec (~> 2.14)
|
data/lib/rediska/driver.rb
CHANGED
@@ -93,7 +93,7 @@ module Rediska
|
|
93
93
|
def bgsave
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
96
|
+
def bgrewriteaof
|
97
97
|
end
|
98
98
|
|
99
99
|
def move key, destination_id
|
@@ -524,10 +524,10 @@ module Rediska
|
|
524
524
|
end
|
525
525
|
|
526
526
|
def hmget(key, *fields)
|
527
|
-
raise_argument_error('hmget')
|
527
|
+
raise_argument_error('hmget') if fields.empty?
|
528
528
|
|
529
529
|
data_type_check(key, Hash)
|
530
|
-
fields.map do |field|
|
530
|
+
fields.flatten.map do |field|
|
531
531
|
field = field.to_s
|
532
532
|
if data[key]
|
533
533
|
data[key][field]
|
@@ -560,6 +560,17 @@ module Rediska
|
|
560
560
|
data[key][field].to_i
|
561
561
|
end
|
562
562
|
|
563
|
+
def hincrbyfloat(key, field, increment)
|
564
|
+
data_type_check(key, Hash)
|
565
|
+
field = field.to_s
|
566
|
+
if data[key]
|
567
|
+
data[key][field] = (data[key][field].to_f + increment.to_f).to_s
|
568
|
+
else
|
569
|
+
data[key] = { field => increment.to_s }
|
570
|
+
end
|
571
|
+
data[key][field]
|
572
|
+
end
|
573
|
+
|
563
574
|
def hexists(key, field)
|
564
575
|
data_type_check(key, Hash)
|
565
576
|
return false unless data[key]
|
data/lib/rediska/version.rb
CHANGED
data/rediska.gemspec
CHANGED
data/spec/redis_spec.rb
CHANGED
data/spec/support/hashes.rb
CHANGED
@@ -64,6 +64,17 @@ shared_examples 'hashes' do
|
|
64
64
|
subject.hincrby('key1', 'cont2', '5').should eq(5)
|
65
65
|
end
|
66
66
|
|
67
|
+
it 'should increment the float value of a hash field by the given float' do
|
68
|
+
subject.hset('key1', 'cont1', 5.0)
|
69
|
+
subject.hincrbyfloat('key1', 'cont1', 4.1).should be == 9.1
|
70
|
+
subject.hget('key1', 'cont1').should be == '9.1'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should increment non existing hash keys' do
|
74
|
+
subject.hget('key1', 'cont2').should be_nil
|
75
|
+
subject.hincrbyfloat('key1', 'cont2', 5.5).should be == 5.5
|
76
|
+
end
|
77
|
+
|
67
78
|
it 'should get all the fields in a hash' do
|
68
79
|
subject.hset('key1', 'i1', 'val1')
|
69
80
|
subject.hset('key1', 'i2', 'val2')
|
@@ -84,6 +95,8 @@ shared_examples 'hashes' do
|
|
84
95
|
subject.hset('key1', 'i2', 'val2')
|
85
96
|
|
86
97
|
subject.hmget('key1', 'i1', 'i2', 'i3').should eq(['val1', 'val2', nil])
|
98
|
+
subject.hmget('key1', ['i1', 'i2', 'i3']).should =~ ['val1', 'val2', nil]
|
99
|
+
|
87
100
|
subject.hmget('key2', 'i1', 'i2').should eq([nil, nil])
|
88
101
|
end
|
89
102
|
|
@@ -8,4 +8,12 @@ shared_examples 'transactions' do
|
|
8
8
|
|
9
9
|
transaction.should eq(['OK', 'OK', ['1', '2']])
|
10
10
|
end
|
11
|
+
|
12
|
+
it 'should execute all command after multi' do
|
13
|
+
subject.multi
|
14
|
+
subject.set('key1', '1')
|
15
|
+
subject.set('key2', '2')
|
16
|
+
subject.mget('key1', 'key2')
|
17
|
+
subject.exec.should be == ['OK', 'OK', ['1', '2']]
|
18
|
+
end
|
11
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rediska
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
description: ! "A light-weighted redis driver for testing, development, and minimal
|
63
79
|
environments,\n which supports various data storage strategies."
|
64
80
|
email:
|