lite-command 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +2 -2
- data/lib/lite/command/internals/calls.rb +13 -10
- data/lib/lite/command/internals/executions.rb +20 -5
- data/lib/lite/command/internals/faults.rb +3 -1
- data/lib/lite/command/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eb09ff348ac355723d82848c69c1673d7ffa2782b3bb0061b16ccbe205b9529
|
4
|
+
data.tar.gz: 514ffc0ce29de277bd0969c29a51884d2509fd46b69e5cc6f85ded44fba4e827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00d47aa6fc59fa96895311bd78be8dcf3b283da16197f6973eb5db4100b61ef6303ab65673b695dfd51cfbc64ae63eca9b70adc0eba46763a25597fa1c1e6ba0
|
7
|
+
data.tar.gz: 2e60eaa36e8b86cec861bc67bfa3bee12292c8edf8c92503e4339128f69f467421f94a4b53ee1a8a96a467cb25617cb6918d553419bbb6b1fbd23c817b2227dd
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [3.1.2] - 2024-10-26
|
10
|
+
### Changed
|
11
|
+
- Make state set methods private
|
12
|
+
- Add returns for invalid state and status transitions
|
13
|
+
|
9
14
|
## [3.1.1] - 2024-10-25
|
10
15
|
### Changed
|
11
16
|
- Add option to raise original or fault exception
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-command (3.1.
|
4
|
+
lite-command (3.1.2)
|
5
5
|
activemodel
|
6
6
|
ostruct
|
7
7
|
|
@@ -136,7 +136,7 @@ GEM
|
|
136
136
|
rubocop-ast (>= 1.31.1, < 2.0)
|
137
137
|
rubocop-rake (0.6.0)
|
138
138
|
rubocop (~> 1.0)
|
139
|
-
rubocop-rspec (3.
|
139
|
+
rubocop-rspec (3.2.0)
|
140
140
|
rubocop (~> 1.61)
|
141
141
|
ruby-progressbar (1.13.0)
|
142
142
|
securerandom (0.3.1)
|
@@ -59,7 +59,7 @@ module Lite
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def bad?(reason = nil)
|
62
|
-
!
|
62
|
+
!ok?(reason)
|
63
63
|
end
|
64
64
|
|
65
65
|
FAULTS.each do |f|
|
@@ -75,22 +75,25 @@ module Lite
|
|
75
75
|
str.nil? || str == reason
|
76
76
|
end
|
77
77
|
|
78
|
-
def fault(object,
|
79
|
-
|
80
|
-
@metadata = metadata
|
78
|
+
def fault(object, s, m) # rubocop:disable Naming/MethodParameterName
|
79
|
+
return if s == SUCCESS || status != SUCCESS
|
81
80
|
|
82
|
-
|
83
|
-
@
|
84
|
-
@metadata ||= down_stream.metadata
|
85
|
-
@caused_by ||= down_stream.caused_by
|
86
|
-
@thrown_by ||= down_stream.thrown_by
|
81
|
+
@status = s
|
82
|
+
@metadata = m
|
87
83
|
|
88
|
-
|
84
|
+
fault_streamer = Lite::Command::FaultStreamer.new(self, object)
|
85
|
+
@reason ||= fault_streamer.reason
|
86
|
+
@metadata ||= fault_streamer.metadata
|
87
|
+
@caused_by ||= fault_streamer.caused_by
|
88
|
+
@thrown_by ||= fault_streamer.thrown_by
|
89
|
+
@fault_exception ||= fault_streamer.fault_exception
|
89
90
|
end
|
90
91
|
|
91
92
|
FAULTS.each do |f|
|
92
93
|
# eg: invalid!("idk") or failure!(fault) or error!("idk", { error_key: "some.error" })
|
93
94
|
define_method(:"#{f}!") do |object, metadata = nil|
|
95
|
+
return unless success?
|
96
|
+
|
94
97
|
fault(object, f, metadata)
|
95
98
|
raise(fault_exception)
|
96
99
|
end
|
@@ -24,13 +24,28 @@ module Lite
|
|
24
24
|
STATES.each do |s|
|
25
25
|
# eg: executing?
|
26
26
|
define_method(:"#{s}?") { state == s }
|
27
|
-
|
28
|
-
# eg: interrupted!
|
29
|
-
define_method(:"#{s}!") { @state = s }
|
30
27
|
end
|
31
28
|
|
32
29
|
private
|
33
30
|
|
31
|
+
def executing!
|
32
|
+
return unless pending?
|
33
|
+
|
34
|
+
@state = EXECUTING
|
35
|
+
end
|
36
|
+
|
37
|
+
def complete!
|
38
|
+
return if executed?
|
39
|
+
|
40
|
+
@state = COMPLETE
|
41
|
+
end
|
42
|
+
|
43
|
+
def interrupted!
|
44
|
+
return if executed?
|
45
|
+
|
46
|
+
@state = INTERRUPTED
|
47
|
+
end
|
48
|
+
|
34
49
|
def before_execution
|
35
50
|
increment_execution_index
|
36
51
|
assign_execution_cmd_id
|
@@ -61,7 +76,7 @@ module Lite
|
|
61
76
|
Utils.try(self, :on_success)
|
62
77
|
rescue StandardError => e
|
63
78
|
@original_exception = e
|
64
|
-
fault(e, ERROR, metadata)
|
79
|
+
fault(e, ERROR, metadata)
|
65
80
|
after_execution
|
66
81
|
Utils.try(self, :"on_#{status}", e)
|
67
82
|
ensure
|
@@ -73,7 +88,7 @@ module Lite
|
|
73
88
|
Utils.try(self, :on_success)
|
74
89
|
rescue StandardError => e
|
75
90
|
@original_exception = e
|
76
|
-
fault(e, ERROR, metadata)
|
91
|
+
fault(e, ERROR, metadata)
|
77
92
|
after_execution
|
78
93
|
Utils.try(self, :"on_#{status}", e)
|
79
94
|
raise(e)
|
data/lib/lite/command/version.rb
CHANGED