lite-command 3.0.0 → 3.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b334836e64434045ade9238d62507c609c53893b8b79f17a9922054336bcf22f
4
- data.tar.gz: c1c84f0f56da8fd3153326c7de316a2382864c5f56d6d1de89835a70c3453e30
3
+ metadata.gz: 953b62c2ba61091b949e8fe3a673bc98be6a516afcea85192ea356e356aaf84e
4
+ data.tar.gz: adfb9bf29183586b33f8b32b801afadfbcf890398827e002dd794692bb708c9e
5
5
  SHA512:
6
- metadata.gz: db8e4a837b728ec4a95733b4820096acd666d956d5f14954366a3fef061a20bca16eb5ed3e6224c1b2bcb676d55d11d21e336ded98ad4fdd0d9968bdb9479a3e
7
- data.tar.gz: d2e21206738f9d692784c05496568d79f42b390a9869a22dfdec6e58640d8019c78958e9df36871fd8ad2f642ea0f240a5f6070ebaa45957cc73fc41daca2aa7
6
+ metadata.gz: b618d0bda8cdbdc2335a16900e00addbdcf0a71e4ee6170c907d3b1e8110415990191d4bc9a9b5a0765582d2ce83df758d4b9109114fa33f04ec0ca27e388524
7
+ data.tar.gz: 6a606bcd18ad5c97920e67557bc946f8e38446c83fdb2155a298530e338cf1f033e6388b411f7229919be6a70eb6c45510b8c1a1c95f9eeed0beabaa143550fa
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.1.0] - 2024-10-25
10
+ ### Added
11
+ - Added `raise!` method to reraise soft call errors
12
+ ### Changed
13
+ - Fixed leakage of configuration option changes in spec
14
+
15
+ ## [3.0.1] - 2024-10-25
16
+ ### Changed
17
+ - Changed equality check for better matching
18
+
9
19
  ## [3.0.0] - 2024-10-15
10
20
  ### Added
11
21
  - Added `bad?` status method check
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-command (3.0.0)
4
+ lite-command (3.1.0)
5
5
  activemodel
6
6
  ostruct
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.2.1.1)
12
- actionview (= 7.2.1.1)
13
- activesupport (= 7.2.1.1)
11
+ actionpack (7.2.1.2)
12
+ actionview (= 7.2.1.2)
13
+ activesupport (= 7.2.1.2)
14
14
  nokogiri (>= 1.8.5)
15
15
  racc
16
16
  rack (>= 2.2.4, < 3.2)
@@ -19,15 +19,15 @@ GEM
19
19
  rails-dom-testing (~> 2.2)
20
20
  rails-html-sanitizer (~> 1.6)
21
21
  useragent (~> 0.16)
22
- actionview (7.2.1.1)
23
- activesupport (= 7.2.1.1)
22
+ actionview (7.2.1.2)
23
+ activesupport (= 7.2.1.2)
24
24
  builder (~> 3.1)
25
25
  erubi (~> 1.11)
26
26
  rails-dom-testing (~> 2.2)
27
27
  rails-html-sanitizer (~> 1.6)
28
- activemodel (7.2.1.1)
29
- activesupport (= 7.2.1.1)
30
- activesupport (7.2.1.1)
28
+ activemodel (7.2.1.2)
29
+ activesupport (= 7.2.1.2)
30
+ activesupport (7.2.1.2)
31
31
  base64
32
32
  bigdecimal
33
33
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -57,10 +57,10 @@ GEM
57
57
  irb (1.14.1)
58
58
  rdoc (>= 4.0.0)
59
59
  reline (>= 0.4.2)
60
- json (2.7.2)
60
+ json (2.7.4)
61
61
  language_server-protocol (3.17.0.3)
62
62
  logger (1.6.1)
63
- loofah (2.22.0)
63
+ loofah (2.23.1)
64
64
  crass (~> 1.0.2)
65
65
  nokogiri (>= 1.12.0)
66
66
  mini_portile2 (2.8.7)
@@ -91,9 +91,9 @@ GEM
91
91
  rails-html-sanitizer (1.6.0)
92
92
  loofah (~> 2.21)
93
93
  nokogiri (~> 1.14)
94
- railties (7.2.1.1)
95
- actionpack (= 7.2.1.1)
96
- activesupport (= 7.2.1.1)
94
+ railties (7.2.1.2)
95
+ actionpack (= 7.2.1.2)
96
+ activesupport (= 7.2.1.2)
97
97
  irb (~> 1.13)
98
98
  rackup (>= 1.0.0)
99
99
  rake (>= 12.2)
@@ -110,7 +110,7 @@ GEM
110
110
  rspec-core (~> 3.13.0)
111
111
  rspec-expectations (~> 3.13.0)
