resque-jobs-per-fork 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -20,6 +20,7 @@ This plugin also defines 2 new hooks that get called after the fork starts and b
20
20
  worker.log("Your message here")
21
21
  end
22
22
 
23
+ Version 0.5.x works on Resque 1.11.x
23
24
  Version 0.4.x works on Resque 1.10.x
24
25
  Version 0.3.x works on Resque 1.8.x
25
26
 
@@ -35,4 +36,4 @@ Version 0.3.x works on Resque 1.8.x
35
36
 
36
37
  == Copyright
37
38
 
38
- Copyright (c) 2010 Sam Granieri (Inspired by Mick Staugaard). See LICENSE for details.
39
+ Copyright (c) 2010-2011 Sam Granieri (Inspired by Mick Staugaard). See LICENSE for details.
data/Rakefile CHANGED
@@ -1,54 +1,27 @@
1
1
  require 'rubygems'
2
+ require 'bundler/setup'
3
+
2
4
  require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rake/rdoctask'
3
7
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "resque-jobs-per-fork"
8
- gem.version = "0.4.0"
9
- gem.summary = %Q{Have your resque workers process more that one job}
10
- gem.description = %Q{When your resque jobs are frequent and fast,
11
- the overhead of forking and running your after_fork might get too big.}
12
- gem.email = "sam@samgranieri.com"
13
- gem.homepage = "http://github.com/samgranieri/resque-jobs-per-fork"
14
- gem.authors = ["Sam Granieri, Mick Staugaard"]
15
- gem.add_dependency "resque", "~> 1.10.0"
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
8
+ # Add bundler gem building helpers
9
+ Bundler::GemHelper.install_tasks
21
10
 
22
- require 'rake/testtask'
23
11
  Rake::TestTask.new(:test) do |test|
24
12
  test.libs << 'lib' << 'test'
25
13
  test.pattern = 'test/**/test_*.rb'
26
14
  test.verbose = true
27
15
  end
28
16
 
29
- begin
30
- require 'rcov/rcovtask'
31
- Rcov::RcovTask.new do |test|
32
- test.libs << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
- rescue LoadError
37
- task :rcov do
38
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
- end
40
- end
41
-
42
- task :test => :check_dependencies
43
-
44
17
  task :default => :test
45
18
 
46
- require 'rake/rdoctask'
47
19
  Rake::RDocTask.new do |rdoc|
48
20
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
21
 
50
22
  rdoc.rdoc_dir = 'rdoc'
51
23
  rdoc.title = "resque-jobs-per-fork #{version}"
52
24
  rdoc.rdoc_files.include('README*')
25
+ rdoc.rdoc_files.include('LICENSE')
53
26
  rdoc.rdoc_files.include('lib/**/*.rb')
54
27
  end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'test/unit'
5
+
6
+ $:.unshift File.expand_path('../', __FILE__)
7
+ $:.unshift File.expand_path('../../lib', __FILE__)
8
+
9
+ require 'resque-jobs-per-fork'
10
+
11
+ Bundler.require(:default, :development)
@@ -1,32 +1,32 @@
1
- require 'helper'
1
+ require 'test_helper'
2
2
 
3
3
  class SomeJob
4
4
  def self.perform(i)
5
5
  $SEQUENCE << "work_#{i}".to_sym
6
- puts 'working...'
7
- sleep(0.1)
8
6
  end
9
7
  end
10
8
 
11
9
  Resque.before_perform_jobs_per_fork do |worker|
12
- $SEQUENCE << "before_perform_jobs_per_fork".to_sym
10
+ $SEQUENCE << :before_perform_jobs_per_fork
13
11
  end
14
12
 
15
13
  Resque.after_perform_jobs_per_fork do |worker|
16
- $SEQUENCE << "after_perform_jobs_per_fork".to_sym
14
+ $SEQUENCE << :after_perform_jobs_per_fork
17
15
  end
18
16
 
19
17
  class TestResqueMultiJobFork < Test::Unit::TestCase
20
18
  def setup
21
19
  $SEQUENCE = []
22
- Resque.redis.flushdb
20
+
23
21
  ENV['JOBS_PER_FORK'] = '2'
24
22
  @worker = Resque::Worker.new(:jobs)
23
+ @worker.cant_fork = true
25
24
  end
26
25
 
27
26
  def test_one_job
28
27
  Resque::Job.create(:jobs, SomeJob, 1)
