active_job_status 0.0.3 → 0.0.4

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: 0f5b9c6307f29a9c2f63d672cb9e3df1ebc8803e
4
- data.tar.gz: 400d59fc1f9d4b8d850f43e3e1faf7a356784242
3
+ metadata.gz: 4ea8bac2bfeb93d6844f4771f4bf9706735831ce
4
+ data.tar.gz: 176590db71f11445b8fc2a82b9b2ff53af8fc65e
5
5
  SHA512:
6
- metadata.gz: ebde3b55fb024aa7663618ae10602e174ff548edb8917aa20af92ebd933147fb9faca42612556b727aa95f050e194c0db57f6732a5d7a7124db4fa21690cd721
7
- data.tar.gz: 65b0f469ebb6c015cb5f7683e28b9c55fab8cdcc2fc1ffa1f0da70e84b34e5f6315c8e04118d995267623aac38845141a949e31260b9a7e7059c23926f0fefea
6
+ metadata.gz: 8baecc6e6ab0a989125c51c35aa1c17fd0a4de621b1263e7b2bf8f5f8e03b5717732e3745878c72c8b1380990ab1f29e8fb0197d40e75cb5f9861c08fba2b952
7
+ data.tar.gz: e3a0a23cc6dd05e7c2be3175f521c4d71abe39e3f182577e55089d0801c5c61e11c9574c882e54d65f0aa8ec4727b979517a1bac5e2698ce5df7437174516273
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # ActiveJobStatus
2
+
3
+ ## 0.0.4
4
+ - Change name of JobStatus::get_status argument batch_key to be batch_id
5
+ - Add changelog
data/README.md CHANGED
@@ -50,14 +50,14 @@ exists, its jobs will be overwritten with the supplied list.
50
50
 
51
51
  my_key = "230923asdlkj230923"
52
52
  my_jobs = [my_first_job.job_id, my_second_job.job_id]
53
- my_batch = ActiveJobStatus::JobBatch.new(batch_key: my_key, job_ids: my_jobs)
53
+ my_batch = ActiveJobStatus::JobBatch.new(batch_id: my_key, job_ids: my_jobs)
54
54
 
55
55
  Batches expire after 72 hours (259200 seconds).
56
56
  You can change that by passing the initalizer an integer value (in seconds).
57
57
 
58
58
  my_key = "230923asdlkj230923"
59
59
  my_jobs = [my_first_job.job_id, my_second_job.job_id]