112
112
  rspec-mocks (~> 3.13.0)
113
- rspec-core (3.13.1)
113
+ rspec-core (3.13.2)
114
114
  rspec-support (~> 3.13.0)
115
115
  rspec-expectations (3.13.3)
116
116
  diff-lcs (>= 1.2.0, < 2.0)
@@ -140,7 +140,7 @@ GEM
140
140
  rubocop (~> 1.61)
141
141
  ruby-progressbar (1.13.0)
142
142
  securerandom (0.3.1)
143
- sqlite3 (2.1.0)
143
+ sqlite3 (2.1.1)
144
144
  mini_portile2 (~> 2.8.0)
145
145
  stringio (3.1.1)
146
146
  thor (1.3.2)
@@ -149,7 +149,7 @@ GEM
149
149
  unicode-display_width (2.6.0)
150
150
  useragent (0.16.10)
151
151
  webrick (1.8.2)
152
- zeitwerk (2.7.0)
152
+ zeitwerk (2.7.1)
153
153
 
154
154
  PLATFORMS
155
155
  ruby
data/README.md CHANGED
@@ -88,15 +88,21 @@ end
88
88
 
89
89
  Executing a command can be done as an instance or class call. It returns the command instance
90
90
  in a frozen state. These will never call will never raise an execption, but will be kept track
91
- of in its internal state.
91
+ of in its internal state. You can raise the offending exception using `raise!`.
92
92
 
93
93
  ```ruby
94
- DecryptSecretMessage.call(...)
94
+ cmd = DecryptSecretMessage.call(...)
95
95
  # - or -
96
- DecryptSecretMessage.new(...).call
96
+ cmd = DecryptSecretMessage.new(...).call
97
97
 
98
- # On success, fault and exception:
99
- #=> <DecryptSecretMessage ...>
98
+ # On success, fault or exception:
99
+ cmd #=> <DecryptSecretMessage ...>
100
+
101
+ # On fault:
102
+ cmd.raise! #=> raises Lite::Command::Fault
103
+
104
+ # On exception:
105
+ cmd.raise! #=> raises StandardError
100
106
  ```
101
107
 
102
108
  > [!TIP]
@@ -29,10 +29,18 @@ module Lite
29
29
  fault
30
30
  end
31
31
 
32
+ def self.===(item)
33
+ Utils.descendant_of?(self, item) || Utils.descendant_of?(item, self)
34
+ end
35
+
32
36
  def type
33
37
  @type ||= self.class.name.split("::").last.downcase
34
38
  end
35
39
 
40
+ def ===(item)
41
+ Utils.descendant_of?(self, item)
42
+ end
43
+
36
44
  end
37
45
 
38
46
  class Noop < Fault; end
@@ -60,6 +60,7 @@ module Lite
60
60
  around_execution { call }
61
61
  Utils.try(self, :on_success)
62
62
  rescue StandardError => e
63
+ @exception = e
63
64
  fault(e, ERROR, metadata) unless e.is_a?(Lite::Command::Fault)
64
65
  after_execution
65
66
  Utils.try(self, :"on_#{status}", e)
@@ -71,6 +72,7 @@ module Lite
71
72
  around_execution { call }
72
73
  Utils.try(self, :on_success)
73
74
  rescue StandardError => e
75
+ @exception = e
74
76
  fault(e, ERROR, metadata) unless e.is_a?(Lite::Command::Fault)
75
77
  after_execution
76
78
  Utils.try(self, :"on_#{status}", e)
@@ -5,6 +5,10 @@ module Lite
5
5
  module Internals
6
6
  module Faults
7
7
 
8
+ def self.included(base)
9
+ base.class_eval { attr_reader :exception }
10
+ end
11
+
8
12
  def caused_by
9
13
  return if success?
10
14
 
@@ -29,6 +33,12 @@ module Lite
29
33
  fault? && !caused_fault?
30
34
  end
31
35
 
36
+ def raise!
37
+ return if exception.nil?
38
+
39
+ raise exception
40
+ end
41
+
32
42
  private
33
43
 
34
44
  def throw!(command)
@@ -6,6 +6,13 @@ module Lite
6
6
 
7
7
  module_function
8
8
 
9
+ def descendant_of?(object, other)
10
+ object_class = object.respond_to?(:new) ? object : object.class
11
+ other_class = other.respond_to?(:new) ? other : other.class
12
+
13
+ !!(object_class <= other_class)
14
+ end
15
+
9
16
  def try(object, method_name, *args, include_private: true)
10
17
  return unless object.respond_to?(method_name, include_private)
11
18
 
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Command
5
5
 
6
- VERSION = "3.0.0"
6
+ VERSION = "3.1.0"
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.0.0
4
+ version: 3.1.0
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-16 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel