foxtail-runtime 0.5.0 → 0.6.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: d7c03fa078365be8892be86558075ca205acdc8cce593a18f594d85332239a87
4
- data.tar.gz: df182477a72b683c9055f579d88a83d896c97a2937f506e28b4df2dc31f4d90b
3
+ metadata.gz: '0481921f0a1d7f75a66e7d46080aa646d5e5543ef357c3a09762c5fcf73f683f'
4
+ data.tar.gz: 37c9d137ac12ad305998d675b2ad571dd19370f6226527e4d219f1887df968ee
5
5
  SHA512:
6
- metadata.gz: 5b884a63ba415f43fc3062644d2447090ed29fb49be70c68cb807c5f9cc34861e24b96652cb7826a311b3c74e29a8cdb8066cf269a4fb9632df4d3558f570b7f
7
- data.tar.gz: 15632c63f8abae557b11958be5ccd512839b3e357e9170b44afe06efd57949acedb9a26bf9bde1d06c336bd7a059f9c20c386dacea7691ebda5bb1636395b918
6
+ metadata.gz: e90826bf95eec404617e04c254c40c612ca01c7e10910126018de9cf460c5ba263e7de1c3d403f424f3341647255cc317b8fd2b21eeef66175cec5d9ea1914f5
7
+ data.tar.gz: 564c13c75088c2307b4df10a5ab84bd9556eb7cecf3d39b36decf4231edd6df6bded5bfe8148989f672aff2dd5b844cf979d025de959b4e091f837d83eccb381
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] - 2026-05-09
4
+
5
+ ### Added
6
+ - Add `format_attribute` to `Bundle` and `Sequence` for formatting message attributes directly (#179)
7
+
3
8
  ## [0.5.0] - 2026-05-08
4
9
 
5
10
  ### Added
@@ -123,6 +123,20 @@ module Foxtail
123
123
  format_pattern(message.value, errors, **)
124
124
  end
125
125
 
126
+ # Format a message attribute with the given arguments.
127
+ #
128
+ # @param id [String, Symbol] Message identifier
129
+ # @param attr [String, Symbol] Attribute name
130
+ # @param errors [Array, nil] If provided, errors are collected into this array instead of being ignored.
131
+ # @return [String] Formatted attribute string, or "id.attr" if message or attribute not found
132
+ def format_attribute(id, attr, errors=nil, **)
133
+ msg = message(id)
134
+ pattern = msg&.attributes&.[](attr.to_s)
135
+ return "#{id}.#{attr}" unless pattern
136
+
137
+ format_pattern(pattern, errors, **)
138
+ end
139
+
126
140
  # Format a pattern with the given arguments (using Resolver)
127
141
  #
128
142
  # @param pattern [String, Array] The pattern to format
@@ -3,7 +3,7 @@
3
3
  module Foxtail
4
4
  module Runtime
5
5
  # Current version of the Foxtail runtime gem
6
- VERSION = "0.5.0"
6
+ VERSION = "0.6.0"
7
7
  public_constant :VERSION
8
8
  end
9
9
  end
@@ -44,6 +44,18 @@ module Foxtail
44
44
  bundle ? bundle.format(id, errors, **) : id.to_s
45
45
  end
46
46
 
47
+ # Formats a message attribute using the first bundle that contains the message.
48
+ # Keyword arguments are passed through to the bundle's format_attribute method.
49
+ #
50
+ # @param id [String] The message ID
51
+ # @param attr [String, Symbol] Attribute name
52
+ # @param errors [Array, nil] If provided, errors are collected into this array instead of being ignored.
53
+ # @return [String] The formatted attribute, or "id.attr" if not found
54
+ def format_attribute(id, attr, errors=nil, **)
55
+ bundle = find_bundle(id)
56
+ bundle ? bundle.format_attribute(id, attr, errors, **) : "#{id}.#{attr}"
57
+ end
58
+
47
59
  private def find_bundle(id) = @bundles.find {|bundle| bundle.message?(id) }
48
60
  end
49
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foxtail-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OZAWA Sakuro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-08 00:00:00.000000000 Z
11
+ date: 2026-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal