Class: Naether::Notation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#artifactObject (readonly)

Returns the value of attribute artifact.



10
11
12
# File 'lib/naether/notation.rb', line 10

def artifact
  @artifact
end

#classifierObject (readonly)

Returns the value of attribute classifier.



10
11
12
# File 'lib/naether/notation.rb', line 10

def classifier
  @classifier
end

#groupObject (readonly)

Returns the value of attribute group.



10
11
12
# File 'lib/naether/notation.rb', line 10

def group
  @group
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/naether/notation.rb', line 10

def type
  @type
end

#versionObject (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_notationObject



38
39
40
# File 'lib/naether/notation.rb', line 38

def to_notation
  "#{group}:#{artifact}:#{type}#{":#{classifier}" if classifier}:#{version}"
end