Class: SemverDialects::Maven::Version
- Inherits:
-
BaseVersion
- Object
- BaseVersion
- SemverDialects::Maven::Version
- Defined in:
- lib/semver_dialects/maven.rb
Overview
rubocop:todo Style/Documentation
Instance Attribute Summary collapse
-
#addition ⇒ Object
Returns the value of attribute addition.
Attributes inherited from BaseVersion
Instance Method Summary collapse
-
#to_a ⇒ Object
Return an array similar to the one Maven generates when parsing versions.
-
#to_s(as_addition = false) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter.
Methods inherited from BaseVersion
Constructor Details
This class inherits a constructor from SemverDialects::BaseVersion
Instance Attribute Details
#addition ⇒ Object
Returns the value of attribute addition.
15 16 17 |
# File 'lib/semver_dialects/maven.rb', line 15 def addition @addition end |
Instance Method Details
#to_a ⇒ Object
Return an array similar to the one Maven generates when parsing versions.
$ java -jar ${MAVEN_HOME}/lib/maven-artifact-3.9.6.jar 1a1
Display parameters as parsed by Maven (in canonical form and as a list of tokens) and comparison result:
1. 1a1 -> 1-alpha-1; tokens: [1, [alpha, [1]]]
23 24 25 26 27 |
# File 'lib/semver_dialects/maven.rb', line 23 def to_a return tokens if addition.nil? tokens.clone.append(addition.to_a) end |
#to_s(as_addition = false) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/semver_dialects/maven.rb', line 29 def to_s(as_addition = false) # rubocop:disable Style/OptionalBooleanParameter s = '' if tokens.any? s += '-' if as_addition s += tokens.map do |token| case token when String token when Integer case token when ALPHA 'alpha' when BETA 'beta' when MILESTONE 'milestone' when RC 'rc' when SNAPSHOT 'snapshot' else token.to_s end end end.join('.') end s += addition.to_s(true) if addition s end |