Class: WonkoTheSane::Util::MavenIdentifier
- Inherits:
-
Object
- Object
- WonkoTheSane::Util::MavenIdentifier
- Defined in:
- lib/wonko_the_sane/util/maven_identifier.rb
Instance Attribute Summary collapse
-
#artifact ⇒ Object
Returns the value of attribute artifact.
-
#classifier ⇒ Object
Returns the value of attribute classifier.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#group ⇒ Object
Returns the value of attribute group.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(string) ⇒ MavenIdentifier
constructor
A new instance of MavenIdentifier.
- #to_name ⇒ Object
- #to_path ⇒ Object
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
#artifact ⇒ Object
Returns the value of attribute artifact.
5 6 7 |
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 5 def artifact @artifact end |
#classifier ⇒ Object
Returns the value of attribute classifier.
7 8 9 |
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 7 def classifier @classifier end |
#extension ⇒ Object
Returns the value of attribute extension.
8 9 10 |
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 8 def extension @extension end |
#group ⇒ Object
Returns the value of attribute group.
4 5 6 |
# File 'lib/wonko_the_sane/util/maven_identifier.rb', line 4 def group @group end |
#version ⇒ Object
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_name ⇒ Object
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_path ⇒ Object
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 |