Class: Naether::Notation
- Inherits:
-
Object
- Object
- Naether::Notation
- Defined in:
- lib/naether/notation.rb
Overview
Helper for handling Maven notations, supports notations:
* artifactId:groupId:version
* artifactId:groupId:type:version
* artifactId:groupId:type:classifier:version
Constant Summary collapse
- PATTERN =
Regexp.compile( '^(.+?):(.+?):(.+?)(:(.+?)(:(.+))?)?$' )
Instance Attribute Summary collapse
-
#artifact ⇒ Object
readonly
Returns the value of attribute artifact.
-
#classifier ⇒ Object
readonly
Returns the value of attribute classifier.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(notation) ⇒ Notation
constructor
A new instance of Notation.
- #to_notation ⇒ Object
Constructor Details
#initialize(notation) ⇒ Notation
Returns a new instance of Notation.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/naether/notation.rb', line 14 def initialize(notation) if notation =~ PATTERN @group = Regexp.last_match(1) @artifact = Regexp.last_match(2) # artifactId:groupId:type:classifier:version if Regexp.last_match(7) @type = Regexp.last_match(3) @classifier = Regexp.last_match(5) @version = Regexp.last_match(7) # artifactId:groupId:type:version elsif Regexp.last_match(5) @type = Regexp.last_match(3) @version = Regexp.last_match(5) # artifactId:groupId:version - else @type = 'jar' @version = Regexp.last_match(3) end end end |
Instance Attribute Details
#artifact ⇒ Object (readonly)
Returns the value of attribute artifact.
10 11 12 |
# File 'lib/naether/notation.rb', line 10 def artifact @artifact end |
#classifier ⇒ Object (readonly)
Returns the value of attribute classifier.
10 11 12 |
# File 'lib/naether/notation.rb', line 10 def classifier @classifier end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
10 11 12 |
# File 'lib/naether/notation.rb', line 10 def group @group end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/naether/notation.rb', line 10 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/naether/notation.rb', line 10 def version @version end |
Instance Method Details
#to_notation ⇒ Object
38 39 40 |
# File 'lib/naether/notation.rb', line 38 def to_notation "#{group}:#{artifact}:#{type}#{":#{classifier}" if classifier}:#{version}" end |