ncr-background_fu 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +2 -0
- data/README.txt +2 -1
- data/Rakefile +7 -0
- data/background-fu.gemspec +3 -3
- data/lib/background_fu.rb +1 -1
- data/lib/job.rb +2 -2
- data/rails/init.rb +3 -4
- data/test/job_test.rb +14 -0
- data/test/test_helper.rb +39 -0
- metadata +4 -2
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
=== 1.0.10 / 2009-02-07
|
4
|
+
|
5
|
+
* Compatibility fixes for Rails 2.2.2. [infused, ovelar, ncr]
|
6
|
+
* Allow concurrency is deprecated in Rails 2.2 so we check if we can use it. (thanks fixlr).
|
7
|
+
|
1
8
|
=== 1.0.9 / 2008-10-22
|
2
9
|
|
3
10
|
* Merged a few important fixes from Keith Morrison. Bumped version, fixed gemspec (thanks 森山 誠二郎). Closes #4. [Keith Morrison, 森山 誠二郎, ncr]
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -17,13 +17,14 @@ Background tasks in Ruby On Rails made dead simple.
|
|
17
17
|
* Clean and straightforward approach (database-based priority queue).
|
18
18
|
* Uses database table (migration included) to store jobs reliably.
|
19
19
|
* Capistrano tasks included.
|
20
|
-
* Generators with migrations and example views included (to be used with concurrency enabled).
|
20
|
+
* Generators with migrations and example views (Prototype required) included (to be used with concurrency enabled).
|
21
21
|
* Multiple worker daemons available.
|
22
22
|
* Easy to deploy in distributed environments.
|
23
23
|
* Enables prioritizing and simple scheduling.
|
24
24
|
* Optional worker monitoring (good for AJAX progress bars).
|
25
25
|
* Proven its stability and reliability in production use.
|
26
26
|
|
27
|
+
|
27
28
|
== SYNOPSIS:
|
28
29
|
|
29
30
|
ruby ./script/generate background
|
data/Rakefile
CHANGED
@@ -6,3 +6,10 @@ Hoe.new('background-fu', BackgroundFu::VERSION) do |p|
|
|
6
6
|
p.rubyforge_name = 'background-fu'
|
7
7
|
p.developer('Jacek Becela', 'jacek.becela@gmail.com')
|
8
8
|
end
|
9
|
+
|
10
|
+
desc 'Test the background-fu plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.pattern = 'test/**/*_test.rb'
|
14
|
+
t.verbose = true
|
15
|
+
end
|
data/background-fu.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{background_fu}
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.10"
|
4
4
|
|
5
5
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jacek Becela"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2009-02-07}
|
10
10
|
s.description = %q{Background tasks in Ruby On Rails made dead simple.}
|
11
11
|
s.email = ["jacek.becela@gmail.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
13
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "background-fu.gemspec", "generators/background/USAGE", "generators/background/background_generator.rb", "generators/background/templates/background.rb", "generators/background/templates/background_ctl", "generators/background/templates/daemons", "generators/background/templates/daemons.yml", "generators/background/templates/example_monitored_worker.rb", "generators/background/templates/example_worker.rb", "generators/background/templates/migration.rb", "generators/background/templates/scaffold/_form.html.erb", "generators/background/templates/scaffold/_job.html.erb", "generators/background/templates/scaffold/_job_deleted.html.erb", "generators/background/templates/scaffold/_progress_indicator.html.erb", "generators/background/templates/scaffold/application_controller.rb", "generators/background/templates/scaffold/background_fu.css", "generators/background/templates/scaffold/index.html.erb", "generators/background/templates/scaffold/jobs.html.erb", "generators/background/templates/scaffold/jobs_controller.rb", "generators/background/templates/scaffold/jobs_helper.rb", "generators/background/templates/scaffold/new.html.erb", "lib/background_fu.rb", "lib/background_fu/worker_monitoring.rb", "lib/job.rb", "lib/job/bonus_features.rb", "rails/init.rb"]
|
13
|
+
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "background-fu.gemspec", "generators/background/USAGE", "generators/background/background_generator.rb", "generators/background/templates/background.rb", "generators/background/templates/background_ctl", "generators/background/templates/daemons", "generators/background/templates/daemons.yml", "generators/background/templates/example_monitored_worker.rb", "generators/background/templates/example_worker.rb", "generators/background/templates/migration.rb", "generators/background/templates/scaffold/_form.html.erb", "generators/background/templates/scaffold/_job.html.erb", "generators/background/templates/scaffold/_job_deleted.html.erb", "generators/background/templates/scaffold/_progress_indicator.html.erb", "generators/background/templates/scaffold/application_controller.rb", "generators/background/templates/scaffold/background_fu.css", "generators/background/templates/scaffold/index.html.erb", "generators/background/templates/scaffold/jobs.html.erb", "generators/background/templates/scaffold/jobs_controller.rb", "generators/background/templates/scaffold/jobs_helper.rb", "generators/background/templates/scaffold/new.html.erb", "lib/background_fu.rb", "lib/background_fu/worker_monitoring.rb", "lib/job.rb", "lib/job/bonus_features.rb", "rails/init.rb", "test/job_test.rb", "test/test_helper.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://github.com/ncr/background-fu}
|
16
16
|
s.rdoc_options = ["--main", "README.txt"]
|
data/lib/background_fu.rb
CHANGED
data/lib/job.rb
CHANGED
@@ -56,7 +56,7 @@ class Job < ActiveRecord::Base
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def invoke_worker
|
59
|
-
self.result = @worker.send
|
59
|
+
self.result = @worker.send(worker_method, *args)
|
60
60
|
self.state = "finished"
|
61
61
|
logger.info("BackgroundFu: Job finished. Job(id: #{id}).")
|
62
62
|
end
|
@@ -83,7 +83,7 @@ class Job < ActiveRecord::Base
|
|
83
83
|
end
|
84
84
|
|
85
85
|
# Job.running => array of running jobs, etc.
|
86
|
-
self.class.send
|
86
|
+
self.class.send(:define_method, state_name) do
|
87
87
|
find_all_by_state(state_name, :order => "id desc")
|
88
88
|
end
|
89
89
|
end
|
data/rails/init.rb
CHANGED
@@ -3,9 +3,8 @@ require 'background_fu/worker_monitoring'
|
|
3
3
|
require 'job'
|
4
4
|
require 'job/bonus_features'
|
5
5
|
|
6
|
-
|
7
|
-
Dependencies.load_paths << "#{RAILS_ROOT}/lib/workers"
|
6
|
+
ActiveSupport::Dependencies.load_paths << "#{RAILS_ROOT}/lib/workers"
|
8
7
|
|
9
|
-
if ActiveRecord::Base.allow_concurrency
|
10
|
-
Job.send
|
8
|
+
if ActiveRecord::Base.method_defined?(:allow_concurrency) and ActiveRecord::Base.allow_concurrency
|
9
|
+
Job.send(:include, Job::BonusFeatures)
|
11
10
|
end
|
data/test/job_test.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/job.rb'
|
3
|
+
|
4
|
+
class JobTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
ActiveRecord::Base.allow_concurrency = false
|
8
|
+
@job = Job.new
|
9
|
+
end
|
10
|
+
|
11
|
+
should_have_readonly_attributes :worker_class, :worker_method, :args
|
12
|
+
should_require_attributes :worker_class, :worker_method
|
13
|
+
|
14
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# supress warnings
|
2
|
+
$VERBOSE = false
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mocha'
|
6
|
+
require 'active_record'
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
# gem install thoughtbot-shoulda --source http://gems.github.com
|
10
|
+
require 'shoulda'
|
11
|
+
require 'shoulda/active_record'
|
12
|
+
|
13
|
+
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'test.log'))
|
14
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
|
15
|
+
|
16
|
+
ActiveRecord::Schema.define do
|
17
|
+
create_table :jobs do |t|
|
18
|
+
t.string :worker_class
|
19
|
+
t.string :worker_method
|
20
|
+
|
21
|
+
t.text :args
|
22
|
+
t.text :result
|
23
|
+
|
24
|
+
t.integer :priority
|
25
|
+
|
26
|
+
t.integer :progress
|
27
|
+
t.string :state
|
28
|
+
|
29
|
+
t.integer :lock_version, :default => 0
|
30
|
+
|
31
|
+
t.timestamp :start_at
|
32
|
+
t.timestamp :started_at
|
33
|
+
t.timestamps
|
34
|
+
end
|
35
|
+
|
36
|
+
add_index :jobs, :state
|
37
|
+
add_index :jobs, :start_at
|
38
|
+
add_index :jobs, :priority
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncr-background_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacek Becela
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-07 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,8 @@ files:
|
|
63
63
|
- lib/job.rb
|
64
64
|
- lib/job/bonus_features.rb
|
65
65
|
- rails/init.rb
|
66
|
+
- test/job_test.rb
|
67
|
+
- test/test_helper.rb
|
66
68
|
has_rdoc: true
|
67
69
|
homepage: http://github.com/ncr/background-fu
|
68
70
|
post_install_message:
|