activeduty 0.1.1 → 0.1.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 +4 -4
- data/README.md +14 -0
- data/lib/active_duty/base.rb +5 -1
- data/lib/active_duty/boots.rb +30 -0
- data/lib/active_duty/reported.rb +22 -0
- data/lib/active_duty/run.rb +6 -1
- data/lib/active_duty/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3395a114d81d8b544c2a3eb42fede4be0e0caae624307d8c6b89b06ec67e62
|
4
|
+
data.tar.gz: 633d72254a97a7802d57fd96fc3e784bf156c5947594767ea0c7e3839e328fda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eb4a5e4b61b42e12011811503479ba58a2a58b2fa18f420a2b373662977dfa2368012a10982f6417c7e7c92e153cc1d0bd3a1e86c315b23590135535a9b1ec5
|
7
|
+
data.tar.gz: d916e5ba265a0dec04ceb7094c0288775a37fe2cde7dd38290563752a9de4345a26085fc1e5c23adb7cba5917456461520560bccb608650c0d78f5381269e9a8
|
data/README.md
CHANGED
@@ -155,3 +155,17 @@ end
|
|
155
155
|
### Failing
|
156
156
|
|
157
157
|
Need to fail? Call `fail!`
|
158
|
+
|
159
|
+
### Sequential calls
|
160
|
+
|
161
|
+
Want to run service after service?
|
162
|
+
|
163
|
+
```
|
164
|
+
class ServiceTwo < ActiveDuty::Base; end
|
165
|
+
class ServiceThree < ActiveDuty::Base; end
|
166
|
+
class ServiceOne < ActiveDuty::Base
|
167
|
+
boots ServiceTwo, ServiceThree
|
168
|
+
end
|
169
|
+
```
|
170
|
+
|
171
|
+
They won't take arguments at this time.
|
data/lib/active_duty/base.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'active_duty/initializers'
|
2
2
|
require 'active_duty/run'
|
3
|
+
require 'active_duty/boots'
|
4
|
+
require 'active_duty/reported'
|
3
5
|
require 'active_duty/fail'
|
4
6
|
require 'active_duty/success'
|
5
7
|
require 'active_duty/callbacks'
|
@@ -15,8 +17,10 @@ module ActiveDuty
|
|
15
17
|
include Fail
|
16
18
|
include Initializers
|
17
19
|
include Rollback
|
18
|
-
include
|
20
|
+
include Boots
|
19
21
|
include Success
|
22
|
+
include Reported
|
23
|
+
include Run
|
20
24
|
|
21
25
|
class << self
|
22
26
|
alias_method :__new, :new
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ActiveDuty
|
2
|
+
module Boots
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
self.class.attr_accessor :_boots
|
7
|
+
end
|
8
|
+
def deploy_troops!
|
9
|
+
boots.each do |boot|
|
10
|
+
klass = boot[:class_name].constantize
|
11
|
+
boot = klass.new(*boot[:options][:args]).call
|
12
|
+
called!(boot)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def boots
|
17
|
+
Array(self.class._boots)
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def boots(*args)
|
22
|
+
@_boots ||= []
|
23
|
+
options = args.extract_options!
|
24
|
+
args.each do |boot|
|
25
|
+
_boots << { class_name: boot.to_s, options: options }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActiveDuty
|
2
|
+
module Reported
|
3
|
+
protected
|
4
|
+
|
5
|
+
def called!(klass)
|
6
|
+
klass._called = true
|
7
|
+
called << klass.class.name
|
8
|
+
end
|
9
|
+
|
10
|
+
def called
|
11
|
+
@called ||= []
|
12
|
+
end
|
13
|
+
|
14
|
+
def called?
|
15
|
+
@_called
|
16
|
+
end
|
17
|
+
|
18
|
+
def _called=(value)
|
19
|
+
@_called = value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/active_duty/run.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module ActiveDuty
|
2
2
|
module Run
|
3
3
|
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def run; end
|
6
|
+
|
4
7
|
def call(*args)
|
5
|
-
begin
|
8
|
+
begin
|
6
9
|
call!(*args)
|
7
10
|
rescue => error
|
8
11
|
rollback!
|
@@ -17,6 +20,8 @@ module ActiveDuty
|
|
17
20
|
|
18
21
|
def call!(*args)
|
19
22
|
run(*args)
|
23
|
+
called!(self)
|
24
|
+
deploy_troops!
|
20
25
|
self
|
21
26
|
end
|
22
27
|
|
data/lib/active_duty/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeduty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Brody
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- README.md
|
91
91
|
- lib/active_duty.rb
|
92
92
|
- lib/active_duty/base.rb
|
93
|
+
- lib/active_duty/boots.rb
|
93
94
|
- lib/active_duty/call_async.rb
|
94
95
|
- lib/active_duty/callbacks.rb
|
95
96
|
- lib/active_duty/context.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- lib/active_duty/fail.rb
|
98
99
|
- lib/active_duty/initializers.rb
|
99
100
|
- lib/active_duty/job.rb
|
101
|
+
- lib/active_duty/reported.rb
|
100
102
|
- lib/active_duty/rollback.rb
|
101
103
|
- lib/active_duty/run.rb
|
102
104
|
- lib/active_duty/success.rb
|