rocketjob 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c01cfe6dbadea5f8d327a520b68c7262b1bcff96
4
- data.tar.gz: 4e52926f26dc216852bae81f780b48103a5625fe
3
+ metadata.gz: b2d5bd2e258623a70cb2ac81bb559db1302d2c40
4
+ data.tar.gz: 5e478b33ac8e404496ca112536dcd57e24d3b369
5
5
  SHA512:
6
- metadata.gz: 3286460b8ce4f27c31c47226b5d157c62541114f0c645b1260ff6cbe86cdd23f985bd6c180024b2812bf8b0ca650634e186f28faf0f5a87c0648a2cdd3edcff3
7
- data.tar.gz: 26af31595e81983ab38e70fbc2b2d1c5101a876bfa2fcfdf9a465648e87269f42c70ee9fb580b9bfda6cfbacec18d67d36d502d235d3a22e0e7e8d5a372947af
6
+ metadata.gz: 6c39b919588cd3f58490294e92ef2233f397a867b4e3bf41073e16374238348f6a2ec892a2dfbcc73ed838ef62c3344a6a3d7ec9289e70ba4ee575cf5ab096a7
7
+ data.tar.gz: 07603275a4346907ea05613012582cbf746571011d25bb4bb42d3bfa022932c8867030025a338e83aa21f8de9eb597e9cee83d9cb34e3eb9175054da8c2101d9
@@ -234,6 +234,11 @@ module RocketJob
234
234
  end
235
235
  end
236
236
 
237
+ # Returns a human readable duration the job has taken
238
+ def duration
239
+ seconds_as_duration(seconds)
240
+ end
241
+
237
242
  # A job has expired if the expiry time has passed before it is started
238
243
  def expired?
239
244
  started_at.nil? && expires_at && (expires_at < Time.now)
@@ -241,7 +246,7 @@ module RocketJob
241
246
 
242
247
  # Returns [Hash] status of this job
243
248
  def as_json
244
- attrs = serializable_hash(methods: :seconds)
249
+ attrs = serializable_hash(methods: [:seconds, :duration])
245
250
  attrs.delete('result') unless collect_output?
246
251
  case
247
252
  when running?
@@ -268,9 +273,7 @@ module RocketJob
268
273
 
269
274
  def status(time_zone='Eastern Time (US & Canada)')
270
275
  h = as_json
271
- if seconds = h.delete('seconds')
272
- h['duration'] = seconds_as_duration(seconds)
273
- end
276
+ h.delete('seconds')
274
277
  h.delete('perform_method') if h['perform_method'] == :perform
275
278
  h.dup.each_pair do |k,v|
276
279
  case
@@ -317,11 +320,13 @@ module RocketJob
317
320
 
318
321
  def before_complete
319
322
  self.percent_complete = 100
320
- self.completed_at = Time.now
323
+ self.completed_at = Time.now
324
+ self.worker_name = nil
321
325
  end
322
326
 
323
327
  def before_fail
324
328
  self.completed_at = Time.now
329
+ self.worker_name = nil
325
330
  end
326
331
 
327
332
  def before_retry
@@ -330,6 +335,7 @@ module RocketJob
330
335
 
331
336
  def before_pause
332
337
  self.completed_at = Time.now
338
+ self.worker_name = nil
333
339
  end
334
340
 
335
341
  def before_resume
@@ -338,13 +344,14 @@ module RocketJob
338
344
 
339
345
  def before_abort
340
346
  self.completed_at = Time.now
347
+ self.worker_name = nil
341
348
  end
342
349
 
343
350
  # Returns a human readable duration from the supplied [Float] number of seconds
344
351
  def seconds_as_duration(seconds)
345
352
  time = Time.at(seconds)
346
353
  if seconds >= 1.day
347
- "#{seconds / 1.day}d #{time.strftime('%-Hh %-Mm %-Ss')}"
354
+ "#{(seconds / 1.day).to_i}d #{time.strftime('%-Hh %-Mm %-Ss')}"
348
355
  elsif seconds >= 1.hour
349
356
  time.strftime('%-Hh %-Mm %-Ss')
350
357
  elsif seconds >= 1.minute
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module RocketJob #:nodoc
3
- VERSION = "0.9.0"
3
+ VERSION = "0.9.1"
4
4
  end
@@ -40,7 +40,7 @@ class WorkerTest < Minitest::Test
40
40
  assert_equal true, @job.completed?
41
41
  assert_equal 2, Jobs::TestJob.result
42
42
 
43
- assert @job.worker_name
43
+ assert_nil @job.worker_name
44
44
  assert @job.completed_at
45
45
  assert @job.created_at
46
46
  assert_nil @job.description
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm