governor_background 0.2.0 → 0.2.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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ./
3
3
  specs:
4
- governor_background (0.2.0)
4
+ governor_background (0.2.1)
5
5
  governor
6
6
 
7
7
  GEM
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{governor_background}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Liam Morley"]
12
- s.date = %q{2011-05-12}
12
+ s.date = %q{2011-05-13}
13
13
  s.description = %q{A middle-tier plugin for the Rails 3-based Governor blogging system, allowing you to tie in additional services that might want to perform blog-related services in the background.}
14
14
  s.email = %q{liam@carpeliam.com}
15
15
  s.extra_rdoc_files = [
@@ -12,7 +12,7 @@ background = Governor::Plugin.new('background')
12
12
  background.register_model_callback do |base|
13
13
  module InstanceMethods
14
14
  private
15
- def run_in_background(method, arguments=[])
15
+ def run_in_background(method, *arguments)
16
16
  GovernorBackground::Handler.run_in_background self, method, arguments
17
17
  end
18
18
  end
@@ -1,7 +1,7 @@
1
1
  module GovernorBackground
2
2
  class Handler
3
3
  class << self
4
- def run_in_background(object, method, arguments=[])
4
+ def run_in_background(object, method, *arguments)
5
5
  job = if delayed_job?
6
6
  Delayed::Job.new(object, method, ::Delayed::Job.enqueue(Delayed::Performer.new(object, method, arguments)))
7
7
  elsif resque?
@@ -3,7 +3,7 @@ module GovernorBackground
3
3
  class Performer
4
4
  @queue = :governor
5
5
 
6
- def self.perform(resource, id, method_name, arguments=[])
6
+ def self.perform(resource, id, method_name, *arguments)
7
7
  article = Governor.resources[resource].to.find(id)
8
8
  if arguments.blank?
9
9
  article.send(method_name)
@@ -42,5 +42,12 @@ module GovernorBackground
42
42
  id = JobManager.jobs.first.id
43
43
  Resque::PerformerWithState.should have_queued(id, {:resource => :articles, :id => @article.id, :method_name => :post, :arguments => []}).in(:governor)
44
44
  end
45
+
46
+ it "can accept any number of arguments" do
47
+ Handler.use_resque = true
48
+ Handler.run_in_background(@article, :post, 1, 2, 3)
49
+ id = JobManager.jobs.first.id
50
+ Resque::PerformerWithState.should have_queued(id, {:resource => :articles, :id => @article.id, :method_name => :post, :arguments => [1, 2, 3]}).in(:governor)
51
+ end
45
52
  end
46
53
  end
@@ -6,12 +6,17 @@ module GovernorBackground
6
6
  before do
7
7
  ResqueSpec.reset!
8
8
  @article = Factory(:article, :author => Factory(:user))
9
- ::Resque.enqueue(Performer, :articles, @article.id, :post)
10
9
  end
11
10
 
12
11
  it "adds article.post to the :governor queue" do
12
+ ::Resque.enqueue(Performer, :articles, @article.id, :post)
13
13
  Performer.should have_queued(:articles, @article.id, :post).in(:governor)
14
14
  end
15
+
16
+ it "accepts any number of arguments" do
17
+ ::Resque.enqueue(Performer, :articles, @article.id, :post, 1, 2, 3)
18
+ Performer.should have_queued(:articles, @article.id, :post, 1, 2, 3).in(:governor)
19
+ end
15
20
  end
16
21
  end
17
22
  end
@@ -1,7 +1,9 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe GovernorBackground do
4
- it "adds #run_in_background to Article" do
5
- Article.private_instance_methods.include? 'run_in_background'
4
+ it "passes arguments to the handler" do
5
+ @article = Factory(:article, :author => Factory(:user))
6
+ GovernorBackground::Handler.expects(:run_in_background).with(@article, :some_method, [1, 2, 3])
7
+ @article.send(:run_in_background, :some_method, 1, 2, 3)
6
8
  end
7
9
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- governor_background (0.2.0)
4
+ governor_background (0.2.1)
5
5
  governor
6
6
 
7
7
  GEM
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: governor_background
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Liam Morley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-12 00:00:00 -04:00
18
+ date: 2011-05-13 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency