swagger 1.4.0 → 1.4.1
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/.gitignore +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +62 -0
- data/README.rdoc +9 -7
- data/Rakefile +7 -43
- data/lib/resque_extension.rb +3 -3
- data/lib/resque_value.rb +0 -1
- data/lib/swagger.rb +5 -2
- data/lib/swagger/commands/helpers.rb +16 -0
- data/lib/swagger/commands/keys.rb +21 -0
- data/lib/swagger/commands/lists.rb +53 -0
- data/lib/swagger/commands/sets.rb +25 -0
- data/lib/swagger/commands/sorted_sets.rb +56 -0
- data/lib/swagger/commands/strings.rb +60 -0
- data/lib/swagger/redis.rb +26 -0
- data/lib/swagger/swallow.rb +14 -0
- data/lib/swagger/version.rb +7 -0
- data/spec/resque_extension_spec.rb +6 -7
- data/spec/spec_helper.rb +17 -14
- data/spec/support/helpers.rb +7 -0
- data/spec/swagger/commands/sorted_sets_spec.rb +175 -0
- data/spec/swagger/commands/strings_spec.rb +58 -0
- data/spec/swagger/redis_spec.rb +171 -0
- data/swagger.gemspec +12 -52
- metadata +74 -35
- data/VERSION +0 -1
- data/lib/redis_impersonator.rb +0 -129
- data/spec/redis_impersonator_spec.rb +0 -171
- data/spec/spec.opts +0 -1
data/swagger.gemspec
CHANGED
@@ -1,66 +1,26 @@
|
|
1
|
-
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
require File.expand_path('../lib/swagger/version', __FILE__)
|
5
2
|
|
6
3
|
Gem::Specification.new do |s|
|
7
4
|
s.name = %q{swagger}
|
8
|
-
s.version =
|
5
|
+
s.version = Swagger.version
|
9
6
|
|
10
|
-
s.required_rubygems_version =
|
11
|
-
s.authors = ["mdeiters"]
|
7
|
+
s.required_rubygems_version = ">= 1.3.6"
|
8
|
+
s.authors = ["mdeiters", "Justin Ko"]
|
12
9
|
s.date = %q{2011-01-14}
|
13
10
|
s.description = %q{Duck punch Resque to use active record for backround jobs instead of redis}
|
14
11
|
s.email = %q{mdeiters@gmail.com}
|
15
|
-
s.
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/redis_impersonator.rb",
|
27
|
-
"lib/resque_extension.rb",
|
28
|
-
"lib/resque_value.rb",
|
29
|
-
"lib/swagger.rb",
|
30
|
-
"spec/redis_impersonator_spec.rb",
|
31
|
-
"spec/resque_extension_spec.rb",
|
32
|
-
"spec/spec.opts",
|
33
|
-
"spec/spec_helper.rb",
|
34
|
-
"swagger.gemspec"
|
35
|
-
]
|
12
|
+
s.files = `git ls-files`.split("\n")
|
36
13
|
s.homepage = %q{http://github.com/mdeiters/swagger}
|
37
14
|
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
-
s.
|
15
|
+
s.require_path = "lib"
|
39
16
|
s.rubygems_version = %q{1.3.6}
|
40
17
|
s.summary = %q{Everything Resque provides minus Redis}
|
41
|
-
s.test_files = [
|
42
|
-
"spec/redis_impersonator_spec.rb",
|
43
|
-
"spec/resque_extension_spec.rb",
|
44
|
-
"spec/spec_helper.rb"
|
45
|
-
]
|
46
18
|
|
47
|
-
if s.respond_to? :specification_version then
|
48
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
-
s.specification_version = 3
|
50
19
|
|
51
|
-
|
52
|
-
|
53
|
-
s.add_runtime_dependency(%q<activerecord>, [">= 0"])
|
54
|
-
s.add_runtime_dependency(%q<resque>, [">= 1.10.0"])
|
55
|
-
else
|
56
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
-
s.add_dependency(%q<activerecord>, [">= 0"])
|
58
|
-
s.add_dependency(%q<resque>, [">= 1.10.0"])
|
59
|
-
end
|
60
|
-
else
|
61
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
-
s.add_dependency(%q<activerecord>, [">= 0"])
|
63
|
-
s.add_dependency(%q<resque>, [">= 1.10.0"])
|
64
|
-
end
|
65
|
-
end
|
20
|
+
s.add_runtime_dependency("activerecord", ">= 0")
|
21
|
+
s.add_runtime_dependency("resque", ">= 1.10.0")
|
66
22
|
|
23
|
+
s.add_development_dependency("rake", "~> 0.8.7")
|
24
|
+
s.add_development_dependency("rspec", ">= 2.4.0")
|
25
|
+
s.add_development_dependency("sqlite3", ">= 1.3.3")
|
26
|
+
end
|
metadata
CHANGED
@@ -5,11 +5,12 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 1.4.
|
8
|
+
- 1
|
9
|
+
version: 1.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- mdeiters
|
13
|
+
- Justin Ko
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
@@ -18,69 +19,107 @@ date: 2011-01-14 00:00:00 -08:00
|
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
24
|
- - ">="
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
segments:
|
28
|
-
-
|
29
|
-
|
30
|
-
|
31
|
-
version: 1.2.9
|
32
|
-
type: :development
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
27
|
+
- 0
|
28
|
+
version: "0"
|
29
|
+
requirement: *id001
|
35
30
|
name: activerecord
|
36
31
|
prerelease: false
|
37
|
-
|
32
|
+
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
35
|
requirements:
|
39
36
|
- - ">="
|
40
37
|
- !ruby/object:Gem::Version
|
41
38
|
segments:
|
39
|
+
- 1
|
40
|
+
- 10
|
42
41
|
- 0
|
43
|
-
version:
|
42
|
+
version: 1.10.0
|
43
|
+
requirement: *id002
|
44
|
+
name: resque
|
45
|
+
prerelease: false
|
44
46
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
48
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ~>
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
- 8
|
55
|
+
- 7
|
56
|
+
version: 0.8.7
|
57
|
+
requirement: *id003
|
58
|
+
name: rake
|
59
|
+
prerelease: false
|
60
|
+
type: :development
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 2
|
68
|
+
- 4
|
69
|
+
- 0
|
70
|
+
version: 2.4.0
|
71
|
+
requirement: *id004
|
72
|
+
name: rspec
|
48
73
|
prerelease: false
|
49
|
-
|
74
|
+
type: :development
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
50
77
|
requirements:
|
51
78
|
- - ">="
|
52
79
|
- !ruby/object:Gem::Version
|
53
80
|
segments:
|
54
81
|
- 1
|
55
|
-
-
|
56
|
-
-
|
57
|
-
version: 1.
|
58
|
-
|
59
|
-
|
82
|
+
- 3
|
83
|
+
- 3
|
84
|
+
version: 1.3.3
|
85
|
+
requirement: *id005
|
86
|
+
name: sqlite3
|
87
|
+
prerelease: false
|
88
|
+
type: :development
|
60
89
|
description: Duck punch Resque to use active record for backround jobs instead of redis
|
61
90
|
email: mdeiters@gmail.com
|
62
91
|
executables: []
|
63
92
|
|
64
93
|
extensions: []
|
65
94
|
|
66
|
-
extra_rdoc_files:
|
67
|
-
|
68
|
-
- README.rdoc
|
95
|
+
extra_rdoc_files: []
|
96
|
+
|
69
97
|
files:
|
70
98
|
- .document
|
71
99
|
- .gitignore
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
72
102
|
- LICENSE
|
73
103
|
- README.rdoc
|
74
104
|
- Rakefile
|
75
|
-
- VERSION
|
76
|
-
- lib/redis_impersonator.rb
|
77
105
|
- lib/resque_extension.rb
|
78
106
|
- lib/resque_value.rb
|
79
107
|
- lib/swagger.rb
|
80
|
-
-
|
108
|
+
- lib/swagger/commands/helpers.rb
|
109
|
+
- lib/swagger/commands/keys.rb
|
110
|
+
- lib/swagger/commands/lists.rb
|
111
|
+
- lib/swagger/commands/sets.rb
|
112
|
+
- lib/swagger/commands/sorted_sets.rb
|
113
|
+
- lib/swagger/commands/strings.rb
|
114
|
+
- lib/swagger/redis.rb
|
115
|
+
- lib/swagger/swallow.rb
|
116
|
+
- lib/swagger/version.rb
|
81
117
|
- spec/resque_extension_spec.rb
|
82
|
-
- spec/spec.opts
|
83
118
|
- spec/spec_helper.rb
|
119
|
+
- spec/support/helpers.rb
|
120
|
+
- spec/swagger/commands/sorted_sets_spec.rb
|
121
|
+
- spec/swagger/commands/strings_spec.rb
|
122
|
+
- spec/swagger/redis_spec.rb
|
84
123
|
- swagger.gemspec
|
85
124
|
has_rdoc: true
|
86
125
|
homepage: http://github.com/mdeiters/swagger
|
@@ -103,8 +142,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
142
|
- - ">="
|
104
143
|
- !ruby/object:Gem::Version
|
105
144
|
segments:
|
106
|
-
-
|
107
|
-
|
145
|
+
- 1
|
146
|
+
- 3
|
147
|
+
- 6
|
148
|
+
version: 1.3.6
|
108
149
|
requirements: []
|
109
150
|
|
110
151
|
rubyforge_project:
|
@@ -112,7 +153,5 @@ rubygems_version: 1.3.6
|
|
112
153
|
signing_key:
|
113
154
|
specification_version: 3
|
114
155
|
summary: Everything Resque provides minus Redis
|
115
|
-
test_files:
|
116
|
-
|
117
|
-
- spec/resque_extension_spec.rb
|
118
|
-
- spec/spec_helper.rb
|
156
|
+
test_files: []
|
157
|
+
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.4.0
|
data/lib/redis_impersonator.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
class RedisImpersonator
|
2
|
-
SET = 'set'
|
3
|
-
LIST = 'list'
|
4
|
-
|
5
|
-
def self.swallow(method, return_value = nil)
|
6
|
-
define_method(method) do |*args|
|
7
|
-
LOGGER.write("RedisImpersonator: Swallowed #{method} with the following arguments #{args.inspect}") if defined?(LOGGER)
|
8
|
-
return_value
|
9
|
-
end
|
10
|
-
end
|
11
|
-
swallow(:namespace=)
|
12
|
-
swallow(:namespace, 'not applicable')
|
13
|
-
swallow(:server, 'ActiveRecord')
|
14
|
-
swallow(:info, self.inspect)
|
15
|
-
|
16
|
-
def srem(set_name, value)
|
17
|
-
ResqueValue.delete_all(:key => set_name.to_s, :key_type => SET, :value => value.to_s)
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def smembers(set_name)
|
22
|
-
ResqueValue.all(:conditions => {:key => set_name.to_s, :key_type => SET}).map(&:value)
|
23
|
-
end
|
24
|
-
|
25
|
-
def sismember(set_name, value)
|
26
|
-
ResqueValue.exists?(:key => set_name.to_s, :key_type => SET, :value => value.to_s)
|
27
|
-
end
|
28
|
-
|
29
|
-
def sadd(set_name, value)
|
30
|
-
sismember(set_name, value) || ResqueValue.create!(:key => set_name.to_s, :key_type => SET, :value => value.to_s)
|
31
|
-
end
|
32
|
-
|
33
|
-
def set(key, value)
|
34
|
-
resque_value = ResqueValue.find_or_initialize_by_key(key.to_s)
|
35
|
-
resque_value.value = value
|
36
|
-
resque_value.save!
|
37
|
-
value
|
38
|
-
end
|
39
|
-
|
40
|
-
def get(key)
|
41
|
-
resque_value = ResqueValue.first(:conditions => {:key => key})
|
42
|
-
resque_value.value if resque_value
|
43
|
-
end
|
44
|
-
|
45
|
-
def del(key)
|
46
|
-
ResqueValue.delete_all(:key => key.to_s)
|
47
|
-
nil
|
48
|
-
end
|
49
|
-
|
50
|
-
def exists(key)
|
51
|
-
ResqueValue.exists?(:key => key.to_s)
|
52
|
-
end
|
53
|
-
|
54
|
-
def incrby(key, value)
|
55
|
-
object = ResqueValue.find_or_initialize_by_key(key.to_s)
|
56
|
-
object.value = (object.value.to_i + value.to_i).to_s
|
57
|
-
object.save!
|
58
|
-
object.value
|
59
|
-
end
|
60
|
-
|
61
|
-
def decrby(key, value)
|
62
|
-
object = ResqueValue.find_or_initialize_by_key(key.to_s)
|
63
|
-
object.value = (object.value.to_i - value.to_i).to_s
|
64
|
-
object.save!
|
65
|
-
object.value
|
66
|
-
end
|
67
|
-
|
68
|
-
def mapped_mget(*keys)
|
69
|
-
Hash[*keys.zip(mget(*keys)).flatten]
|
70
|
-
end
|
71
|
-
|
72
|
-
def mget(*keys)
|
73
|
-
keys.collect!{|key| key.to_s }
|
74
|
-
resque_values = ResqueValue.all(:conditions => {:key => keys})
|
75
|
-
resque_values.map(&:value)
|
76
|
-
end
|
77
|
-
|
78
|
-
def llen(list_name)
|
79
|
-
ResqueValue.all(:conditions => {:key => list_name.to_s, :key_type=> LIST }).size
|
80
|
-
end
|
81
|
-
|
82
|
-
def lset(list_name, index, value)
|
83
|
-
rpush(list_name, value)
|
84
|
-
end
|
85
|
-
|
86
|
-
def lrange(list_name, start_range, end_range)
|
87
|
-
options = { :conditions => {
|
88
|
-
:key => list_name.to_s,
|
89
|
-
:key_type=> LIST}}
|
90
|
-
unless end_range < 0
|
91
|
-
limit = end_range - start_range + 1
|
92
|
-
options.merge!(:limit => limit, :offset => start_range)
|
93
|
-
end
|
94
|
-
values = ResqueValue.all(options)
|
95
|
-
values.map(&:value)
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
def lrem(list_name, count, value)
|
100
|
-
raise "Only supports count of 0 which means to remove all elements in list" if count != 0
|
101
|
-
ResqueValue.delete_all(:key => list_name.to_s, :key_type=> LIST, :value => value )
|
102
|
-
end
|
103
|
-
|
104
|
-
def lpop(list_name)
|
105
|
-
ResqueValue.transaction do
|
106
|
-
last = ResqueValue.last(:conditions => {:key => list_name.to_s, :key_type => LIST}, :lock => true)
|
107
|
-
if last
|
108
|
-
last.destroy
|
109
|
-
return last.value
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def rpush(list_name, value)
|
115
|
-
ResqueValue.create!(:key => list_name.to_s, :key_type => LIST, :value => value.to_s)
|
116
|
-
end
|
117
|
-
|
118
|
-
def ltrim(list_name, start_range, end_range)
|
119
|
-
limit = end_range - start_range + 1
|
120
|
-
ids = ResqueValue.all(:select => "id", :conditions => {:key => list_name}, :offset => start_range, :limit => limit)
|
121
|
-
ResqueValue.delete_all(["`key` = ? AND id NOT IN (?)", list_name, ids.collect{|i| i.id}])
|
122
|
-
end
|
123
|
-
|
124
|
-
def keys(pattern = '*')
|
125
|
-
raise "Pattern '#{pattern}' not supported" if pattern != '*'
|
126
|
-
ResqueValue.all(:select => 'DISTINCT resque_values.key').map(&:key)
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe 'RedisImpersonator' do
|
4
|
-
let(:impersonator) { RedisImpersonator.new }
|
5
|
-
|
6
|
-
|
7
|
-
it 'responds to info' do
|
8
|
-
impersonator.info.should_not be_nil
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'swallows calls to namespace' do
|
12
|
-
lambda{impersonator.namespace = 'value'}.should_not raise_error
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'manipulating key values' do
|
16
|
-
it 'it can get key values' do
|
17
|
-
impersonator.set('key', 'value').should == 'value'
|
18
|
-
impersonator.get('key').should == 'value'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'can create new key values' do
|
22
|
-
impersonator.set('key', 'value').should == 'value'
|
23
|
-
ResqueValue.first.value.should == 'value'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'can delete key values' do
|
27
|
-
impersonator.set('key', 'value').should == 'value'
|
28
|
-
impersonator.del('key')
|
29
|
-
impersonator.get('key').should be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'can get multiple values by keys' do
|
33
|
-
impersonator.set('key-1', 'one')
|
34
|
-
impersonator.set('key-2', 'two')
|
35
|
-
impersonator.mapped_mget('key-1', 'key-2')['key-1'].should == 'one'
|
36
|
-
impersonator.mapped_mget('key-1', 'key-2')['key-2'].should == 'two'
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'always returns all keys when pattern is *' do
|
40
|
-
impersonator.set('key-1', 'one')
|
41
|
-
impersonator.set('key-2', 'two')
|
42
|
-
impersonator.keys('*').should include('key-1', 'key-2')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'raies error when pattern is not *' do
|
46
|
-
lambda{impersonator.keys('something not *')}.should raise_error
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'managing workes in a set' do
|
51
|
-
it 'can add workers to the queue' do
|
52
|
-
worker = Resque::Worker.new(queues = ['queue1'])
|
53
|
-
impersonator.sadd(:workers, worker)
|
54
|
-
ResqueValue.first.value.should == worker.to_s
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'returns all values in the workers set' do
|
58
|
-
worker = Resque::Worker.new(queues = ['queue1'])
|
59
|
-
impersonator.sadd(:workers, worker)
|
60
|
-
impersonator.smembers(:workers).first.should == worker.to_s
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'removes a worker from the workers set by name' do
|
64
|
-
worker = Resque::Worker.new(queues = ['queue1'])
|
65
|
-
impersonator.sadd(:workers, worker)
|
66
|
-
impersonator.srem(:workers, worker)
|
67
|
-
impersonator.smembers(:workers).should be_empty
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should only add a value to a set once' do
|
71
|
-
impersonator.sadd(:test, 'one')
|
72
|
-
impersonator.sadd(:test, 'one')
|
73
|
-
impersonator.smembers(:test).size.should == 1
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'indicates when worker is in the workers set' do
|
77
|
-
worker = Resque::Worker.new(queues = ['queue1'])
|
78
|
-
|
79
|
-
impersonator.sismember(:workers, worker).should == false
|
80
|
-
impersonator.sadd(:workers, worker)
|
81
|
-
impersonator.sismember(:workers, worker).should == true
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'can delete a whole set by name' do
|
85
|
-
impersonator.sadd(:test, 'one')
|
86
|
-
impersonator.sadd(:test, 'two')
|
87
|
-
impersonator.del(:test)
|
88
|
-
impersonator.smembers(:test).should be_empty
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'working with lists' do
|
93
|
-
it 'should return nil if no items on a queue' do
|
94
|
-
impersonator.lpop('some_queue').should be_nil
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'ingores index and adds item to list' do
|
98
|
-
impersonator.lset('some_queue', 88, 'value')
|
99
|
-
impersonator.llen('some_queue').should == 1
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should add item to queue and then pop it back off' do
|
103
|
-
impersonator.rpush('some_queue', 'value')
|
104
|
-
impersonator.lpop('some_queue').should == 'value'
|
105
|
-
impersonator.lpop('some_queue').should be_nil
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'should tell you how many items are in a list' do
|
109
|
-
impersonator.rpush('some_queue', 'one')
|
110
|
-
impersonator.rpush('some_queue', 'two')
|
111
|
-
impersonator.llen('some_queue').should == 2
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should be able to paginate through a list' do
|
115
|
-
impersonator.rpush('some_queue', 'one')
|
116
|
-
impersonator.rpush('some_queue', 'two')
|
117
|
-
impersonator.rpush('some_queue', 'three')
|
118
|
-
impersonator.lrange('some_queue', 0, 1).first.should == 'one'
|
119
|
-
impersonator.lrange('some_queue', 2, 3).first.should == 'three'
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should get all results if you pass -1 to lrange' do
|
123
|
-
impersonator.rpush('some_queue', 'one')
|
124
|
-
impersonator.rpush('some_queue', 'two')
|
125
|
-
impersonator.rpush('some_queue', 'three')
|
126
|
-
impersonator.lrange('some_queue', 0, -1).should include('one', 'two', 'three')
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should remove items from queue' do
|
130
|
-
impersonator.rpush('some_queue', 'one')
|
131
|
-
impersonator.rpush('some_queue', 'two')
|
132
|
-
impersonator.rpush('some_queue', 'two')
|
133
|
-
impersonator.lrem('some_queue', 0, 'two').should == 2
|
134
|
-
impersonator.lrange('some_queue', 0, -1).should include('one')
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should trim according to the specifed start and end" do
|
138
|
-
1.upto(6){|i| impersonator.rpush('some_queue', i)}
|
139
|
-
impersonator.ltrim('some_queue', 1, 3)
|
140
|
-
impersonator.llen('some_queue').should == 3
|
141
|
-
impersonator.lrange('some_queue', 0, 2).should == ["2","3","4"]
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should not affect other keys when trimming" do
|
145
|
-
1.upto(3){|i| impersonator.rpush('some_queue', i)}
|
146
|
-
impersonator.set('something_else', 'independent value')
|
147
|
-
impersonator.ltrim('some_queue', 0, 0)
|
148
|
-
impersonator.get('something_else').should == 'independent value'
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should get a range of values" do
|
152
|
-
1.upto(6){|i| impersonator.rpush('some_queue', i)}
|
153
|
-
impersonator.lrange('some_queue', 0, 5).should == ['1','2','3','4','5','6']
|
154
|
-
impersonator.lrange('some_queue', 1, 3).should == ['2','3','4']
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'should increment a value' do
|
159
|
-
impersonator.incrby('something', 2)
|
160
|
-
impersonator.get('something').should == '2'
|
161
|
-
impersonator.incrby('something', 1)
|
162
|
-
impersonator.get('something').should == '3'
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'should decrement a value' do
|
166
|
-
impersonator.incrby('something', 2)
|
167
|
-
impersonator.get('something').should == '2'
|
168
|
-
impersonator.decrby('something', 1)
|
169
|
-
impersonator.get('something').should == '1'
|
170
|
-
end
|
171
|
-
end
|