60
- my_batch = ActiveJobStatus::JobBatch.new(batch_key: my_key,
60
+ my_batch = ActiveJobStatus::JobBatch.new(batch_id: my_key,
61
61
  job_ids: my_jobs,
62
62
  expire_in: 500000)
63
63
 
@@ -73,7 +73,7 @@ And you can ask the batch if all the jobs are completed or not.
73
73
 
74
74
  You can ask the batch for other bits of information.
75
75
 
76
- batch.batch_key
76
+ batch.batch_id
77
77
  # => "230923asdlkj230923"
78
78
  batch.job_ids
79
79
  # => ["b67af7a0-3ed2-4661-a2d5-ff6b6a254886", "6c0216b9-ea0c-4ee9-a3b2-501faa919a66"]
@@ -1,22 +1,22 @@
1
1
  module ActiveJobStatus
2
2
  class JobBatch
3
3
 
4
- attr_reader :batch_key
4
+ attr_reader :batch_id
5
5
  attr_reader :job_ids
6
6
  attr_reader :expire_in
7
7
 
8
- def initialize(batch_key:, job_ids:, expire_in: 259200)
9
- @batch_key = batch_key
8
+ def initialize(batch_id:, job_ids:, expire_in: 259200)
9
+ @batch_id = batch_id
10
10
  @job_ids = job_ids
11
11
  @expire_in = expire_in
12
- ActiveJobStatus.redis.del(@batch_key) # delete any old batches
13
- ActiveJobStatus.redis.sadd(@batch_key, @job_ids)
14
- ActiveJobStatus.redis.expire(@batch_key, @expire_in)
12
+ ActiveJobStatus.redis.del(@batch_id) # delete any old batches
13
+ ActiveJobStatus.redis.sadd(@batch_id, @job_ids)
14
+ ActiveJobStatus.redis.expire(@batch_id, @expire_in)
15
15
  end
16
16
 
17
17
  def add_jobs(job_ids:)
18
18
  @job_ids = @job_ids + job_ids
19
- ActiveJobStatus.redis.sadd(@batch_key, job_ids)
19
+ ActiveJobStatus.redis.sadd(@batch_id, job_ids)
20
20
  end
21
21
 
22
22
  def completed?
@@ -27,8 +27,8 @@ module ActiveJobStatus
27
27
  !job_statuses.any?
28
28
  end
29
29
 
30
- def self.find(batch_key:)
31
- ActiveJobStatus.redis.smembers(batch_key)
30
+ def self.find(batch_id:)
31
+ ActiveJobStatus.redis.smembers(batch_id)
32
32
  end
33
33
  end
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveJobStatus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe ActiveJobStatus::JobBatch do
4
4
 
5
- let!(:batch_key) { Time.now }
5
+ let!(:batch_id) { Time.now }
6
6
 
7
7
  let!(:redis) { ActiveJobStatus.redis }
8
8
 
@@ -15,7 +15,7 @@ describe ActiveJobStatus::JobBatch do
15
15
  let!(:addl_jobs) { [job3.job_id, job4.job_id] }
16
16
  let!(:total_jobs) { first_jobs + addl_jobs }
17
17
 
18
- let!(:batch) { ActiveJobStatus::JobBatch.new(batch_key: batch_key,
18
+ let!(:batch) { ActiveJobStatus::JobBatch.new(batch_id: batch_id,
19
19
  job_ids: first_jobs) }
20
20
 
21
21
  describe "#initialize" do
@@ -24,7 +24,7 @@ describe ActiveJobStatus::JobBatch do
24
24
  end
25
25
  it "should create a redis set" do
26
26
  first_jobs.each do |job_id|
27
- expect(redis.smembers(batch_key)).to include job_id
27
+ expect(redis.smembers(batch_id)).to include job_id
28
28
  end
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ describe ActiveJobStatus::JobBatch do
33
33
  it "should add jobs to the set" do
34
34
  batch.add_jobs(job_ids: addl_jobs)
35
35
  total_jobs.each do |job_id|
36
- expect(ActiveJobStatus::JobBatch.find(batch_key: batch_key)).to \
36
+ expect(ActiveJobStatus::JobBatch.find(batch_id: batch_id)).to \
37
37
  include job_id
38
38
  end
39
39
  end
@@ -56,31 +56,31 @@ describe ActiveJobStatus::JobBatch do
56
56
 
57
57
  describe "::find" do
58
58
  it "should return an array of jobs when a batch exists" do
59
- expect(ActiveJobStatus::JobBatch.find(batch_key: batch_key)).to \
59
+ expect(ActiveJobStatus::JobBatch.find(batch_id: batch_id)).to \
60
60
  be_an_instance_of Array
61
61
  end
62
62
  it "should return the correct jobs" do
63
- expect(ActiveJobStatus::JobBatch.find(batch_key: batch_key)).to \
63
+ expect(ActiveJobStatus::JobBatch.find(batch_id: batch_id)).to \
64
64
  eq first_jobs
65
65
  end
66
66
  it "should return nil when no batch exists" do
67
- expect(ActiveJobStatus::JobBatch.find(batch_key: "45")).to eq []
67
+ expect(ActiveJobStatus::JobBatch.find(batch_id: "45")).to eq []
68
68
  end
69
69
  end
70
70
 
71
71
  describe "expiring job" do
72
72
  it "should allow the expiration time to be set in seconds" do
73
- expect(ActiveJobStatus::JobBatch.new(batch_key: "newkey",
73
+ expect(ActiveJobStatus::JobBatch.new(batch_id: "newkey",
74
74
  job_ids: first_jobs,
75
75
  expire_in: 200000)).to \
76
76
  be_an_instance_of ActiveJobStatus::JobBatch
77
77
  end
78
78
  it "should expire" do
79
- ActiveJobStatus::JobBatch.new(batch_key: "expiry",
79
+ ActiveJobStatus::JobBatch.new(batch_id: "expiry",
80
80
  job_ids: first_jobs,
81
81
  expire_in: 1)
82
82
  sleep 2
83
- expect(ActiveJobStatus::JobBatch.find(batch_key: "expiry")).to be_empty
83
+ expect(ActiveJobStatus::JobBatch.find(batch_id: "expiry")).to be_empty
84
84
 
85
85
  end
86
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_job_status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
120
  - ".travis.yml"
121
+ - CHANGELOG.md
121
122
  - Gemfile
122
123
  - LICENSE.txt
123
124
  - README.md