cmdx 1.7.3 → 1.7.4

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: 01fd49f8d31e90b2818d78cbf452c68888f76e8f4983647b1c163b235963b6a8
4
- data.tar.gz: ab15559fbfedd9f359f23fbce24b7259ed428ef37caeb5522777de0724f395a8
3
+ metadata.gz: ff39f948f58871f530cfe7c94fc3b2ced9fe4cd9454147c7f9c5a68419e05488
4
+ data.tar.gz: fe3771fdcdaf0caff34f24c96ff424d4a0452d34072b05f3e9dc773301e64a3f
5
5
  SHA512:
6
- metadata.gz: f5a8da6a5f773f69d2e25fb856f8440ec630c7d049493b0bf1478719ef4ac17f2d1bfc82f2718030de3883cf91db43986d0826b4bcfbfed7ceaaf1f7b5ba1c6f
7
- data.tar.gz: c36629bdbe94b2ce563e67f0d1bcaf9c292d180f30a22871a10480d11676714819f2636f463f538916f72c56200170f4ab39e8d9a84c28479a41a5310f7fdd12
6
+ metadata.gz: d2948e478871aefd1f966dd3c6ff37adbb4c2bdeb7797d926d1b70de067ed1b3fedc7a8a5ac76c3d69cdac72d9ff038ac3e47bb2c676cead50ec3108ae4f9c38
7
+ data.tar.gz: 20b3808d5cca7c389a9d29396441475cb17a2b0e93c3e4b7ceb2132bf781521d5ff1b5a90487bced9a3b402e5acfc88f714fc94f14ef5b9edf9f801d8c482f89
data/CHANGELOG.md CHANGED
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [TODO]
7
+ ## [1.7.4] - 2025-09-03
8
+
9
+ ### Added
10
+ - Added errors delegation from result object
11
+ - Added `full_messages` and `to_hash` methods to errors
8
12
 
9
13
  ## [1.7.3] - 2025-09-03
10
14
 
data/lib/cmdx/errors.rb CHANGED
@@ -48,6 +48,18 @@ module CMDx
48
48
  !messages[attribute].empty?
49
49
  end
50
50
 
51
+ # Convert errors to a hash format with arrays of fullmessages.
52
+ #
53
+ # @return [Hash{Symbol => Array<String>}] Hash with attribute keys and message arrays
54
+ #
55
+ # @example
56
+ # errors.full_messages # => { email: ["email must be valid format", "email cannot be blank"] }
57
+ def full_messages
58
+ messages.each_with_object({}) do |(attribute, messages), hash|
59
+ hash[attribute] = messages.map { |message| "#{attribute} #{message}" }
60
+ end
61
+ end
62
+
51
63
  # Convert errors to a hash format with arrays of messages.
52
64
  #
53
65
  # @return [Hash{Symbol => Array<String>}] Hash with attribute keys and message arrays
@@ -58,6 +70,18 @@ module CMDx
58
70
  messages.transform_values(&:to_a)
59
71
  end
60
72
 
73
+ # Convert errors to a hash format with optional full messages.
74
+ #
75
+ # @param full [Boolean] Whether to include full messages with attribute names
76
+ # @return [Hash{Symbol => Array<String>}] Hash with attribute keys and message arrays
77
+ #
78
+ # @example
79
+ # errors.to_hash # => { email: ["must be valid format", "cannot be blank"] }
80
+ # errors.to_hash(true) # => { email: ["email must be valid format", "email cannot be blank"] }
81
+ def to_hash(full = false)
82
+ full ? full_messages : to_h
83
+ end
84
+
61
85
  # Convert errors to a human-readable string format.
62
86
  #
63
87
  # @return [String] Formatted error messages joined with periods
@@ -65,9 +89,7 @@ module CMDx
65
89
  # @example
66
90
  # errors.to_s # => "email must be valid format. email cannot be blank"
67
91
  def to_s
68
- messages.each_with_object([]) do |(attribute, messages), memo|
69
- messages.each { |message| memo << "#{attribute} #{message}" }
70
- end.join(". ")
92
+ full_messages.values.flatten.join(". ")
71
93
  end
72
94
 
73
95
  end
data/lib/cmdx/result.rb CHANGED
@@ -33,7 +33,7 @@ module CMDx
33
33
 
34
34
  attr_reader :task, :state, :status, :metadata, :reason, :cause
35
35
 
36
- def_delegators :task, :context, :chain
36
+ def_delegators :task, :context, :chain, :errors
37
37
 
38
38
  # @param task [CMDx::Task] The task instance this result represents
39
39
  #
data/lib/cmdx/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CMDx
4
4
 
5
- VERSION = "1.7.3"
5
+ VERSION = "1.7.4"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez