opera 0.2.17 → 0.2.18

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: c6b4eeef70ec90ace2eab7861bb9e9801f1e986354a411f2ca426f1380c3a0f7
4
- data.tar.gz: b2264478656ffab0e08ae0e50b7b54a4dffdf81d64bb53bb2a27365151700351
3
+ metadata.gz: f5f102d05b4d0cbf79d677bc5697388b51f643dfa5a880426894f1c6b30b70dc
4
+ data.tar.gz: a30d504859167c71b902ac30dbc03bcf8ea048575aa08a5f0b26864e24c51be9
5
5
  SHA512:
6
- metadata.gz: efb5db089f99b26ab2f085e62a064dcaf31adc46632fccc9e51ab73f22dc611d9341f7f3ddb5b4d1bdf5d1c8b598aab54af5071df891f0696f5b8357bcd1960b
7
- data.tar.gz: 0c5e84d50fa8f0a0b5f4a839b97e208925420de362ed42ab60e0731aadfe4b7a25462a6927078feb185dd03c2621aa09562a13d5893b3fdba3bd9de171e01fd6
6
+ metadata.gz: 69fe6abf0538339b075da566f75d8b18e60533cb33254bc25a5e495f49e89fa065a2abe2ee65c8e79cbf5b222a68284ac3f6a8a5fb37c9453a5a767d58d9caf1
7
+ data.tar.gz: 12630548b31111d555ffc9e7e95d2d07d5f6fd919feac47ffab3c152587d700a2f4460f927456242b7a23b414ae37d8a152cb9d0f3cd6ea74276894f3dad385e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Opera Changelog
2
2
 
3
+ ### 0.2.18 - September 20, 2024
4
+
5
+ - added `output!` method on Result object
6
+ - deleted `to_h` alias for `output`
7
+
3
8
  ### 0.2.17 - July 8, 2024
4
9
 
5
10
  - minor fix `mode` configuration option.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opera (0.2.16)
4
+ opera (0.2.18)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -880,6 +880,7 @@ Opera::Operation::Result.new(output: 'success')
880
880
  - failure? - [true, false] - Return true if any error or exception
881
881
  - output - [Anything] - Return Anything
882
882
  - output=(Anything) - Sets content of operation output
883
+ - output! - Return Anything if Success, raise exception if Failure
883
884
  - add_error(key, value) - Adds new error message
884
885
  - add_errors(Hash) - Adds multiple error messages
885
886
  - add_exception(method, message, classname: nil) - Adds new exception
@@ -17,7 +17,7 @@ module Opera
17
17
 
18
18
  case dry_result
19
19
  when Opera::Operation::Result
20
- add_instruction_output(instruction, dry_result.to_h)
20
+ add_instruction_output(instruction, dry_result.output)
21
21
 
22
22
  unless dry_result.success?
23
23
  result.add_errors(dry_result.errors)
@@ -3,14 +3,14 @@
3
3
  module Opera
4
4
  module Operation
5
5
  class Result
6
+ class OutputError < StandardError; end
7
+
6
8
  attr_reader :errors, # Acumulator of errors in validation + steps
7
9
  :exceptions, # Acumulator of exceptions in steps
8
10
  :information, # Temporal object to store related information
9
11
  :executions # Stacktrace or Pipe of the methods evaludated
10
12
 
11
- attr_accessor :output # Final object returned if success?
12
-
13
- alias to_h output
13
+ attr_accessor :output # in case of success, it contains the resulting value
14
14
 
15
15
  def initialize(output: nil, errors: {})
16
16
  @errors = errors
@@ -32,6 +32,12 @@ module Opera
32
32
  errors.merge(exceptions)
33
33
  end
34
34
 
35
+ def output!
36
+ raise OutputError, 'Cannot retrieve output from a Failure.' if failure?
37
+
38
+ output
39
+ end
40
+
35
41
  # rubocop:disable Metrics/MethodLength
36
42
  def add_error(field, message)
37
43
  @errors[field] ||= []
data/lib/opera/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Opera
4
- VERSION = '0.2.17'
4
+ VERSION = '0.2.18'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.17
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - ProFinda Development Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-08 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation