Class: WonkoTheSane::Util::MavenIdentifier

Inherits:
Object
  • Object
show all
Defined in:
lib/wonko_the_sane/util/maven_identifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ MavenIdentifier

Returns a new instance of MavenIdentifier.



10
11
12
13
14
15
16
17
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 10

def initialize(string)
  parts = string.match /(?<group>[^:@]+):(?<artifact>[^:@]+):(?<version>[^:@]+)(:(?<classifier>[^:@]+))?(@(?<extension>[^:@]+))?/
  @group = parts[:group]
  @artifact = parts[:artifact]
  @version = parts[:version]
  @classifier = parts[:classifier]
  @extension = parts[:extension] ? parts[:extension] : 'jar'
end

Instance Attribute Details

#artifactObject

Returns the value of attribute artifact.



5
6
7
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 5

def artifact
  @artifact
end

#classifierObject

Returns the value of attribute classifier.



7
8
9
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 7

def classifier
  @classifier
end

#extensionObject

Returns the value of attribute extension.



8
9
10
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 8

def extension
  @extension
end

#groupObject

Returns the value of attribute group.



4
5
6
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 4

def group
  @group
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 6

def version
  @version
end

Instance Method Details

#to_nameObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 27

def to_name
  name = @group + ':' + @artifact + ':' + @version
  if @classifier
    name = name + ':' + @classifier
  end
  if @extension != 'jar'
    name = name + '@' + @extension
  end
  return name
end

#to_pathObject



19
20
21
22
23
24
25
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 19

def to_path
  path = @group.gsub(/\./, '/') + '/' + @artifact + '/' + @version + '/' + @artifact + '-' + @version
  if @classifier
    path = path + '-' + @classifier
  end
  return path + '.' + @extension
end