swagger 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -87,10 +87,14 @@ class RedisImpersonator
87
87
  options = { :conditions => {
88
88
  :key => list_name.to_s,
89
89
  :key_type=> LIST}}
90
- options.merge!(:limit => end_range, :offset => start_range) unless end_range < 0
90
+ unless end_range < 0
91
+ limit = end_range - start_range + 1
92
+ options.merge!(:limit => limit, :offset => start_range)
93
+ end
91
94
  values = ResqueValue.all(options)
92
95
  values.map(&:value)
93
96
  end
97
+
94
98
 
95
99
  def lrem(list_name, count, value)
96
100
  raise "Only supports count of 0 which means to remove all elements in list" if count != 0
@@ -111,6 +115,12 @@ class RedisImpersonator
111
115
  ResqueValue.create!(:key => list_name.to_s, :key_type => LIST, :value => value.to_s)
112
116
  end
113
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
+
114
124
  def keys(pattern = '*')
115
125
  raise "Pattern '#{pattern}' not supported" if pattern != '*'
116
126
  ResqueValue.all(:select => 'DISTINCT resque_values.key').map(&:key)
@@ -134,6 +134,25 @@ describe 'RedisImpersonator' do
134
134
  impersonator.lrange('some_queue', 0, -1).should include('one')
135
135
  end
136
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
137
156
  end
138
157
 
139
158
  it 'should increment a value' do
@@ -149,4 +168,4 @@ describe 'RedisImpersonator' do
149
168
  impersonator.decrby('something', 1)
150
169
  impersonator.get('something').should == '1'
151
170
  end
152
- end
171
+ end
data/swagger.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{swagger}
8
- s.version = "1.3.1"
8
+ s.version = "1.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mdeiters"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 1
9
- version: 1.3.1
8
+ - 2
9
+ version: 1.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - mdeiters