disc 0.0.24 → 0.0.25

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: fe07d8d776e3658f1ce638b9e2bdbe95efd516bc
4
- data.tar.gz: ef1a6ebf0fc055d8239a4133904d572fb0c48db6
3
+ metadata.gz: e1620d0f0752ee08feff06a19d5e83c23afbce91
4
+ data.tar.gz: dbaa723df114c6dead5260ec688c0cb144d60946
5
5
  SHA512:
6
- metadata.gz: db1e642b0f8f685214d6bb767ff175bcb9113dbeb52f04457f54bd2f1173e581f7c17cdfae1a1310929305a150275279edba722d90e41c2d0399437f4ec4391f
7
- data.tar.gz: 91a52222b2f6d68601f2911d80df230cf8722c892a41171b6c31dba8d711d2092ae39f9aeda66dd18086181f5fbbf71dc0a230c2fbfa6bc7f4b2e8f24beaa6b6
6
+ metadata.gz: da67f0364f6e4c0fab1289d94e0053f539c1d784981821e937315fc91f0e24893fdfdcadc37dbab15c1ac47f18695bde6f7eb17a21074af224e174f48490116a
7
+ data.tar.gz: b27a52e29cfe6017d6adeac0b125cbe4f0c9c555b4d7057e8c67e4234774325186ebdca1f84eab6415050fa2776f9dc0277336f8718e305de32876133d3cd7a3
data/.travis.yml CHANGED
@@ -14,8 +14,6 @@ install:
14
14
  - export GEM_HOME=$PWD/gems/$RUBY_VERSION
15
15
  - export GEM_PATH=$GEM_HOME:$GEM_PATH
16
16
  - export PATH=$GEM_HOME/bin:$PWD/disque/src:$PATH
17
- - mkdir -p $GEM_HOME
18
- - which dep || gem install dep
19
- - dep install
17
+ - cat .gems* | xargs gem install
20
18
  before_script: disque-server --daemonize yes
21
19
  script: make test
data/bin/disc CHANGED
@@ -1,14 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'disc'
4
- require 'clap'
5
-
6
3
  if ARGV.empty?
7
4
  $stdout.puts('Usage: disc -r FILE')
8
5
 
9
6
  exit(1)
10
7
  end
11
8
 
9
+ stop = proc do
10
+ if defined?(Disc)
11
+ Disc::Worker.stop
12
+ else
13
+ exit 0
14
+ end
15
+ end
16
+
17
+ trap(:INT, &stop)
18
+ trap(:TERM, &stop)
19
+
20
+ require 'clap'
21
+ require_relative '../lib/disc'
22
+
12
23
  Clap.run ARGV,
13
24
  "-r" => lambda { |file| require file }
14
25
 
@@ -0,0 +1,9 @@
1
+ module Disc::Job::ClassMethods
2
+ def mocked_queue
3
+ @_mocked_queue ||= []
4
+ end
5
+
6
+ def enqueue(args = [], at: nil, queue: nil, **options)
7
+ mocked_queue << { args: args, at: at, options: options }
8
+ end
9
+ end
data/lib/disc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Disc
2
- VERSION = "0.0.24"
2
+ VERSION = "0.0.25"
3
3
  end
data/lib/disc.rb CHANGED
@@ -46,8 +46,16 @@ class Disc
46
46
  :timeout,
47
47
  :count
48
48
 
49
+ def self.current
50
+ @current ||= new
51
+ end
52
+
49
53
  def self.run
50
- new.run
54
+ current.run
55
+ end
56
+
57
+ def self.stop
58
+ current.stop
51
59
  end
52
60
 
53
61
  def initialize(options = {})
@@ -73,6 +81,10 @@ class Disc
73
81
  self
74
82
  end
75
83
 
84
+ def stop
85
+ @stop = true
86
+ end
87
+
76
88
  def run
77
89
  $stdout.puts("Disc::Worker listening in #{queues}")
78
90
  loop do
@@ -87,7 +99,11 @@ class Disc
87
99
  Disc.on_error(err, job.update('id' => msgid, 'queue' => queue))
88
100
  end
89
101
  end
102
+
103
+ break if @stop
90
104
  end
105
+ ensure
106
+ disque.quit
91
107
  end
92
108
  end
93
109
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - pote
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disque
@@ -83,6 +83,7 @@ files:
83
83
  - examples/greeter.rb
84
84
  - lib/active_job/queue_adapters/disc_adapter.rb
85
85
  - lib/disc.rb
86
+ - lib/disc/testing.rb
86
87
  - lib/disc/version.rb
87
88
  - test/disc_test.rb
88
89
  homepage: https://github.com/pote/disc