gl_command 1.2.0 → 1.3.0
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/lib/gl_command/callable.rb +1 -0
- data/lib/gl_command/context_inspect.rb +40 -21
- data/lib/gl_command/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d64529ae90558047a1a67fb4641fcbc6807f4bac0ef8b503945d2981dac33f80
|
4
|
+
data.tar.gz: 541c75d629f1ba4971ab7d6fd37ac4a1fdfee2f19cb6256477d4857408fb64ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7767272a19c79ed50bc21bcd5a94a04f8f16c26e509bdfc3b86937e8204dabf2d053ea2fc85919acc56de3a770fd35ff88490b2d101fdcf6e6a89a714c55176f
|
7
|
+
data.tar.gz: f4fd2347bedf5ccbd94c09e230bf760d16d0ec1f19a4ecada73416d7a4b0da52a7f79759f074c4a38f98cd783ce45a07dd84c46dd1f13b87685cfdec8d0e9c9e
|
data/lib/gl_command/callable.rb
CHANGED
@@ -202,6 +202,7 @@ module GLCommand
|
|
202
202
|
|
203
203
|
chain_rollback if self.class.chain? # defined in GLCommand::Chainable
|
204
204
|
rollback
|
205
|
+
instrument_command(:after_rollback)
|
205
206
|
end
|
206
207
|
|
207
208
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -1,5 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GLCommand
|
2
4
|
class ContextInspect
|
5
|
+
PERMITTED_OUTPUTS = %i[string hash].freeze
|
6
|
+
|
3
7
|
class << self
|
4
8
|
def error(error_obj)
|
5
9
|
return '' if error_obj.blank?
|
@@ -7,35 +11,50 @@ module GLCommand
|
|
7
11
|
error_obj.is_a?(Array) ? error_obj.uniq.join(', ') : error_obj.to_s
|
8
12
|
end
|
9
13
|
|
10
|
-
def hash_params(hash)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
elsif value.respond_to?(:uuid)
|
18
|
-
object_param_with_id(value, :uuid)
|
19
|
-
elsif value.respond_to?(:id)
|
20
|
-
object_param_with_id(value, :id)
|
21
|
-
else
|
22
|
-
value
|
23
|
-
end
|
24
|
-
"#{key}: #{value_s}"
|
25
|
-
end.join(', ')
|
14
|
+
def hash_params(hash, output: :string)
|
15
|
+
unless PERMITTED_OUTPUTS.include?(output)
|
16
|
+
raise "Unknown output type: #{output}, must be one of #{PERMITTED_OUTPUTS}"
|
17
|
+
end
|
18
|
+
|
19
|
+
result = hash.map { |key, value| output_for(key:, value:, output:) }
|
20
|
+
output == :string ? result.join(', ') : result.to_h
|
26
21
|
end
|
27
22
|
|
28
23
|
private
|
29
24
|
|
25
|
+
def output_for(key:, value:, output:)
|
26
|
+
value_s = if value.nil?
|
27
|
+
'nil'
|
28
|
+
elsif value.respond_to?(:to_sql)
|
29
|
+
object_param_as_sql(value, output:)
|
30
|
+
elsif value.respond_to?(:id)
|
31
|
+
object_param_with_id(value, :id, output:)
|
32
|
+
elsif value.respond_to?(:uuid)
|
33
|
+
object_param_with_id(value, :uuid, output:)
|
34
|
+
else
|
35
|
+
value
|
36
|
+
end
|
37
|
+
|
38
|
+
output == :string ? "#{key}: #{value_s}" : [key, value_s]
|
39
|
+
end
|
40
|
+
|
30
41
|
# Active record objects can be really big - rather than rendering the whole object, just show the ID
|
31
|
-
def object_param_with_id(obj, key)
|
42
|
+
def object_param_with_id(obj, key, output:)
|
32
43
|
obj_id = obj.send(key)
|
33
|
-
|
34
|
-
|
44
|
+
if output == :string
|
45
|
+
id_value = obj_id.is_a?(Integer) ? obj_id : "\"#{obj_id}\""
|
46
|
+
"#<#{obj.class.name} #{key}=#{id_value}>"
|
47
|
+
else
|
48
|
+
obj_id
|
49
|
+
end
|
35
50
|
end
|
36
51
|
|
37
|
-
def object_param_as_sql(obj)
|
38
|
-
|
52
|
+
def object_param_as_sql(obj, output:)
|
53
|
+
if output == :string
|
54
|
+
"#<#{obj.class.name} sql=\"#{obj.to_sql}\">"
|
55
|
+
else
|
56
|
+
obj.to_sql
|
57
|
+
end
|
39
58
|
end
|
40
59
|
end
|
41
60
|
end
|
data/lib/gl_command/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gl_command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Give Lively
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|