batchy 0.2.1 → 0.2.2

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.
@@ -72,7 +72,7 @@ module Batchy
72
72
  # Removes duplicate batches that are stuck in
73
73
  # a running state
74
74
  def clear_zombies
75
- duplicate_batches.each do | dup |
75
+ duplicate_batches(:limit_to_current_host => true).each do | dup |
76
76
  if not dup.process_running?
77
77
  dup.error = Batchy::Error.new("Process has died, moving to a finished state")
78
78
  dup.finish!
@@ -82,10 +82,23 @@ module Batchy
82
82
 
83
83
  # Find all batches with the same guid that are
84
84
  # running.
85
- def duplicate_batches
85
+ #
86
+ # limit_to_current_host
87
+ # This option limit duplicate batches to the
88
+ # current host.
89
+ # Default: false
90
+ #
91
+ def duplicate_batches *args
92
+ options = args.extract_options!
93
+ options.reverse_merge! :limit_to_current_host => false
94
+
86
95
  raise Batchy::Error, "Can not check for duplicate batches on nil guid" if guid.nil?
87
96
 
88
97
  rel = self.class.where(:guid => guid, :state => "running")
98
+
99
+ if options[:limit_to_current_host]
100
+ rel = rel.where(:hostname => Socket.gethostname)
101
+ end
89
102
  return rel if new_record?
90
103
 
91
104
  rel.where("id <> ?", id)
@@ -1,3 +1,3 @@
1
1
  module Batchy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: batchy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bob Briski
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - ">="
170
170
  - !ruby/object:Gem::Version
171
- hash: 1197839351505114963
171
+ hash: -1782560018282016053
172
172
  segments:
173
173
  - 0
174
174
  version: "0"
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- hash: 1197839351505114963
180
+ hash: -1782560018282016053
181
181
  segments:
182
182
  - 0
183
183
  version: "0"