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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d88e18025d91c08352d81be6288346138b4c07f8c6c1b7e437c1309f4c4ed330
4
- data.tar.gz: 1011eca8e0ca7854dfd9b488d8f91a467d15ff2dccc60f5a36eb433ef3761fe7
3
+ metadata.gz: 25949bea3778fbe660ae361819879bc36deb461fb37e9efa4ad11012529ae682
4
+ data.tar.gz: 7f9df66b9027c3c7e3cb7b8efaad1508dec68c22b4b63ab27c4ffd123707519e
5
5
  SHA512:
6
- metadata.gz: 42eb9126777ee23506f1d98c3313e6de9c03da120b6711a399ad99051c88faac769080e4f41891c3a2658381aa4ad93eaf191c4ec00e446c8507f5f5ca8108fe
7
- data.tar.gz: f314544be97beead7f55e6e8ee3f164e9a80013368aaa1380f632e0a702dd3fecb555a06d9e100990454aff6249a01a35c688a28792aa9b1e7351e624e38b542
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-command (3.1.4)
4
+ lite-command (3.1.5)
5
5
  activemodel
6
6
  ostruct
7
7
 
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(ctx.encrypted_message)
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: "[!] command stopped due to failure",
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: 1,
615
- #=> thrown_by: 1,
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
- delegate(*attributes, from:)
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
- delegate(*attributes, from:)
29
+ delegates(*attributes, from:)
30
30
  end
31
31
 
32
32
  private
33
33
 
34
- def delegate(*attributes, from: :context)
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)
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Command
5
5
 
6
- VERSION = "3.1.4"
6
+ VERSION = "3.1.5"
7
7
 
8
8
  end
9
9
  end
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
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-27 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel