sequel-state-machine 1.2.2 → 1.4.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5f7df6f4992d44e4fe205af0b2f52e510738ab27ca5e8b281908b095ccf2a96
|
4
|
+
data.tar.gz: ea9d6726c70aef22d907dbba0dd8e7dec1cc7cced63e0c425df997ed01312f64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b338921fe0d5784d5d3f397539ca806cf929be159727dae311c0ad61123b4997809ec15fe1e7586c7e8851894b1d35deda749f6f7fb6afba32f4b1da1e62266e
|
7
|
+
data.tar.gz: d6d58511606654d184e4cb9562ffc4a2d3ed7d8a6eab7c4607ed23ca8401a0bfef1499d3d372cf89983d5659d62c512f619119c024170450d7ec80dd11737e9c
|
@@ -83,6 +83,16 @@ module Sequel
|
|
83
83
|
return alog
|
84
84
|
end
|
85
85
|
|
86
|
+
# Commit pending changes to the audit log.
|
87
|
+
# This involves either:
|
88
|
+
# - Updating the last audit log step, if it matches our current criteria (event, from state, to state),
|
89
|
+
# - or creating a new audit log entry.
|
90
|
+
# This ensures that we have the following behavior:
|
91
|
+
# - Failed transitions - ie where from and to state are the same - do not add multiple audit log steps.
|
92
|
+
# Only the latest failed transition is recorded.
|
93
|
+
# - Successful transitions are always recorded. If we transition, a->b->c,
|
94
|
+
# and then reset the state machine to 'a' and transition a->b->c again,
|
95
|
+
# we'd end up with 5 transitions (a->b->c->a->b->c).
|
86
96
|
def commit_audit_log(transition)
|
87
97
|
machine = self.class.state_machines.length > 1 ? transition.machine.name : nil
|
88
98
|
StateMachines::Sequel.log(
|
@@ -90,19 +100,20 @@ module Sequel
|
|
90
100
|
)
|
91
101
|
current = self.current_audit_log(machine: machine)
|
92
102
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
if
|
99
|
-
StateMachines::Sequel.log(self, :debug, "updating_audit_log", {audit_log_id:
|
100
|
-
|
103
|
+
last_log = self.audit_logs.last
|
104
|
+
can_update_last = last_log &&
|
105
|
+
last_log.sequel_state_machine_get(:event) == transition.event.to_s &&
|
106
|
+
last_log.sequel_state_machine_get(:from_state) == transition.from &&
|
107
|
+
last_log.sequel_state_machine_get(:to_state) == transition.to
|
108
|
+
if can_update_last
|
109
|
+
StateMachines::Sequel.log(self, :debug, "updating_audit_log", {audit_log_id: last_log.id})
|
110
|
+
mapped_values = last_log.sequel_state_machine_map_columns(
|
101
111
|
at: Time.now,
|
102
112
|
actor: StateMachines::Sequel.current_actor,
|
103
|
-
messages: current.messages,
|
113
|
+
messages: current.messages || (current.class.state_machine_messages_supports_array ? [] : ""),
|
104
114
|
reason: current.reason,
|
105
|
-
)
|
115
|
+
)
|
116
|
+
last_log.update(**mapped_values)
|
106
117
|
else
|
107
118
|
StateMachines::Sequel.log(self, :debug, "creating_audit_log", {})
|
108
119
|
current.set(**current.sequel_state_machine_map_columns(
|
@@ -124,7 +135,7 @@ module Sequel
|
|
124
135
|
audlog.messages << message
|
125
136
|
else
|
126
137
|
audlog.messages ||= ""
|
127
|
-
audlog.messages += (audlog.messages.empty? ? message : (
|
138
|
+
audlog.messages += (audlog.messages.empty? ? message : ("\n" + message))
|
128
139
|
end
|
129
140
|
audlog.reason = reason if reason
|
130
141
|
return audlog
|
@@ -76,7 +76,7 @@ module Sequel
|
|
76
76
|
|
77
77
|
def full_message
|
78
78
|
msg = self.sequel_state_machine_get(:messages)
|
79
|
-
return self.class.state_machine_messages_supports_array ? msg.join("
|
79
|
+
return self.class.state_machine_messages_supports_array ? msg.join("\n") : msg
|
80
80
|
end
|
81
81
|
|
82
82
|
def sequel_state_machine_get(unmapped)
|
@@ -16,7 +16,7 @@ module StateMachines
|
|
16
16
|
if obj.respond_to?(:audit_logs) && !obj.audit_logs.empty?
|
17
17
|
@audit_log = obj.audit_logs.max_by(&:id)
|
18
18
|
msg += ": #{@audit_log.full_message}"
|
19
|
-
msg = msg.
|
19
|
+
msg = msg.gsub("\n", ", ").strip
|
20
20
|
end
|
21
21
|
super(obj, msg)
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-state-machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lithic Tech
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,56 +44,70 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.25.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.25.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-performance
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.13.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.13.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-sequel
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.3.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.3.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sequel
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5.
|
89
|
+
version: '5.59'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5.
|
96
|
+
version: '5.59'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sequel-postgres-pr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.6'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: simplecov
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,7 +183,7 @@ licenses:
|
|
169
183
|
- MIT
|
170
184
|
metadata:
|
171
185
|
rubygems_mfa_required: 'true'
|
172
|
-
post_install_message:
|
186
|
+
post_install_message:
|
173
187
|
rdoc_options: []
|
174
188
|
require_paths:
|
175
189
|
- lib
|
@@ -184,8 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
198
|
- !ruby/object:Gem::Version
|
185
199
|
version: '0'
|
186
200
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
188
|
-
signing_key:
|
201
|
+
rubygems_version: 3.4.6
|
202
|
+
signing_key:
|
189
203
|
specification_version: 4
|
190
204
|
summary: Hook together the excellent Ruby Sequel ORM to the state-machines library,
|
191
205
|
with auditing and other tools.
|