employer 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -85,6 +85,10 @@ class CustomPipelineBackend
85
85
  def dequeue
86
86
  end
87
87
 
88
+ # clear must clear the backend of all its jobs
89
+ def clear
90
+ end
91
+
88
92
  # complete accepts a Job object, using its id the pipeline backend should
89
93
  # mark the job as complete
90
94
  def complete(job)
@@ -28,6 +28,17 @@ module Employer
28
28
  workshop.run
29
29
  end
30
30
 
31
+ desc "clear", "Clear jobs"
32
+ option :config, default: "config/employer.rb", desc: "Config file to use"
33
+ def clear
34
+ unless File.exists?(options[:config])
35
+ STDERR.puts "#{options[:config]} does not exist."
36
+ exit 1
37
+ end
38
+
39
+ Employer::Workshop.pipeline(options[:config]).clear
40
+ end
41
+
31
42
  desc "config", "Generate config file"
32
43
  option :config, default: "config/employer.rb", desc: "Path to config file"
33
44
  def config
@@ -24,6 +24,11 @@ module Employer
24
24
  end
25
25
  end
26
26
 
27
+ def clear
28
+ raise Employer::Errors::PipelineBackendRequired if backend.nil?
29
+ backend.clear
30
+ end
31
+
27
32
  def complete(job)
28
33
  raise Employer::Errors::PipelineBackendRequired if backend.nil?
29
34
  backend.complete(job)
@@ -1,3 +1,3 @@
1
1
  module Employer
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -54,6 +54,18 @@ describe Employer::Pipeline do
54
54
  end
55
55
  end
56
56
 
57
+ describe "#clear" do
58
+ it "clears all jobs using its backend" do
59
+ backend.should_receive(:clear)
60
+ pipeline.backend = backend
61
+ pipeline.clear
62
+ end
63
+
64
+ it "fails when no backend is set" do
65
+ expect { pipeline.clear }.to raise_error(Employer::Errors::PipelineBackendRequired)
66
+ end
67
+ end
68
+
57
69
  describe "#complete" do
58
70
  it "completes job using its backend" do
59
71
  backend.should_receive(:complete).with(job)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: employer
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: