amazing-activist 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccad58a6e900c0d926811f0f5520a807665c3966efff845ac4359c00493cf0cf
4
- data.tar.gz: 79b51504d7c1bea9dc76bcefe0d78697d7a3e30f15bd21c3dac8684ebaf81dac
3
+ metadata.gz: e1b67a3e5f375db018b80c5576790c70199cab89e8e352bf2700f06e2efa8678
4
+ data.tar.gz: 313e959d99e39ec6c6c759748bdd08889c73945388ed5240e5919043968558f5
5
5
  SHA512:
6
- metadata.gz: 36d6f413e5a39dbde9bf7c0aa6ef40bb58f438096ba659963536c7a2c059c135a00f88f765058edfdb53bdc572352f48f5ac6ebd3d7e4444205b9c34c85ccf51
7
- data.tar.gz: 56347f7ea9356a1edfdff9f41816b34036f25184ccc7e102ebb11524371b7e3e2e1f134d17bf6644c47ebc7ffd1f36fc369f12f438c62571837f9ae48e8684b2
6
+ metadata.gz: 2f97922ccb1e84836578e2103f17b34e6a0081d29f6370aac8438b9cfdbf53974c3d14ab66f92f56569ca2481c0000e069db0967be80614578d7edf8881f7bfa
7
+ data.tar.gz: a53cc57eb23851df4af94092f83506fc23d79769158d8ac7105badd94742d68e08959add4746eb41f767bb1fd2b0fec082ee161caf73722a200420a96cd68a72
data/CHANGES.md ADDED
@@ -0,0 +1,69 @@
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.5.1] - 2023-04-26
12
+
13
+ ### Changed
14
+
15
+ - Optimize `Failure#deconstruct_keys` to avoid message generation if requested
16
+ keys are present and do not include it.
17
+
18
+
19
+ ## [0.5.0] - 2023-03-13
20
+
21
+ ### Changed
22
+
23
+ - (BREAKING) i18n does not remove `_activity` suffix from keys anymore, e.g.
24
+ for `Foo::BarActivity` expected i18n key will be `foo/bar_activity`, not
25
+ `foo/bar` as it was before.
26
+
27
+
28
+ ## [0.4.0] - 2024-02-19
29
+
30
+ ### Added
31
+
32
+ - `Base.on_broken_outcome` allows registering custom handler for the broken
33
+ outcome contract (when `#call` returns neither `Success` nor `Failure`)
34
+ - `Base.rescue_from` allows registering unhandled exception handlers.
35
+
36
+
37
+ ## [0.3.0] - 2024-02-19
38
+
39
+ ### Added
40
+
41
+ - `UnwrapError#cause` respects failure's `#exception`.
42
+
43
+ ### Changed
44
+
45
+ - (BREAKING) `Base#failure` context must be given as keyword argument.
46
+ - (BREAKING) `Failure#message` is no longer part of its `#context`.
47
+ - (BREAKING) `Failure#exception` is no longer part of its `#context`.
48
+
49
+
50
+ ## [0.2.0] - 2024-01-28
51
+
52
+ ### Added
53
+
54
+ - Generate default failure messages with
55
+ [i18n](https://github.com/ruby-i18n/i18n).
56
+
57
+
58
+ ## [0.1.0] - 2024-01-27
59
+
60
+ ### Added
61
+
62
+ - Initial release.
63
+
64
+ [0.5.1]: https://github.com/ixti/amazing-activist/compare/v0.5.0...v0.5.1
65
+ [0.5.0]: https://github.com/ixti/amazing-activist/compare/v0.4.0...v0.5.0
66
+ [0.4.0]: https://github.com/ixti/amazing-activist/compare/v0.3.0...v0.4.0
67
+ [0.3.0]: https://github.com/ixti/amazing-activist/compare/v0.2.0...v0.3.0
68
+ [0.2.0]: https://github.com/ixti/amazing-activist/compare/v0.1.0...v0.2.0
69
+ [0.1.0]: https://github.com/ixti/amazing-activist/tree/v0.1.0
@@ -1,4 +1,4 @@
1
1
  en:
2
2
  amazing_activist:
3
3
  failures:
4
- not_implemented: "<%{activity}> activity has no implementation"
4
+ not_implemented: "<%{activity}> has no implementation"
@@ -1,4 +1,4 @@
1
1
  gl:
2
2
  amazing_activist:
3
3
  failures:
4
- not_implemented: "<%{activity}> actividade non ten implementación"
4
+ not_implemented: "<%{activity}> non ten implementación"
@@ -49,8 +49,11 @@ module AmazingActivist
49
49
 
50
50
  # @api internal
51
51
  # @return [Hash]
52
- def deconstruct_keys(_)
53
- { failure: @code, activity: @activity, message: message, exception: exception, context: context }
52
+ def deconstruct_keys(keys)
53
+ deconstructed = { failure: @code, activity: @activity, exception: exception, context: context }
54
+ deconstructed[:message] = message if keys.nil? || keys.include?(:message)
55
+
56
+ deconstructed
54
57
  end
55
58
 
56
59
  # @yieldparam self [self]
@@ -10,9 +10,6 @@ I18n.load_path += Dir[File.expand_path("#{__dir__}/locale/*.yml")]
10
10
  module AmazingActivist
11
11
  # @api internal
12
12
  class Polyglot
13
- ANONYMOUS_ACTIVITY_NAME = "anonymous"
14
- private_constant :ANONYMOUS_ACTIVITY_NAME
15
-
16
13
  def initialize(activity)
17
14
  @activity = activity
18
15
  end
@@ -25,26 +22,26 @@ module AmazingActivist
25
22
  # Thus, if activity `Pretty::DamnGoodActivity` failed with `:bad_choise`
26
23
  # code the lookup will be:
27
24
  #
28
- # * `amazing_activist.activities.pretty/damn_good.failures.bad_choice
25
+ # * `amazing_activist.activities.pretty/damn_good_activity.failures.bad_choice
29
26
  # * `amazing_activist.failures.bad_choice
30
27
  #
31
28
  # If there's no translation with any of the above keys, a generic
32
29
  # non-translated message will be used:
33
30
  #
34
- # <pretty/damn_good> activity failed - bad_choice
31
+ # <pretty/damn_good_activity> failed - bad_choice
35
32
  #
36
33
  # @return [String] Failure message
37
34
  def message(code, **context)
38
35
  default = [
39
36
  :"amazing_activist.failures.#{code}",
40
- "<%{activity}> activity failed - %{code}" # rubocop:disable Style/FormatStringToken
37
+ "<%{activity}> failed - %{code}" # rubocop:disable Style/FormatStringToken
41
38
  ]
42
39
 
43
40
  if @activity.class.name
44
- activity = @activity.class.name.underscore.presence.delete_suffix("_activity")
41
+ activity = @activity.class.name.underscore.presence
45
42
  i18n_key = :"amazing_activist.activities.#{activity}.failures.#{code}"
46
43
  else
47
- activity = "(anonymous)"
44
+ activity = "(anonymous activity)"
48
45
  i18n_key = default.shift
49
46
  end
50
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AmazingActivist
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.1"
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.4.0
4
+ version: 0.5.1
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-02-20 00:00:00.000000000 Z
11
+ date: 2024-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - CHANGES.md
48
49
  - LICENSE.txt
49
50
  - README.adoc
50
51
  - lib/amazing-activist.rb
@@ -68,9 +69,9 @@ licenses:
68
69
  - MIT
69
70
  metadata:
70
71
  homepage_uri: https://github.com/ixti/amazing-activist
71
- source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.4.0
72
+ source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.5.1
72
73
  bug_tracker_uri: https://github.com/ixti/amazing-activist/issues
73
- changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.4.0/CHANGES.md
74
+ changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.5.1/CHANGES.md
74
75
  rubygems_mfa_required: 'true'
75
76
  post_install_message:
76
77
  rdoc_options: []