job_status 0.1.2 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: faa86031895368a907806319e21723442f2ea5f8
4
- data.tar.gz: ec5d455c495fc411a7fda28e3766eb7db448b511
3
+ metadata.gz: f1b7047448a17dcec8a4e27ed8c5ca00609ad672
4
+ data.tar.gz: 7b678f4198ba576d19aa6383a9a00ddd6780df66
5
5
  SHA512:
6
- metadata.gz: 4b3e0b06727a4d14d945c82002b0dd8649703ffd6bf936b744c118aeb62c3fd8df3d4df7c39c84350c35cc875d9e157fbe368ec40e0601ceb6f7c1370d19e86b
7
- data.tar.gz: c0f6d1734fd48b5996a74dbc918f77664d5c433a661d16f61b3fedeea0c570b009047ec683b2dd1fcd8f4f25a5608696dcd2b9c949261d6f873e30d117902240
6
+ metadata.gz: 5a276f71e8d36d8cacfc4f66c7389d39a741dd74c7254ac47497139fa000bc852a74f6f054bf7fbab7ce1648afdf3bdd7571534a2c23c18d30f8d428eaaebed9
7
+ data.tar.gz: 2cc5487829588315ff38b2d96e2dbbd4ab530dc03fe378ca730afd4edb64c97d55707efa82ebb6c90f80cc7201d1bf4cc34f2f2f2ef80a97db8fa794fb82ba5c
@@ -10,7 +10,7 @@ module JobStatus
10
10
  # @return [Symbol] status Returns status possible valuds
11
11
  # :queued, :working, :completed
12
12
  #
13
- def self.get_status(job_id:)
13
+ def self.get_status(job_id)
14
14
  status = JobStatus.store.fetch(job_id)
15
15
  status ? status[:status] : nil
16
16
  end
@@ -21,7 +21,7 @@ module JobStatus
21
21
  # @param job_id [String] ActiveJob ID to query the store for
22
22
  # @return [Integer] at Value stored by the work for the progress
23
23
  #
24
- def self.at(job_id:)
24
+ def self.at(job_id)
25
25
  status = JobStatus.store.fetch(job_id)
26
26
  status ? status[:at] : nil
27
27
  end
@@ -32,7 +32,7 @@ module JobStatus
32
32
  # @param job_id [String] ActiveJob ID to query the store for
33
33
  # @return returns the stored data, could be any serializable object
34
34
  #
35
- def self.store(job_id:)
35
+ def self.store(job_id)
36
36
  status = JobStatus.store.fetch(job_id)
37
37
  status ? status[:store] : nil
38
38
  end
@@ -43,18 +43,28 @@ module JobStatus
43
43
  # @param job_id [String] ActiveJob ID to query the store for
44
44
  # @return [Integer] total Returns total used for the percentage
45
45
  #
46
- def self.total(job_id:)
46
+ def self.total(job_id)
47
47
  status = JobStatus.store.fetch(job_id)
48
48
  status ? status[:total] : nil
49
49
  end
50
50
 
51
+ def self.percentage(job_id)
52
+ status = JobStatus.store.fetch(job_id)
53
+ percent = nil
54
+ puts status
55
+ if status
56
+ percent = 100.0 / (status[:total].to_f / status[:at])
57
+ end
58
+ return percent
59
+ end
60
+
51
61
  #
52
62
  # Get the All Data from the store
53
63
  #
54
64
  # @param job_id [String] ActiveJob ID to query the store for
55
65
  # @return returns all information held in the store for the job_id
56
66
  #
57
- def self.get_all(job_id:)
67
+ def self.get_all(job_id)
58
68
  status = JobStatus.store.fetch(job_id)
59
69
  status ? status : nil
60
70
  end
@@ -12,11 +12,11 @@ module JobStatus
12
12
  def self.included(base)
13
13
  base.extend ClassMethods
14
14
  base.class_eval do
15
- before_enqueue { JobStatus::Tracker.enqueue(job_id: @job_id) }
15
+ before_enqueue { JobStatus::Tracker.enqueue(@job_id) }
16
16
 
17
- before_perform { JobStatus::Tracker.update(job_id: @job_id, status: :working ) }
17
+ before_perform { JobStatus::Tracker.update(@job_id, :working ) }
18
18
 
19
- after_perform { JobStatus::Tracker.update(job_id: @job_id, status: :completed ) }
19
+ after_perform { JobStatus::Tracker.update(@job_id, :completed ) }
20
20
  end
21
21
  end
22
22
 
@@ -26,7 +26,7 @@ module JobStatus
26
26
  # @param job_id [String] ActiveJob job_id to attach information to in storage
27
27
  # @param at [Integer] Value to store for the current position
28
28
  #
29
- def at(job_id:, at:)
29
+ def at(job_id, at)
30
30
  storage(job_id, :at, at)
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ module JobStatus
36
36
  # @param job_id [String] ActiveJob job_id to attach information to in storage
37
37
  # @param total [Integer] Value to store for the total positions
38
38
  #
39
- def total(job_id:, total:)
39
+ def total(job_id, total)
40
40
  storage(job_id, :total, total)
41
41
  end
42
42
 
@@ -46,7 +46,7 @@ module JobStatus
46
46
  # @param job_id [String] ActiveJob job_id to attach information to in storage
47
47
  # @param store [Object] Data to be save within the storage, can be any serializable object
48
48
  #
49
- def store(job_id:, store:)
49
+ def store(job_id, store)
50
50
  storage(job_id, :store, store)
51
51
  end
52
52
 
@@ -8,7 +8,7 @@ module JobStatus
8
8
  #
9
9
  # @param job_id [String] ActiveJob ID to use as the key in storage
10
10
  #
11
- def self.enqueue(job_id:)
11
+ def self.enqueue(job_id)
12
12
  JobStatus.store.write(job_id, {status: :queued, at: 0, total: 100}, expires_in: 259200)
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ module JobStatus
17
17
  #
18
18
  # @param job_id [String] ActiveJob ID to use as the key in storage
19
19
  #
20
- def self.update(job_id:, status:)
20
+ def self.update(job_id, status)
21
21
  cache = JobStatus.store.fetch(job_id)
22
22
  cache[:status] = status
23
23
  JobStatus.store.write(job_id, cache)
@@ -28,7 +28,7 @@ module JobStatus
28
28
  #
29
29
  # @param job_id [String] ActiveJob ID to use as the key in storage
30
30
  #
31
- def self.remove(job_id:)
31
+ def self.remove(job_id)
32
32
  JobStatus.store.delete(job_id)
33
33
  end
34
34
  end
@@ -3,5 +3,5 @@
3
3
  #
4
4
  module JobStatus
5
5
  # Version Number
6
- VERSION = "0.1.2"
6
+ VERSION = "0.5.2"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job_status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Kapp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob