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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/foxtail/bundle.rb +14 -0
- data/lib/foxtail/runtime/version.rb +1 -1
- data/lib/foxtail/sequence.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0481921f0a1d7f75a66e7d46080aa646d5e5543ef357c3a09762c5fcf73f683f'
|
|
4
|
+
data.tar.gz: 37c9d137ac12ad305998d675b2ad571dd19370f6226527e4d219f1887df968ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e90826bf95eec404617e04c254c40c612ca01c7e10910126018de9cf460c5ba263e7de1c3d403f424f3341647255cc317b8fd2b21eeef66175cec5d9ea1914f5
|
|
7
|
+
data.tar.gz: 564c13c75088c2307b4df10a5ab84bd9556eb7cecf3d39b36decf4231edd6df6bded5bfe8148989f672aff2dd5b844cf979d025de959b4e091f837d83eccb381
|
data/CHANGELOG.md
CHANGED
data/lib/foxtail/bundle.rb
CHANGED
|
@@ -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
|
data/lib/foxtail/sequence.rb
CHANGED
|
@@ -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.
|
|
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-
|
|
11
|
+
date: 2026-05-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|