29
28
  @worker.work(0)
29
+
30
30
  assert_equal([:before_perform_jobs_per_fork, :work_1, :after_perform_jobs_per_fork], $SEQUENCE)
31
31
  end
32
32
 
@@ -42,8 +42,11 @@ class TestResqueMultiJobFork < Test::Unit::TestCase
42
42
  Resque::Job.create(:jobs, SomeJob, 2)
43
43
  Resque::Job.create(:jobs, SomeJob, 3)
44
44
  @worker.work(0)
45
- assert_equal([:before_perform_jobs_per_fork, :work_1, :work_2, :after_perform_jobs_per_fork,
46
- :before_perform_jobs_per_fork, :work_3, :after_perform_jobs_per_fork], $SEQUENCE)
45
+
46
+ assert_equal([
47
+ :before_perform_jobs_per_fork, :work_1, :work_2, :after_perform_jobs_per_fork,
48
+ :before_perform_jobs_per_fork, :work_3, :after_perform_jobs_per_fork
49
+ ], $SEQUENCE)
47
50
  end
48
51
 
49
52
  def test_work_normally_if_env_var_set
@@ -55,9 +58,10 @@ class TestResqueMultiJobFork < Test::Unit::TestCase
55
58
 
56
59
  def test_crash_if_no_env_var_set
57
60
  ENV.delete('JOBS_PER_FORK')
61
+
58
62
  assert_raise(RuntimeError) do
59
63
  Resque::Job.create(:jobs, SomeJob, 1)
60
64
  @worker.work(0)
61
65
  end
62
66
  end
63
- end
67
+ end
metadata CHANGED
@@ -1,66 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-jobs-per-fork
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
- - Sam Granieri, Mick Staugaard
13
+ - Sam Granieri
14
+ - Mick Staugaard
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-24 00:00:00 -05:00
19
+ date: 2011-02-24 00:00:00 -06:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: resque
23
23
  prerelease: false
24
+ type: :runtime
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ~>
28
29
  - !ruby/object:Gem::Version
29
- hash: 63
30
+ hash: 27
30
31
  segments:
31
32
  - 1
32
33
  - 10
33
- - 0
34
- version: 1.10.0
35
- type: :runtime
34
+ version: "1.10"
36
35
  version_requirements: *id001
37
- description: |-
38
- When your resque jobs are frequent and fast,
39
- the overhead of forking and running your after_fork might get too big.
40
- email: sam@samgranieri.com
36
+ name: resque
37
+ description: When your resque jobs are frequent and fast, the overhead of forking and running your after_fork might get too big.
38
+ email:
39
+ - sam@samgranieri.com
41
40
  executables: []
42
41
 
43
42
  extensions: []
44
43
 
45
- extra_rdoc_files:
46
- - LICENSE
47
- - README.rdoc
44
+ extra_rdoc_files: []
45
+
48
46
  files:
49
- - .document
50
- - .gitignore
47
+ - lib/resque-jobs-per-fork.rb
48
+ - test/test_helper.rb
49
+ - test/test_resque-jobs-per-fork.rb
51
50
  - LICENSE
52
51
  - README.rdoc
53
52
  - Rakefile
54
- - lib/resque-jobs-per-fork.rb
55
- - test/helper.rb
56
- - test/test_resque-jobs-per-fork.rb
57
53
  has_rdoc: true
58
54
  homepage: http://github.com/samgranieri/resque-jobs-per-fork
59
55
  licenses: []
60
56
 
61
57
  post_install_message:
62
- rdoc_options:
63
- - --charset=UTF-8
58
+ rdoc_options: []
59
+
64
60
  require_paths:
65
61
  - lib
66
62
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -84,10 +80,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
80
  requirements: []
85
81
 
86
82
  rubyforge_project:
87
- rubygems_version: 1.3.7
83
+ rubygems_version: 1.5.2
88
84
  signing_key:
89
85
  specification_version: 3
90
86
  summary: Have your resque workers process more that one job
91
- test_files:
92
- - test/helper.rb
93
- - test/test_resque-jobs-per-fork.rb
87
+ test_files: []
88
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
- *.gemspec
21
-
22
- ## PROJECT::SPECIFIC
data/test/helper.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
-
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
- $LOAD_PATH.unshift(File.dirname(__FILE__))
6
- $TESTING = true
7
-
8
- require 'resque-jobs-per-fork'