swagger 1.1.2 → 1.2.0

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/README.rdoc CHANGED
@@ -1,22 +1,26 @@
1
- = swagger = (Resque - Redis) + ActiveRecord
1
+ = Swagger = Resque + ActiveRecord - Redis
2
2
 
3
- Swagger allows you to use Resque full featured by only adding one table in your existing database.
4
-
5
- Resque is a great library for creating/running/administering background jobs. Redis is great too but may be overkill for just a few simple background jobs. Swagger marries the power and robustness of Resque with the trivial setup of delayed_job.
3
+ Swagger marries the power and robustness of Resque with the trivial setup of delayed_job. Swagger allows you to use all the features of Resque (http://github.com/defunkt/resque) without any of the "Redis" by adding one table to your existing database.
6
4
 
7
5
  == Getting Started
8
6
 
9
- 1. Add resque and swagger to your gem dependencies (order is important)
7
+ === 1. Add resque and swagger to your gem dependencies (order is important)
10
8
 
11
9
  config.gem 'resque'
12
10
  config.gem 'swagger'
13
11
 
14
- 2. In your rails app, create the file initializers/resque.rb with the following:
12
+ === 2. In your rails app, create the file initializers/resque.rb with the following:
13
+
14
+ environment = ENV['RAILS_ENV'] || 'development'
15
+ database = YAML::load(ERB.new(IO.read(File.join(File.dirname(__FILE__), '..', 'database.yml'))).result)[environment]
15
16
 
16
- Resque.swagger!
17
- Resque.connect_to_database YAML::load(ERB.new(IO.read(File.join(File.dirname(__FILE__), '..', 'database.yml'))).result)[RAILS_ENV]
17
+ require 'swagger'
18
+ Resque.swagger!
19
+ Resque.connect_to_database(database)
20
+
21
+ ==== NOTE: This allows rails and the resque admin app to use the same initializer by executing at the console: resque-web config/initializers/resque.rb
18
22
 
19
- 3. Create an active record migration
23
+ === 3. Create an active record migration
20
24
 
21
25
  create_table :resque_values do |table|
22
26
  table.column :key, :string
@@ -27,8 +31,6 @@ Resque is a great library for creating/running/administering background jobs. Re
27
31
  add_index :resque_values, :key
28
32
  add_index :resque_values, [:key, :key_type]
29
33
 
30
- NOTE: To start up the administration sinatra app with swagger, do the following: resque-web config/initializers/resque.rb
31
-
32
34
  == Note on Patches/Pull Requests
33
35
 
34
36
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.2.0
@@ -84,15 +84,19 @@ class RedisImpersonator
84
84
  end
85
85
 
86
86
  def lrange(list_name, start_range, end_range)
87
- values = ResqueValue.all(
88
- :conditions => {
87
+ options = { :conditions => {
89
88
  :key => list_name.to_s,
90
- :key_type=> LIST},
91
- :offset => start_range,
92
- :limit => end_range)
89
+ :key_type=> LIST}}
90
+ options.merge!(:limit => end_range, :offset => start_range) unless end_range < 0
91
+ values = ResqueValue.all(options)
93
92
  values.map(&:value)
94
93
  end
95
94
 
95
+ def lrem(list_name, count, value)
96
+ raise "Only supports count of 0 which means to remove all elements in list" if count != 0
97
+ ResqueValue.delete_all(:key => list_name.to_s, :key_type=> LIST, :value => value )
98
+ end
99
+
96
100
  def lpop(list_name)
97
101
  last = ResqueValue.last(:conditions => {:key => list_name.to_s, :key_type => LIST})
98
102
  if last
@@ -5,7 +5,7 @@ Resque.module_eval do
5
5
  end
6
6
 
7
7
  define_method(:connect_to_database) do |database|
8
- ResqueValue.establish_connection(database)
8
+ ResqueValue.establish_connection database
9
9
  end
10
10
  end
11
11
  end
@@ -118,6 +118,22 @@ describe 'RedisImpersonator' do
118
118
  impersonator.lrange('some_queue', 0, 1).first.should == 'one'
119
119
  impersonator.lrange('some_queue', 2, 3).first.should == 'three'
120
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
+
121
137
  end
122
138
 
123
139
  it 'should increment a value' do
data/swagger.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{swagger}
8
- s.version = "1.1.2"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mdeiters"]
12
- s.date = %q{2010-07-14}
12
+ s.date = %q{2010-07-22}
13
13
  s.description = %q{Duck punch Resque to use active record for backround jobs instead of redis}
14
14
  s.email = %q{mdeiters@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
7
  - 2
9
- version: 1.1.2
8
+ - 0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - mdeiters
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-14 00:00:00 -07:00
17
+ date: 2010-07-22 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency