amazing-activist 0.5.0 → 0.5.2

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: 290c18d206342a875bfadb61a6d1cda66e7df96a44ecda1379a18e3aefc187fd
4
- data.tar.gz: d21e98ee9f606a7264cdf743f935f7c845832c884f86feef55076f8a3eae535f
3
+ metadata.gz: 1fab0193cbbc4c13ab7e7f2162143de36d01369aa84090020c4903164c9be3eb
4
+ data.tar.gz: ce39998e2d99ab98dcd504b52f634ce0ad829fa0063ddb646a64627a21348f92
5
5
  SHA512:
6
- metadata.gz: 3056d150ef3732e54396acd8915056cd20f5d11c6efc00eb3d131920deeaac92f42cbe5d92955e2667671fe3a14af93fc6cc495108fb797692b3280cb5449f7d
7
- data.tar.gz: 68886df50e8d078f52b03804ec09f146d64f6fcc6ad27c1153bc71b078e2b9b49868e5bb496a3caef9708321c18fe088d371c8a9eb4f9b8a1c09d62365d84ced
6
+ metadata.gz: d0c769b8a3b3ddfc1c1595c05c3b1093db5679c5a8f2ca2ef6076402113cb390b62ac4617b29e447426be8602f6df6825427b0e70d05e2c980747ddc98977b0a
7
+ data.tar.gz: bc41b347b777da6516b4b1fbc08006816f953d79219f47df93a4e8530e3de60383f7441045c42ab7b300f17d3d8d9bc20902f59ca4222c11499573551933f199
data/CHANGES.md CHANGED
@@ -7,7 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.5.0] - 2023-03-13
10
+ ## [0.5.2] - 2024-08-30
11
+
12
+ ### Changed
13
+
14
+ - i18n now looks for keys without `amazing_activist` prefix as well; Lookup
15
+ order now goes like: `amazing_activist.activities.[activity].failures`,
16
+ `activities.[activity].failures`, `amazing_activist.failures`,
17
+ `activities.failures`, with fallback to hardcoded `"<[activity]> failed - [code]"`.
18
+
19
+
20
+ ## [0.5.1] - 2024-04-26
21
+
22
+ ### Changed
23
+
24
+ - Optimize `Failure#deconstruct_keys` to avoid message generation if requested
25
+ keys are present and do not include it.
26
+
27
+
28
+ ## [0.5.0] - 2024-03-13
11
29
 
12
30
  ### Changed
13
31
 
@@ -52,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
52
70
 
53
71
  - Initial release.
54
72
 
73
+ [0.5.1]: https://github.com/ixti/amazing-activist/compare/v0.5.0...v0.5.1
55
74
  [0.5.0]: https://github.com/ixti/amazing-activist/compare/v0.4.0...v0.5.0
56
75
  [0.4.0]: https://github.com/ixti/amazing-activist/compare/v0.3.0...v0.4.0
57
76
  [0.3.0]: https://github.com/ixti/amazing-activist/compare/v0.2.0...v0.3.0
@@ -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]
@@ -17,13 +17,17 @@ module AmazingActivist
17
17
  # The i18n key for the message will be looked in namespaces:
18
18
  #
19
19
  # * `amazing_activist.activities.[activity].failures`
20
+ # * `activities.[activity].failures`
20
21
  # * `amazing_activist.failures`
22
+ # * `activities.failures`
21
23
  #
22
24
  # Thus, if activity `Pretty::DamnGoodActivity` failed with `:bad_choise`
23
25
  # code the lookup will be:
24
26
  #
25
27
  # * `amazing_activist.activities.pretty/damn_good_activity.failures.bad_choice
28
+ # * `activities.pretty/damn_good_activity.failures.bad_choice
26
29
  # * `amazing_activist.failures.bad_choice
30
+ # * `activities.failures.bad_choice
27
31
  #
28
32
  # If there's no translation with any of the above keys, a generic
29
33
  # non-translated message will be used:
@@ -32,14 +36,16 @@ module AmazingActivist
32
36
  #
33
37
  # @return [String] Failure message
34
38
  def message(code, **context)
35
- default = [
39
+ activity = @activity.class.name&.underscore
40
+ default = [
36
41
  :"amazing_activist.failures.#{code}",
42
+ :"activities.failures.#{code}",
37
43
  "<%{activity}> failed - %{code}" # rubocop:disable Style/FormatStringToken
38
44
  ]
39
45
 
40
- if @activity.class.name
41
- activity = @activity.class.name.underscore.presence
46
+ if activity
42
47
  i18n_key = :"amazing_activist.activities.#{activity}.failures.#{code}"
48
+ default.unshift(:"activities.#{activity}.failures.#{code}")
43
49
  else
44
50
  activity = "(anonymous activity)"
45
51
  i18n_key = default.shift
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AmazingActivist
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.2"
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.5.0
4
+ version: 0.5.2
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-03-13 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -69,9 +69,9 @@ licenses:
69
69
  - MIT
70
70
  metadata:
71
71
  homepage_uri: https://github.com/ixti/amazing-activist
72
- source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.5.0
72
+ source_code_uri: https://github.com/ixti/amazing-activist/tree/v0.5.2
73
73
  bug_tracker_uri: https://github.com/ixti/amazing-activist/issues
74
- changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.5.0/CHANGES.md
74
+ changelog_uri: https://github.com/ixti/amazing-activist/blob/v0.5.2/CHANGES.md
75
75
  rubygems_mfa_required: 'true'
76
76
  post_install_message:
77
77
  rdoc_options: []
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.5.4
91
+ rubygems_version: 3.5.11
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Your friendly neighborhood activist.