amazing-activist 0.2.0 → 0.3.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: f315ef7e7d9f2042299846f98243c0ba5b316cf5421d3c8f6d01f3340ed49b91
4
- data.tar.gz: ec30a1a3f6f72d3c0daa5160af6e388b3a1f1d4a1110922c3730bf3ddc3da6d1
3
+ metadata.gz: b5a9d6f3426a86d93d6affd8f54d19f7f071cb5142636c1b3b6fc2a12fbe87b9
4
+ data.tar.gz: d53b13cc039dee609e0d2870c560932942d3aa38009b4e7a742f7ce7ad44e9df
5
5
  SHA512:
6
- metadata.gz: 6d1a627bdd3555b90c232198db69b73da0cb6e3f51d6c4295e668ddb571fcce94bbe8d1f16d399622a5704cd2cf9c0e7e6e3a83d61bb7c5fa4595b85256f3153
7
- data.tar.gz: de4a7d7cb65e4ab08d1c80b23fae22b11a86b225e578e07a03bd7e18bf78202d7a5c5a6bdae0436d5d77f1726464f99a564701d9734fef1dd02842d19ae2c8d2
6
+ metadata.gz: '0549ced0fb0312fd5c4cca4cfc8ccaa0e359584c868497a5eea3caa7ad246958de12566d5f33525d555f6bbd9c3a77eb3536514d0e555b83a8a629048c3d58ff'
7
+ data.tar.gz: de8d63d94501dc73c61cc626e899407846af44dc8e9cb1c603e7154d57a57720adaa0897a319782a458ed9d89eff474a510777f5083206b9da902143f89060bd
data/README.adoc CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  [source,ruby]
26
26
  ----
27
- class ApplicationActivity < AmazingActivist::Activity
27
+ class ApplicationActivity < AmazingActivist::Base
28
28
  end
29
29
 
30
30
  class OnboardingActivity < ApplicationActivity
@@ -18,6 +18,14 @@ module AmazingActivist
18
18
  # failure(:invalid_params, user: user)
19
19
  # end
20
20
  # end
21
+ #
22
+ # case OnboardActivity.call(email: "user@example.com")
23
+ # in success: user
24
+ # Current.user = user
25
+ # redirect_to dashboard_url
26
+ # else
27
+ # render :new, status: :unprocessable_entity
28
+ # end
21
29
  # ----
22
30
  class Base
23
31
  class << self
@@ -53,8 +61,8 @@ module AmazingActivist
53
61
  # @param code (see Outcome::Failure#initialize)
54
62
  # @param context (see Outcome::Failure#initialize)
55
63
  # @return [Outcome::Failure]
56
- def failure(code, **context)
57
- Outcome::Failure.new(code, activity: self, context: context)
64
+ def failure(code, message: nil, exception: nil, context: {})
65
+ Outcome::Failure.new(code, activity: self, message: message, exception: exception, context: context)
58
66
  end
59
67
  end
60
68
  end
@@ -9,19 +9,26 @@ module AmazingActivist
9
9
  # @return [Symbol]
10
10
  attr_reader :code
11
11
 
12
- # @return [AmazingActivist::Activity]
12
+ # @return [AmazingActivist::Base]
13
13
  attr_reader :activity
14
14
 
15
- # @return [Hash{Symbol => Object}]
15
+ # @return [Exception, nil]
16
+ attr_reader :exception
17
+
18
+ # @return [Hash]
16
19
  attr_reader :context
17
20
 
18
21
  # @param code [#to_sym]
19
22
  # @param activity [AmazingActivist::Activity]
20
- # @param context [Hash{Symbol => Object}]
21
- def initialize(code, activity:, context:)
22
- @code = code.to_sym
23
- @activity = activity
24
- @context = context
23
+ # @param message [#to_s, nil]
24
+ # @param exception [Exception, nil]
25
+ # @param context [Hash]
26
+ def initialize(code, activity:, message:, exception:, context:)
27
+ @code = code.to_sym
28
+ @activity = activity
29
+ @message = message&.to_s
30
+ @exception = exception
31
+ @context = context
25
32
  end
26
33
 
27
34
  # @return [true]
