Module: A2A::Versioning
- Defined in:
- lib/a2a/versioning.rb
Constant Summary collapse
- CURRENT =
SPEC_VERSION- SUPPORTED =
[CURRENT].freeze
Class Method Summary collapse
-
.normalize(version) ⇒ Object
Returns the normalized Major.Minor string from a version value.
- .supported?(version) ⇒ Boolean
-
.validate!(version) ⇒ Object
Raises VersionNotSupportedError when the version is not in SUPPORTED.
Class Method Details
.normalize(version) ⇒ Object
Returns the normalized Major.Minor string from a version value. Strips any patch segment so “1.0.2” is treated as “1.0”.
10 11 12 13 |
# File 'lib/a2a/versioning.rb', line 10 def self.normalize(version) parts = version.to_s.split(".") "#{parts[0]}.#{parts[1]}" end |
.supported?(version) ⇒ Boolean
15 16 17 |
# File 'lib/a2a/versioning.rb', line 15 def self.supported?(version) SUPPORTED.include?(version.to_s) end |
.validate!(version) ⇒ Object
Raises VersionNotSupportedError when the version is not in SUPPORTED. Returns the normalized version string when valid.
21 22 23 24 25 26 |
# File 'lib/a2a/versioning.rb', line 21 def self.validate!(version) v = normalize(version) raise VersionNotSupportedError, "unsupported A2A version: #{v}" unless supported?(v) v end |