acts_as_executor 1.0.0.rc3 → 1.0.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # acts_as_executor
2
2
 
3
- acts_as_executor seamlessly integrates Java’s Executor framework with JRuby on Rails, enabling an application to use executors in a familiar Rails’eque way.
3
+ acts_as_executor seamlessly integrates Java’s Executor framework with Ruby on Rails, enabling an application to use executors in a familiar Rails’eque way.
4
4
 
5
5
  [RubyGems][ruby_gems] | [GitHub][github] | [Travis CI][travis_ci] | [RubyDoc][ruby_doc] | [Wiki][wiki]
6
6
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["philostler@gmail.com"]
11
11
  s.homepage = "https://github.com/philostler/acts_as_executor"
12
12
  s.summary = %q{Java Executor framework integration for Rails}
13
- s.description = %q{Seamlessly integrates Java's Executor framework with JRuby on Rails}
13
+ s.description = %q{Seamlessly integrates Java's Executor framework with Ruby on Rails}
14
14
 
15
15
  s.files = Dir[".rspec"] +
16
16
  Dir["acts_as_executor.gemspec"] +
@@ -13,6 +13,7 @@ module ActsAsExecutor
13
13
 
14
14
  # Validations
15
15
  base.validates :name, :presence => true, :uniqueness => true
16
+ base.validates :max_tasks, :presence => true, :if => :schedulable?
16
17
  base.validates :max_tasks, :numericality => { :only_integer => true, :greater_than_or_equal_to => 1 }, :allow_nil => true
17
18
  end
18
19
 
@@ -31,8 +31,8 @@ module ActsAsExecutor
31
31
  instance = instantiate executable, arguments
32
32
 
33
33
  self.future = executor.send(:execute, instance, id.to_s, schedule, start, every, units)
34
- future.done_handler = method :done_handler
35
- rescue Exception => exception
34
+ future.done_handler = method :done_handler unless executor.send(:schedulable?)
35
+ rescue RuntimeError => exception
36
36
  executor.send(:log).error log_message executor.name, "creating", id.to_s, executable, "encountered an unexpected exception. " + exception.to_s
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsExecutor
2
- VERSION = "1.0.0.rc3"
2
+ VERSION = "1.0.0.rc5"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe ActsAsExecutor do
4
- it { ActsAsExecutor::VERSION.should == "1.0.0.rc3" }
4
+ it { ActsAsExecutor::VERSION.should == "1.0.0.rc5" }
5
5
 
6
6
  describe "#rails_initialized?" do
7
7
  context "when rails initialized" do
@@ -2,9 +2,10 @@ InstanceSupportMethods.blueprint do
2
2
  end
3
3
 
4
4
  Executor.blueprint do
5
- id { "#{sn}" }
6
- name { "name#{sn}" }
7
- max_tasks { 1 }
5
+ id { "#{sn}" }
6
+ name { "name#{sn}" }
7
+ max_tasks { 1 }
8
+ schedulable { false }
8
9
  end
9
10
 
10
11
  ExecutorTask.blueprint do
@@ -23,7 +23,33 @@ describe ActsAsExecutor::Task::Model::InstanceMethods do
23
23
  @model.send(:future).should == future
24
24
  end
25
25
 
26
- context "when any exception is thrown" do
26
+ it "should set done handler on future" do
27
+ future = double "Future"
28
+ future.stub :done_handler=
29
+
30
+ @model.should_receive(:instantiate).and_return @executable
31
+ @model.executor.should_receive(:execute).with(@executable, @model.id.to_s, @model.schedule, @model.start, @model.every, @model.units).and_return future
32
+ future.should_receive(:done_handler=).with @model.method(:done_handler)
33
+
34
+ @model.send :enqueue
35
+ end
36
+
37
+ context "when executor is schedulable" do
38
+ before(:each) { @model = ExecutorTask.make(:executor => Executor.make(:schedulable => true)) }
39
+
40
+ it "should not set done handler on future" do
41
+ future = double "Future"
42
+ future.stub :done_handler=
43
+
44
+ @model.should_receive(:instantiate).and_return @executable
45
+ @model.executor.should_receive(:execute).with(@executable, @model.id.to_s, @model.schedule, @model.start, @model.every, @model.units).and_return future
46
+ future.should_not_receive :done_handler=
47
+
48
+ @model.send :enqueue
49
+ end
50
+ end
51
+
52
+ context "when runtime exception is thrown" do
27
53
  it "should log exception" do
28
54
  exception = RuntimeError.new
29
55
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: acts_as_executor
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.0.0.rc3
5
+ version: 1.0.0.rc5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Phil Ostler
@@ -10,7 +10,8 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-22 00:00:00 Z
13
+ date: 2011-10-24 00:00:00 +01:00
14
+ default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activemodel
@@ -67,7 +68,7 @@ dependencies:
67
68
  version: "2.6"
68
69
  type: :development
69
70
  version_requirements: *id005
70
- description: Seamlessly integrates Java's Executor framework with JRuby on Rails
71
+ description: Seamlessly integrates Java's Executor framework with Ruby on Rails
71
72
  email:
72
73
  - philostler@gmail.com
73
74
  executables: []
@@ -125,6 +126,7 @@ files:
125
126
  - spec/task/model/instance_support_methods_spec.rb
126
127
  - spec/validators/class_exists_validator_spec.rb
127
128
  - spec/validators/class_subclasses_validator_spec.rb
129
+ has_rdoc: true
128
130
  homepage: https://github.com/philostler/acts_as_executor
129
131
  licenses: []
130
132
 
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  requirements: []
149
151
 
150
152
  rubyforge_project:
151
- rubygems_version: 1.8.10
153
+ rubygems_version: 1.5.1
152
154
  signing_key:
153
155
  specification_version: 3
154
156
  summary: Java Executor framework integration for Rails