allq 0.2.6 → 0.2.7

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: 5cb3d940d62e6d79755efc8fa9741b075fdba20e
4
- data.tar.gz: d49aa751daaff07c60be6a1eb4089142a07471b6
3
+ metadata.gz: 4734e699bb46e5673f0ebbd2767395b3cb6bb486
4
+ data.tar.gz: 6e203ba2a656726e5e12690a900cee4995512c6e
5
5
  SHA512:
6
- metadata.gz: 3b65e58efb78d81d2a5a433142fe1b7f43b75ee992b0947c2252cbd1ada29be5be4db977f9659401959d72df72fb20e54668ee61d554838e7655c3bff20acb85
7
- data.tar.gz: 6f165465a5205cc565edeee63c1732e02e26c6d6e2cf47c64438d5fa9e67f1f781367393fd1d1d8ef1ec28fbd3ac7a41d704bff1caacf0111a25b1116069f4c3
6
+ metadata.gz: c0272f731ea498ca15f3a7dc3ad3a0c45fadca88dc5683572f4e0ab8c904c081a525630c5d3e08e95ef6ded91892fa722ac4be11e6b7b7a3c1060fdf76c2078d
7
+ data.tar.gz: 055dc4c1af3431d540aee4e54d281f2e2d15fc1f1e3bb8d0c2c4c03e0eccc3a59d4a16951ef6f4f0fe5ed021494af72e7d806cd8b51c68129347ae8b1a1c6e8c
@@ -3,9 +3,11 @@ require 'json'
3
3
  class AllQ
4
4
  # Base class for handling allq actions
5
5
  class Base
6
+ attr_reader :connection, :client
6
7
 
7
- def initialize(connection)
8
+ def initialize(connection, client)
8
9
  @connection = connection
10
+ @client = client
9
11
  setup
10
12
  end
11
13
 
@@ -34,7 +36,7 @@ class AllQ
34
36
  job_info = result_hash["job"]
35
37
  job_id = job_info["job_id"]
36
38
 
37
- job = Job.new(job_id)
39
+ job = Job.new(job_id, @client)
38
40
  # -- Optional fields
39
41
  job.body = job_info["body"] if job_info["body"]
40
42
  job.expireds = job_info["expireds"] if job_info["expireds"]
@@ -7,7 +7,7 @@ class AllQ
7
7
  result = JSON.parse(data)
8
8
  if result['job']
9
9
  return nil if result['job'].empty?
10
- job = Job.new_from_hash(result['job'])
10
+ job = Job.new_from_hash(result['job'], @client)
11
11
  return job
12
12
  end
13
13
  nil
@@ -17,7 +17,7 @@ class AllQ
17
17
  result = JSON.parse(data)
18
18
  if result['job']
19
19
  return nil if result['job'].empty?
20
- job = Job.new_from_hash(result['job'])
20
+ job = Job.new_from_hash(result['job'], @client)
21
21
  return job
22
22
  end
23
23
  nil
@@ -9,18 +9,18 @@ class AllQ
9
9
  url = URL if url.nil?
10
10
 
11
11
  @connection = AllQ::Connection.new(url)
12
- @get_action = AllQ::Get.new(@connection)
13
- @put_action = AllQ::Put.new(@connection)
14
- @done_action = AllQ::Done.new(@connection)
15
- @stats_action = AllQ::Stats.new(@connection)
16
- @release_action = AllQ::Release.new(@connection)
17
- @touch_action = AllQ::Touch.new(@connection)
18
- @kick_action = AllQ::Kick.new(@connection)
19
- @bury_action = AllQ::Bury.new(@connection)
20
- @clear_action = AllQ::Clear.new(@connection)
21
- @peek_action = AllQ::Peek.new(@connection)
22
- @delete_action = AllQ::Delete.new(@connection)
23
- @parent_job_action = AllQ::ParentJob.new(@connection)
12
+ @get_action = AllQ::Get.new(@connection, self)
13
+ @put_action = AllQ::Put.new(@connection, self)
14
+ @done_action = AllQ::Done.new(@connection, self)
15
+ @stats_action = AllQ::Stats.new(@connection, self)
16
+ @release_action = AllQ::Release.new(@connection, self)
17
+ @touch_action = AllQ::Touch.new(@connection, self)
18
+ @kick_action = AllQ::Kick.new(@connection, self)
19
+ @bury_action = AllQ::Bury.new(@connection, self)
20
+ @clear_action = AllQ::Clear.new(@connection, self)
21
+ @peek_action = AllQ::Peek.new(@connection, self)
22
+ @delete_action = AllQ::Delete.new(@connection, self)
23
+ @parent_job_action = AllQ::ParentJob.new(@connection, self)
24
24
  end
25
25
 
26
26
  def parent_job(tube, body, ttl: 3600, delay: 0, parent_id: nil, priority: 5, limit: nil, noop: false)
@@ -1,13 +1,14 @@
1
1
  class AllQ
2
2
 
3
3
  class Job
4
- attr_accessor :id, :body, :expireds, :releases
5
- def initialize(id, tube = nil, body = nil, expireds = nil, releases = nil)
4
+ attr_accessor :id, :body, :expireds, :releases, :client
5
+ def initialize(id, client, tube = nil, body = nil, expireds = nil, releases = nil)
6
6
  @body = body
7
7
  @id = id
8
8
  @tube = tube
9
9
  @expireds = expireds
10
10
  @releases = releases
11
+ @client = client
11
12
  end
12
13
 
13
14
  def to_hash
@@ -21,23 +22,23 @@ class AllQ
21
22
  end
22
23
 
23
24
  def done
24
- AllQ::Client.instance.done(self)
25
+ @client.done(self)
25
26
  end
26
27
 
27
28
  def delete
28
- AllQ::Client.instance.delete(self)
29
+ @client.delete(self)
29
30
  end
30
31
 
31
32
  def touch
32
- AllQ::Client.instance.touch(self)
33
+ @client.touch(self)
33
34
  end
34
35
 
35
36
  def release(delay = 0)
36
- AllQ::Client.instance.release(self, delay)
37
+ @client.release(self, delay)
37
38
  end
38
39
 
39
40
  def bury
40
- AllQ::Client.instance.bury(self)
41
+ @client.bury(self)
41
42
  end
42
43
 
43
44
  def to_json
@@ -58,14 +59,14 @@ class AllQ
58
59
  }
59
60
  end
60
61
 
61
- def self.new_from_hash(hash)
62
+ def self.new_from_hash(hash, client)
62
63
  begin
63
64
  id = hash.fetch('job_id')
64
65
  body = hash.fetch('body')
65
66
  tube = hash.fetch('tube')
66
67
  expireds = hash.fetch('expireds')
67
68
  releases = hash.fetch('releases')
68
- job = Job.new(id, tube, body, expireds, releases)
69
+ job = Job.new(id, client, tube, body, expireds, releases)
69
70
  return job
70
71
  rescue => ex
71
72
  puts "Server value: #{hash}"
@@ -1,3 +1,3 @@
1
1
  module Allq
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason