lite-command 3.1.4 → 3.1.5
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -4
- data/lib/lite/command/internals/attributes.rb +3 -3
- data/lib/lite/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: 25949bea3778fbe660ae361819879bc36deb461fb37e9efa4ad11012529ae682
|
4
|
+
data.tar.gz: 7f9df66b9027c3c7e3cb7b8efaad1508dec68c22b4b63ab27c4ffd123707519e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c2ee67da223708a63852d539ab82f7a893214c1016376fc0af4496d224ccdcfef3340b1267f6fec11348ae8d2ede2c87b605494aa2090a8f449c317a3d9613a
|
7
|
+
data.tar.gz: 29ec28857fc0e8f29e1ba34a41cae8b44298a44c9477e73a237f5eb708965ba555a4b82edff984b20b61b4f1967ce93586ec74075a8421f6481c353865c0e275
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [3.1.5] - 2024-10-28
|
10
|
+
### Changed
|
11
|
+
- Renamed private `delegate` method to `delegates` to prevent rails clash
|
12
|
+
|
9
13
|
## [3.1.4] - 2024-10-27
|
10
14
|
### Added
|
11
15
|
- Add exception data to results hash
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -262,9 +262,18 @@ class DecryptSecretMessage < Lite::Command::Base
|
|
262
262
|
|
263
263
|
validates :encrypted_message, length: 10..999
|
264
264
|
validates :version, inclusion: { in: %w[v1 v3 v8], allow_blank: true }
|
265
|
+
validate :validate_decrypt_magic_numbers
|
265
266
|
|
266
267
|
def call
|
267
|
-
context.decrypted_message = SecretMessage.decrypt(
|
268
|
+
context.decrypted_message = SecretMessage.decrypt(encrypted_message)
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
|
273
|
+
def validate_decrypt_magic_numbers
|
274
|
+
return if encrypted_message.starts_with?("~x01~")
|
275
|
+
|
276
|
+
errors.add(:encrypted_message, :invalid, message: "has invalid magic numbers")
|
268
277
|
end
|
269
278
|
|
270
279
|
end
|
@@ -352,6 +361,9 @@ cmd.status #=> "invalid"
|
|
352
361
|
cmd.reason #=> "Invalid message start value"
|
353
362
|
cmd.metadata #=> { i18n: "gb.invalid_start_value" }
|
354
363
|
|
364
|
+
cmd.original_exception #=> <RuntimeError ...>
|
365
|
+
cmd.command_exception #=> <DecryptSecretMessage::Error ...>
|
366
|
+
|
355
367
|
cmd.success? #=> false
|
356
368
|
cmd.noop? #=> false
|
357
369
|
cmd.invalid? #=> true
|
@@ -606,13 +618,15 @@ command.to_hash #=> {
|
|
606
618
|
#=> outcome: "failure",
|
607
619
|
#=> state: "interrupted",
|
608
620
|
#=> status: "failure",
|
609
|
-
#=> reason: "
|
621
|
+
#=> reason: "Command stopped due to some failure",
|
610
622
|
#=> metadata: {
|
611
623
|
#=> errors: { name: ["is too short"] },
|
612
624
|
#=> i18n_key: "command.failure"
|
613
625
|
#=> },
|
614
|
-
#=> caused_by:
|
615
|
-
#=>
|
626
|
+
#=> caused_by: 3,
|
627
|
+
#=> caused_exception: "[ChildCommand::Failure] something is wrong from within",
|
628
|
+
#=> thrown_by: 2,
|
629
|
+
#=> thrown_exception: "[FailureCommand::Failure] something is wrong from within",
|
616
630
|
#=> runtime: 0.0123
|
617
631
|
#=> }
|
618
632
|
```
|
@@ -12,7 +12,7 @@ module Lite
|
|
12
12
|
module ClassMethods
|
13
13
|
|
14
14
|
def required(*attributes, from: :context, **options)
|
15
|
-
|
15
|
+
delegates(*attributes, from:)
|
16
16
|
|
17
17
|
validates_each(*attributes, **options) do |command, method_name, _attr_value|
|
18
18
|
next if command.errors.added?(from, :undefined) || command.errors.added?(method_name, :required)
|
@@ -26,12 +26,12 @@ module Lite
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def optional(*attributes, from: :context, **_options)
|
29
|
-
|
29
|
+
delegates(*attributes, from:)
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def
|
34
|
+
def delegates(*attributes, from: :context)
|
35
35
|
attributes.each do |method_name|
|
36
36
|
define_method(method_name) do
|
37
37
|
return unless respond_to?(from)
|
data/lib/lite/command/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|