@@ -35,15 +42,15 @@ module AmazingActivist
35
42
  end
36
43
 
37
44
  # @api internal
38
- # @return [Array<(:failure, Symbol, AmazingActivist::Activity, Hash{Symbol => Object})>]
45
+ # @return [Array]
39
46
  def deconstruct
40
- [:failure, @code, @activity, @context]
47
+ [:failure, @code, @activity]
41
48
  end
42
49
 
43
50
  # @api internal
44
- # @return [Hash{success: Object, activity: AmazingActivist::Activity}]
51
+ # @return [Hash]
45
52
  def deconstruct_keys(_)
46
- { failure: @code, activity: @activity, context: @context }
53
+ { failure: @code, activity: @activity, message: message, exception: exception, context: context }
47
54
  end
48
55
 
49
56
  # @yieldparam self [self]
@@ -56,8 +63,11 @@ module AmazingActivist
56
63
  raise UnwrapError, self
57
64
  end
58
65
 
66
+ # Failure message.
67
+ #
68
+ # @return [String]
59
69
  def message
60
- @context.fetch(:message) { Polyglot.new(@activity).message(@code, **context) }
70
+ @message || Polyglot.new(@activity).message(@code, **context)
61
71
  end
62
72
  end
63
73
  end
@@ -3,11 +3,11 @@
3
3
  module AmazingActivist
4
4
  module Outcome
5
5
  class Success
6
- # @return [AmazingActivist::Activity]
6
+ # @return [AmazingActivist::Base]
7
7
  attr_reader :activity
8
8
 
9
9
  # @param value [Object]
10
- # @param activity [AmazingActivist::Activity]
10
+ # @param activity [AmazingActivist::Base]
11
11
  def initialize(value, activity:)
12
12
  @value = value
13
13
  @activity = activity
@@ -24,13 +24,13 @@ module AmazingActivist
24
24
  end
25
25
 
26
26
  # @api internal
27
- # @return [Array<(:success, Object, AmazingActivist::Activity)>]
27
+ # @return [Array]
28
28
  def deconstruct
29
29
  [:success, @value, @activity]
30
30
  end
31
31
 
32
32
  # @api internal
33
- # @return [Hash{success: Object, activity: AmazingActivist::Activity}]
33
+ # @return [Hash]
34
34
  def deconstruct_keys(_)
35
35
  { success: @value, activity: @activity }
36
36
  end
@@ -13,5 +13,10 @@ module AmazingActivist
13
13
 
14
14
  super(failure.message)
15
15
  end
16
+
17
+ # @return [Exception, nil]
18
+ def cause
19
+ @failure.exception || super
20
+ end
16
21
  end
17
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AmazingActivist
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazing-activist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Zapparov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-28 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -45,7 +45,6 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - CHANGELOG.md
49
48
  - LICENSE.txt
50
49
  - README.adoc
51
50
  - lib/amazing-activist.rb
@@ -65,9 +64,9 @@ licenses:
65
64
  - MIT
66
65
  metadata:
67
66
  homepage_uri: https://github.com/ixti/amazing-activist
68
- source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.2.0
67
+ source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.3.0
69
68
  bug_tracker_uri: https://github.com/ixti/amazing-activist/issues
70
- changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.2.0/CHANGES.md
69
+ changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.3.0/CHANGES.md
71
70
  rubygems_mfa_required: 'true'
72
71
  post_install_message:
73
72
  rdoc_options: []
@@ -84,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
85
  requirements: []
87
- rubygems_version: 3.2.33
86
+ rubygems_version: 3.5.4
88
87
  signing_key:
89
88
  specification_version: 4
90
89
  summary: Your friendly neighborhood activist.
data/CHANGELOG.md DELETED
@@ -1,25 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
-
11
- ## [0.2.0] - 2024-01-28
12
-
13
- ## Added
14
-
15
- - Generate default failure messages with
16
- [i18n](https://github.com/ruby-i18n/i18n).
17
-
18
-
19
- ## [0.1.0] - 2024-01-27
20
-
21
- ## Added
22
-
23
- - Initial release.
24
-
25
- [0.1.0]: https://github.com/ixti/sidekiq-antidote/tree/v0.1.0